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

Function tryGetObjectLikeCompletionContainer

test/fixtures/snapshot/typescript.js:134949–134967  ·  view source on GitHub ↗

* Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given.

(contextToken)

Source from the content-addressed store, hash-verified

134947 * on the condition that one exists and that the context implies completion should be given.
134948 */
134949 function tryGetObjectLikeCompletionContainer(contextToken) {
134950 if (contextToken) {
134951 var parent = contextToken.parent;
134952 switch (contextToken.kind) {
134953 case 18 /* SyntaxKind.OpenBraceToken */: // const x = { |
134954 case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, |
134955 if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
134956 return parent;
134957 }
134958 break;
134959 case 41 /* SyntaxKind.AsteriskToken */:
134960 return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
134961 case 79 /* SyntaxKind.Identifier */:
134962 return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
134963 ? contextToken.parent.parent : undefined;
134964 }
134965 }
134966 return undefined;
134967 }
134968 function getRelevantTokens(position, sourceFile) {
134969 var previousToken = ts.findPrecedingToken(position, sourceFile);
134970 if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected