import { Declaration , DeclarationType } from './declaration' ; import { isFinalVariableDeclaration } from './declarationUtils' ; import { Symbol } from './symbol' ; export function getLastTypedDeclaredForSymbol ( symbol ) { const typedDecls = symbol . getTypedDeclarations ( ) ; if ( typedDecls . length > 0 ) { return typedDecls [ typedDecls . length - 1 ] ; } return undefined ; } export function isTypedDictMemberAccessedThroughIndex ( symbol ) { const typedDecls = symbol . getTypedDeclarations ( ) ; if ( typedDecls . length > 0 ) { const lastDecl = typedDecls [ typedDecls . length - 1 ] ; if ( lastDecl . type === DeclarationType . Variable ) { return true ; } } return false ; } export function isFinalVariable ( symbol ) { return symbol . getDeclarations ( ) . some ( ( decl ) => isFinalVariableDeclaration ( decl ) ) ; } export function isRequiredTypedDictVariable ( symbol ) { return symbol . getDeclarations ( ) . some ( ( decl ) => decl . type === DeclarationType . Variable && ! ! decl . isRequired ) ; } export function isNotRequiredTypedDictVariable ( symbol ) { return symbol . getDeclarations ( ) . some ( ( decl ) => decl . type === DeclarationType . Variable && ! ! decl . isNotRequired ) ; }