MCPcopy Index your code
hub / github.com/nodejs/node / getSymbolCompletionFromEntryId

Function getSymbolCompletionFromEntryId

test/fixtures/snapshot/typescript.js:133094–133136  ·  view source on GitHub ↗
(program, log, sourceFile, position, entryId, host, preferences)

Source from the content-addressed store, hash-verified

133092 return entries;
133093 }
133094 function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
133095 if (entryId.data) {
133096 var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
133097 if (autoImport) {
133098 var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken;
133099 return {
133100 type: "symbol",
133101 symbol: autoImport.symbol,
133102 location: ts.getTouchingPropertyName(sourceFile, position),
133103 previousToken: previousToken_1,
133104 contextToken: contextToken_1,
133105 isJsxInitializer: false,
133106 isTypeOnlyLocation: false,
133107 origin: autoImport.origin,
133108 };
133109 }
133110 }
133111 var compilerOptions = program.getCompilerOptions();
133112 var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
133113 if (!completionData) {
133114 return { type: "none" };
133115 }
133116 if (completionData.kind !== 0 /* CompletionDataKind.Data */) {
133117 return { type: "request", request: completionData };
133118 }
133119 var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
133120 var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; });
133121 if (literal !== undefined)
133122 return { type: "literal", literal: literal };
133123 // Find the symbol with the matching entry name.
133124 // We don't need to perform character checks here because we're only comparing the
133125 // name against 'entryName' (which is known to be good), not building a new
133126 // completion entry.
133127 return ts.firstDefined(symbols, function (symbol, index) {
133128 var origin = symbolToOriginInfoMap[index];
133129 var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
133130 return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */
133131 || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)
133132 || getSourceFromOrigin(origin) === entryId.source)
133133 ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
133134 : undefined;
133135 }) || { type: "none" };
133136 }
133137 function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
133138 var typeChecker = program.getTypeChecker();
133139 var compilerOptions = program.getCompilerOptions();

Callers 2

getCompletionEntrySymbolFunction · 0.85

Calls 7

getRelevantTokensFunction · 0.85
getCompletionDataFunction · 0.85
completionNameForLiteralFunction · 0.85
getSourceFromOriginFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected