@@ -10950,58 +10950,55 @@ func (node *SourceFile) ECMALineMap() []core.TextPos {
1095010950// If the name appears more than once, the value is -1.
1095110951func (file * SourceFile ) GetNameTable () map [string ]int {
1095210952 file .nameTableOnce .Do (func () {
10953- file .nameTable = file .initializeNameTable ()
10954- })
10955- return file .nameTable
10956- }
10953+ nameTable := make (map [string ]int )
1095710954
10958- func (file * SourceFile ) initializeNameTable () map [string ]int {
10959- nameTable := make (map [string ]int )
10955+ isTagName := func (node * Node ) bool {
10956+ return node .Parent != nil && IsJSDocTag (node .Parent ) && node .Parent .TagName () == node
10957+ }
1096010958
10961- isTagName := func (node * Node ) bool {
10962- return node .Parent != nil && IsJSDocTag (node .Parent ) && node .Parent .TagName () == node
10963- }
10959+ isArgumentOfElementAccessExpression := func (node * Node ) bool {
10960+ return node != nil && node .Parent != nil &&
10961+ node .Parent .Kind == KindElementAccessExpression &&
10962+ node .Parent .AsElementAccessExpression ().ArgumentExpression == node
10963+ }
1096410964
10965- isArgumentOfElementAccessExpression := func (node * Node ) bool {
10966- return node != nil && node .Parent != nil &&
10967- node .Parent .Kind == KindElementAccessExpression &&
10968- node .Parent .AsElementAccessExpression ().ArgumentExpression == node
10969- }
10965+ // We want to store any numbers/strings if they were a name that could be
10966+ // related to a declaration. So, if we have 'import x = require("something")'
10967+ // then we want 'something' to be in the name table. Similarly, if we have
10968+ // "a['propname']" then we want to store "propname" in the name table.
10969+ literalIsName := func (node * Node ) bool {
10970+ return IsDeclarationName (node ) ||
10971+ node .Parent .Kind == KindExternalModuleReference ||
10972+ isArgumentOfElementAccessExpression (node ) ||
10973+ IsLiteralComputedPropertyDeclarationName (node )
10974+ }
1097010975
10971- // We want to store any numbers/strings if they were a name that could be
10972- // related to a declaration. So, if we have 'import x = require("something")'
10973- // then we want 'something' to be in the name table. Similarly, if we have
10974- // "a['propname']" then we want to store "propname" in the name table.
10975- literalIsName := func (node * Node ) bool {
10976- return IsDeclarationName (node ) ||
10977- node .Parent .Kind == KindExternalModuleReference ||
10978- isArgumentOfElementAccessExpression (node ) ||
10979- IsLiteralComputedPropertyDeclarationName (node )
10980- }
10976+ var walk func (node * Node ) bool
10977+ walk = func (node * Node ) bool {
10978+ if IsIdentifier (node ) && ! isTagName (node ) && node .Text () != "" ||
10979+ IsStringOrNumericLiteralLike (node ) && literalIsName (node ) ||
10980+ IsPrivateIdentifier (node ) {
10981+ text := node .Text ()
10982+ if _ , ok := nameTable [text ]; ok {
10983+ nameTable [text ] = - 1
10984+ } else {
10985+ nameTable [text ] = node .Pos ()
10986+ }
10987+ }
1098110988
10982- var walk func (node * Node ) bool
10983- walk = func (node * Node ) bool {
10984- if IsIdentifier (node ) && ! isTagName (node ) && node .Text () != "" ||
10985- IsStringOrNumericLiteralLike (node ) && literalIsName (node ) ||
10986- IsPrivateIdentifier (node ) {
10987- text := node .Text ()
10988- if _ , ok := nameTable [text ]; ok {
10989- nameTable [text ] = - 1
10990- } else {
10991- nameTable [text ] = node .Pos ()
10989+ node .ForEachChild (walk )
10990+ jsdocNodes := node .JSDoc (file )
10991+ for _ , jsdoc := range jsdocNodes {
10992+ jsdoc .ForEachChild (walk )
1099210993 }
10994+ return false
1099310995 }
1099410996
10995- node .ForEachChild (walk )
10996- jsdocNodes := node .JSDoc (file )
10997- for _ , jsdoc := range jsdocNodes {
10998- jsdoc .ForEachChild (walk )
10999- }
11000- return false
11001- }
10997+ file .AsNode ().ForEachChild (walk )
1100210998
11003- file .AsNode ().ForEachChild (walk )
11004- return nameTable
10999+ file .nameTable = nameTable
11000+ })
11001+ return file .nameTable
1100511002}
1100611003
1100711004func (node * SourceFile ) IsBound () bool {
0 commit comments