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

Function nodeIsASICandidate

test/fixtures/snapshot/typescript.js:129028–129065  ·  view source on GitHub ↗
(node, sourceFile)

Source from the content-addressed store, hash-verified

129026 ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI;
129027 ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI);
129028 function nodeIsASICandidate(node, sourceFile) {
129029 var lastToken = node.getLastToken(sourceFile);
129030 if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) {
129031 return false;
129032 }
129033 if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) {
129034 if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) {
129035 return false;
129036 }
129037 }
129038 else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) {
129039 var lastChild = ts.last(node.getChildren(sourceFile));
129040 if (lastChild && ts.isModuleBlock(lastChild)) {
129041 return false;
129042 }
129043 }
129044 else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) {
129045 var lastChild = ts.last(node.getChildren(sourceFile));
129046 if (lastChild && ts.isFunctionBlock(lastChild)) {
129047 return false;
129048 }
129049 }
129050 else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) {
129051 return false;
129052 }
129053 // See comment in parser’s `parseDoStatement`
129054 if (node.kind === 240 /* SyntaxKind.DoStatement */) {
129055 return true;
129056 }
129057 var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; });
129058 var nextToken = findNextToken(node, topNode, sourceFile);
129059 if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) {
129060 return true;
129061 }
129062 var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
129063 var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line;
129064 return startLine !== endLine;
129065 }
129066 function positionIsASICandidate(pos, context, sourceFile) {
129067 var contextAncestor = ts.findAncestor(context, function (ancestor) {
129068 if (ancestor.end !== pos) {

Callers 1

positionIsASICandidateFunction · 0.85

Tested by

no test coverage detected