@@ -57,7 +57,7 @@ namespace ts.Completions {
57
57
58
58
if ( isSourceFileJavaScript ( sourceFile ) ) {
59
59
const uniqueNames = getCompletionEntriesFromSymbols ( symbols , entries , location , /*performCharacterChecks*/ true , typeChecker , compilerOptions . target , log ) ;
60
- addRange ( entries , getJavaScriptCompletionEntries ( sourceFile , location . pos , uniqueNames , compilerOptions . target ) ) ;
60
+ getJavaScriptCompletionEntries ( sourceFile , location . pos , uniqueNames , compilerOptions . target , entries ) ;
61
61
}
62
62
else {
63
63
if ( ( ! symbols || symbols . length === 0 ) && keywordFilters === KeywordCompletionFilters . None ) {
@@ -79,33 +79,34 @@ namespace ts.Completions {
79
79
return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, entries } ;
80
80
}
81
81
82
- function getJavaScriptCompletionEntries ( sourceFile : SourceFile , position : number , uniqueNames : Map < true > , target : ScriptTarget ) : CompletionEntry [ ] {
83
- const entries : CompletionEntry [ ] = [ ] ;
84
-
85
- const nameTable = getNameTable ( sourceFile ) ;
86
- nameTable . forEach ( ( pos , name ) => {
82
+ function getJavaScriptCompletionEntries (
83
+ sourceFile : SourceFile ,
84
+ position : number ,
85
+ uniqueNames : Map < true > ,
86
+ target : ScriptTarget ,
87
+ entries : Push < CompletionEntry > ) : void {
88
+ getNameTable ( sourceFile ) . forEach ( ( pos , name ) => {
87
89
// Skip identifiers produced only from the current location
88
90
if ( pos === position ) {
89
91
return ;
90
92
}
91
93
const realName = unescapeLeadingUnderscores ( name ) ;
92
94
93
- if ( ! uniqueNames . get ( realName ) ) {
94
- uniqueNames . set ( realName , true ) ;
95
- const displayName = getCompletionEntryDisplayName ( realName , target , /*performCharacterChecks*/ true ) ;
96
- if ( displayName ) {
97
- const entry = {
98
- name : displayName ,
99
- kind : ScriptElementKind . warning ,
100
- kindModifiers : "" ,
101
- sortText : "1"
102
- } ;
103
- entries . push ( entry ) ;
104
- }
95
+ if ( uniqueNames . has ( realName ) ) {
96
+ return ;
105
97
}
106
- } ) ;
107
98
108
- return entries ;
99
+ uniqueNames . set ( realName , true ) ;
100
+ const displayName = getCompletionEntryDisplayName ( realName , target , /*performCharacterChecks*/ true ) ;
101
+ if ( displayName ) {
102
+ entries . push ( {
103
+ name : displayName ,
104
+ kind : ScriptElementKind . warning ,
105
+ kindModifiers : "" ,
106
+ sortText : "1"
107
+ } ) ;
108
+ }
109
+ } ) ;
109
110
}
110
111
111
112
function createCompletionEntry ( symbol : Symbol , location : Node , performCharacterChecks : boolean , typeChecker : TypeChecker , target : ScriptTarget ) : CompletionEntry {
@@ -141,7 +142,7 @@ namespace ts.Completions {
141
142
const entry = createCompletionEntry ( symbol , location , performCharacterChecks , typeChecker , target ) ;
142
143
if ( entry ) {
143
144
const id = entry . name ;
144
- if ( ! uniqueNames . get ( id ) ) {
145
+ if ( ! uniqueNames . has ( id ) ) {
145
146
entries . push ( entry ) ;
146
147
uniqueNames . set ( id , true ) ;
147
148
}
0 commit comments