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

Function tryParseModifier

test/fixtures/snapshot/typescript.js:36748–36770  ·  view source on GitHub ↗
(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier)

Source from the content-addressed store, hash-verified

36746 return list && createNodeArray(list, pos);
36747 }
36748 function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
36749 var pos = getNodePos();
36750 var kind = token();
36751 if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) {
36752 // We need to ensure that any subsequent modifiers appear on the same line
36753 // so that when 'const' is a standalone declaration, we don't issue an error.
36754 if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
36755 return undefined;
36756 }
36757 }
36758 else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
36759 return undefined;
36760 }
36761 else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) {
36762 return undefined;
36763 }
36764 else {
36765 if (!parseAnyContextualModifier()) {
36766 return undefined;
36767 }
36768 }
36769 return finishNode(factory.createToken(kind), pos);
36770 }
36771 /*
36772 * There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member.
36773 * In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect

Callers 1

parseModifiersFunction · 0.85

Calls 6

getNodePosFunction · 0.85
tryParseFunction · 0.85
lookAheadFunction · 0.85
finishNodeFunction · 0.85
tokenFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…