MCPcopy Create free account
hub / github.com/nodejs/node / shouldIncludeSymbol

Function shouldIncludeSymbol

test/fixtures/snapshot/typescript.js:133022–133061  ·  view source on GitHub ↗
(symbol, symbolToSortTextMap)

Source from the content-addressed store, hash-verified

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
133042 if (!!sourceFile.externalModuleIndicator
133043 && !compilerOptions.allowUmdGlobalAccess
133044 && symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
133045 && (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
133046 || symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
133047 return false;
133048 }
133049 allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
133050 // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
133051 if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
133052 return !!(allFlags & 1920 /* SymbolFlags.Namespace */);
133053 }
133054 if (isTypeOnlyLocation) {
133055 // It's a type, but you can reach it by namespace.type as well
133056 return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker);
133057 }
133058 }
133059 // expressions are value space (which includes the value namespaces)
133060 return !!(allFlags & 111551 /* SymbolFlags.Value */);
133061 }
133062 }
133063 Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
133064 function getLabelCompletionAtPosition(node) {

Callers 1

Tested by

no test coverage detected