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

Function parseClassElement

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

Source from the content-addressed store, hash-verified

36796 return modifiers;
36797 }
36798 function parseClassElement() {
36799 var pos = getNodePos();
36800 if (token() === 26 /* SyntaxKind.SemicolonToken */) {
36801 nextToken();
36802 return finishNode(factory.createSemicolonClassElement(), pos);
36803 }
36804 var hasJSDoc = hasPrecedingJSDocComment();
36805 var decorators = parseDecorators();
36806 var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true);
36807 if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
36808 return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
36809 }
36810 if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) {
36811 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */);
36812 }
36813 if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) {
36814 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */);
36815 }
36816 if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) {
36817 var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
36818 if (constructorDeclaration) {
36819 return constructorDeclaration;
36820 }
36821 }
36822 if (isIndexSignature()) {
36823 return parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers);
36824 }
36825 // It is very important that we check this *after* checking indexers because
36826 // the [ token can start an index signature or a computed property name
36827 if (ts.tokenIsIdentifierOrKeyword(token()) ||
36828 token() === 10 /* SyntaxKind.StringLiteral */ ||
36829 token() === 8 /* SyntaxKind.NumericLiteral */ ||
36830 token() === 41 /* SyntaxKind.AsteriskToken */ ||
36831 token() === 22 /* SyntaxKind.OpenBracketToken */) {
36832 var isAmbient = ts.some(modifiers, isDeclareModifier);
36833 if (isAmbient) {
36834 for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36835 var m = _a[_i];
36836 m.flags |= 16777216 /* NodeFlags.Ambient */;
36837 }
36838 return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36839 }
36840 else {
36841 return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
36842 }
36843 }
36844 if (decorators || modifiers) {
36845 // treat this as a property declaration with a missing name.
36846 var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
36847 return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined);
36848 }
36849 // 'isClassMemberStart' should have hinted not to attempt parsing.
36850 return ts.Debug.fail("Should not have attempted to parse class member declaration.");
36851 }
36852 function parseClassExpression() {
36853 return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */);
36854 }

Callers

nothing calls this directly

Calls 15

getNodePosFunction · 0.85
nextTokenFunction · 0.85
finishNodeFunction · 0.85
hasPrecedingJSDocCommentFunction · 0.85
parseDecoratorsFunction · 0.85
parseModifiersFunction · 0.85
lookAheadFunction · 0.85
parseContextualModifierFunction · 0.85
parseAccessorDeclarationFunction · 0.85
isIndexSignatureFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…