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

Function parseRightSideOfDot

test/fixtures/snapshot/typescript.js:33147–33181  ·  view source on GitHub ↗
(allowIdentifierNames, allowPrivateIdentifiers)

Source from the content-addressed store, hash-verified

33145 return finishNode(factory.createQualifiedName(entity, name), entity.pos);
33146 }
33147 function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
33148 // Technically a keyword is valid here as all identifiers and keywords are identifier names.
33149 // However, often we'll encounter this in error situations when the identifier or keyword
33150 // is actually starting another valid construct.
33151 //
33152 // So, we check for the following specific case:
33153 //
33154 // name.
33155 // identifierOrKeyword identifierNameOrKeyword
33156 //
33157 // Note: the newlines are important here. For example, if that above code
33158 // were rewritten into:
33159 //
33160 // name.identifierOrKeyword
33161 // identifierNameOrKeyword
33162 //
33163 // Then we would consider it valid. That's because ASI would take effect and
33164 // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
33165 // In the first case though, ASI will not take effect because there is not a
33166 // line terminator after the identifier or keyword.
33167 if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
33168 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
33169 if (matchesPattern) {
33170 // Report that we need an identifier. However, report it right after the dot,
33171 // and not on the next token. This is because the next token might actually
33172 // be an identifier and the error would be quite confusing.
33173 return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
33174 }
33175 }
33176 if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33177 var node = parsePrivateIdentifier();
33178 return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected);
33179 }
33180 return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
33181 }
33182 function parseTemplateSpans(isTaggedTemplate) {
33183 var pos = getNodePos();
33184 var list = [];

Callers 4

parseEntityNameFunction · 0.85
parseSuperExpressionFunction · 0.85
parseJsxElementNameFunction · 0.85

Calls 6

lookAheadFunction · 0.85
createMissingNodeFunction · 0.85
parsePrivateIdentifierFunction · 0.85
parseIdentifierNameFunction · 0.85
parseIdentifierFunction · 0.85
tokenFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…