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

Function getCandidate

test/fixtures/snapshot/typescript.js:135396–135434  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135394 : undefined
135395 };
135396 function getCandidate() {
135397 var parent = contextToken.parent;
135398 if (ts.isImportEqualsDeclaration(parent)) {
135399 keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */;
135400 return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined;
135401 }
135402 if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) {
135403 return parent;
135404 }
135405 if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) {
135406 if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ ||
135407 contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ ||
135408 contextToken.kind === 27 /* SyntaxKind.CommaToken */)) {
135409 keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
135410 }
135411 if (canCompleteFromNamedBindings(parent)) {
135412 // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from`
135413 if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) {
135414 isKeywordOnlyCompletion = true;
135415 keywordCompletion = 156 /* SyntaxKind.FromKeyword */;
135416 }
135417 else {
135418 return parent.parent.parent;
135419 }
135420 }
135421 return undefined;
135422 }
135423 if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) {
135424 // A lone import keyword with nothing following it does not parse as a statement at all
135425 keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
135426 return contextToken;
135427 }
135428 if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) {
135429 // `import s| from`
135430 keywordCompletion = 152 /* SyntaxKind.TypeKeyword */;
135431 return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined;
135432 }
135433 return undefined;
135434 }
135435 }
135436 function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) {
135437 return ts.isImportSpecifier(importSpecifier)

Callers 1

Tested by

no test coverage detected