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

Function isValidTrigger

test/fixtures/snapshot/typescript.js:135318–135342  ·  view source on GitHub ↗
(sourceFile, triggerCharacter, contextToken, position)

Source from the content-addressed store, hash-verified

135316 return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent);
135317 }
135318 function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) {
135319 switch (triggerCharacter) {
135320 case ".":
135321 case "@":
135322 return true;
135323 case '"':
135324 case "'":
135325 case "`":
135326 // Only automatically bring up completions if this is an opening quote.
135327 return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1;
135328 case "#":
135329 return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken);
135330 case "<":
135331 // Opening JSX tag
135332 return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent));
135333 case "/":
135334 return !!contextToken && (ts.isStringLiteralLike(contextToken)
135335 ? !!ts.tryGetImportFromModuleSpecifier(contextToken)
135336 : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent));
135337 case " ":
135338 return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */;
135339 default:
135340 return ts.Debug.assertNever(triggerCharacter);
135341 }
135342 }
135343 function binaryExpressionMayBeOpenTag(_a) {
135344 var left = _a.left;
135345 return ts.nodeIsMissing(left);

Callers 1

getCompletionsAtPositionFunction · 0.85

Calls 1

Tested by

no test coverage detected