(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag)
| 132982 | } |
| 132983 | } |
| 132984 | function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) { |
| 132985 | var _a; |
| 132986 | var start = ts.timestamp(); |
| 132987 | var variableDeclaration = getVariableDeclaration(location); |
| 132988 | var useSemicolons = ts.probablyUsesSemicolons(sourceFile); |
| 132989 | var typeChecker = program.getTypeChecker(); |
| 132990 | // Tracks unique names. |
| 132991 | // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; |
| 132992 | // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. |
| 132993 | // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. |
| 132994 | var uniques = new ts.Map(); |
| 132995 | for (var i = 0; i < symbols.length; i++) { |
| 132996 | var symbol = symbols[i]; |
| 132997 | var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; |
| 132998 | var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); |
| 132999 | if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { |
| 133000 | continue; |
| 133001 | } |
| 133002 | var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; |
| 133003 | var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; |
| 133004 | var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText); |
| 133005 | var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag); |
| 133006 | if (!entry) { |
| 133007 | continue; |
| 133008 | } |
| 133009 | /** True for locals; false for globals, module exports from other files, `this.` completions. */ |
| 133010 | var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); })); |
| 133011 | uniques.set(name, shouldShadowLaterSymbols); |
| 133012 | ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true); |
| 133013 | } |
| 133014 | log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); |
| 133015 | // Prevent consumers of this map from having to worry about |
| 133016 | // the boolean value. Externally, it should be seen as the |
| 133017 | // set of all names. |
| 133018 | return { |
| 133019 | has: function (name) { return uniques.has(name); }, |
| 133020 | add: function (name) { return uniques.set(name, true); }, |
| 133021 | }; |
| 133022 | function shouldIncludeSymbol(symbol, symbolToSortTextMap) { |
| 133023 | var allFlags = symbol.flags; |
| 133024 | if (!ts.isSourceFile(location)) { |
| 133025 | // export = /**/ here we want to get all meanings, so any symbol is ok |
| 133026 | if (ts.isExportAssignment(location.parent)) { |
| 133027 | return true; |
| 133028 | } |
| 133029 | // Filter out variables from their own initializers |
| 133030 | // `const a = /* no 'a' here */` |
| 133031 | if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { |
| 133032 | return false; |
| 133033 | } |
| 133034 | // External modules can have global export declarations that will be |
| 133035 | // available as global keywords in all scopes. But if the external module |
| 133036 | // already has an explicit export and user only wants to user explicit |
| 133037 | // module imports then the global keywords will be filtered out so auto |
| 133038 | // import suggestions will win in the completion |
| 133039 | var symbolOrigin = ts.skipAlias(symbol, typeChecker); |
| 133040 | // We only want to filter out the global keywords |
| 133041 | // Auto Imports are not available for scripts so this conditional is always false |
no test coverage detected