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

Function parseObjectLiteralElement

test/fixtures/snapshot/typescript.js:35720–35770  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35718 return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
35719 }
35720 function parseObjectLiteralElement() {
35721 var pos = getNodePos();
35722 var hasJSDoc = hasPrecedingJSDocComment();
35723 if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) {
35724 var expression = parseAssignmentExpressionOrHigher();
35725 return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
35726 }
35727 var decorators = parseDecorators();
35728 var modifiers = parseModifiers();
35729 if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) {
35730 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */);
35731 }
35732 if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) {
35733 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */);
35734 }
35735 var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */);
35736 var tokenIsIdentifier = isIdentifier();
35737 var name = parsePropertyName();
35738 // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker.
35739 var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */);
35740 var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */);
35741 if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) {
35742 return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken);
35743 }
35744 // check if it is short-hand property assignment or normal property assignment
35745 // NOTE: if token is EqualsToken it is interpreted as CoverInitializedName production
35746 // CoverInitializedName[Yield] :
35747 // IdentifierReference[?Yield] Initializer[In, ?Yield]
35748 // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern
35749 var node;
35750 var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */);
35751 if (isShorthandPropertyAssignment) {
35752 var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */);
35753 var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
35754 node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
35755 // Save equals token for error reporting.
35756 // TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
35757 node.equalsToken = equalsToken;
35758 }
35759 else {
35760 parseExpected(58 /* SyntaxKind.ColonToken */);
35761 var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
35762 node = factory.createPropertyAssignment(name, initializer);
35763 }
35764 // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
35765 node.decorators = decorators;
35766 node.modifiers = modifiers;
35767 node.questionToken = questionToken;
35768 node.exclamationToken = exclamationToken;
35769 return withJSDoc(finishNode(node, pos), hasJSDoc);
35770 }
35771 function parseObjectLiteralExpression() {
35772 var pos = getNodePos();
35773 var openBracePosition = scanner.getTokenPos();

Callers

nothing calls this directly

Calls 15

getNodePosFunction · 0.85
hasPrecedingJSDocCommentFunction · 0.85
parseOptionalTokenFunction · 0.85
withJSDocFunction · 0.85
finishNodeFunction · 0.85
parseDecoratorsFunction · 0.85
parseModifiersFunction · 0.85
parseContextualModifierFunction · 0.85
parseAccessorDeclarationFunction · 0.85
parsePropertyNameFunction · 0.85
parseMethodDeclarationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…