()
| 1847 | } |
| 1848 | |
| 1849 | func (p *Parser) parseClassElement() *ast.Node { |
| 1850 | pos := p.nodePos() |
| 1851 | jsdoc := p.jsdocScannerInfo() |
| 1852 | if p.token == ast.KindSemicolonToken { |
| 1853 | p.nextToken() |
| 1854 | result := p.finishNode(p.factory.NewSemicolonClassElement(), pos) |
| 1855 | p.withJSDoc(result, jsdoc) |
| 1856 | return result |
| 1857 | } |
| 1858 | modifiers := p.parseModifiersEx(true /*allowDecorators*/, true /*permitConstAsModifier*/, true /*stopOnStartOfClassStaticBlock*/) |
| 1859 | if p.token == ast.KindStaticKeyword && p.lookAhead((*Parser).nextTokenIsOpenBrace) { |
| 1860 | return p.parseClassStaticBlockDeclaration(pos, jsdoc, modifiers) |
| 1861 | } |
| 1862 | if p.parseContextualModifier(ast.KindGetKeyword) { |
| 1863 | return p.parseAccessorDeclaration(pos, jsdoc, modifiers, ast.KindGetAccessor, ParseFlagsNone) |
| 1864 | } |
| 1865 | if p.parseContextualModifier(ast.KindSetKeyword) { |
| 1866 | return p.parseAccessorDeclaration(pos, jsdoc, modifiers, ast.KindSetAccessor, ParseFlagsNone) |
| 1867 | } |
| 1868 | if p.token == ast.KindConstructorKeyword || p.token == ast.KindStringLiteral { |
| 1869 | constructorDeclaration := p.tryParseConstructorDeclaration(pos, jsdoc, modifiers) |
| 1870 | if constructorDeclaration != nil { |
| 1871 | return constructorDeclaration |
| 1872 | } |
| 1873 | } |
| 1874 | if p.isIndexSignature() { |
| 1875 | return p.checkJSSyntax(p.parseIndexSignatureDeclaration(pos, jsdoc, modifiers)) |
| 1876 | } |
| 1877 | // It is very important that we check this *after* checking indexers because |
| 1878 | // the [ token can start an index signature or a computed property name |
| 1879 | if tokenIsIdentifierOrKeyword(p.token) || p.token == ast.KindStringLiteral || p.token == ast.KindNumericLiteral || p.token == ast.KindBigIntLiteral || p.token == ast.KindAsteriskToken || p.token == ast.KindOpenBracketToken { |
| 1880 | isAmbient := modifiers != nil && core.Some(modifiers.Nodes, isDeclareModifier) |
| 1881 | if isAmbient { |
| 1882 | for _, m := range modifiers.Nodes { |
| 1883 | m.Flags |= ast.NodeFlagsAmbient |
| 1884 | } |
| 1885 | saveContextFlags := p.contextFlags |
| 1886 | p.setContextFlags(ast.NodeFlagsAmbient, true) |
| 1887 | result := p.parsePropertyOrMethodDeclaration(pos, jsdoc, modifiers) |
| 1888 | p.contextFlags = saveContextFlags |
| 1889 | return result |
| 1890 | } else { |
| 1891 | return p.parsePropertyOrMethodDeclaration(pos, jsdoc, modifiers) |
| 1892 | } |
| 1893 | } |
| 1894 | if modifiers != nil { |
| 1895 | // treat this as a property declaration with a missing name. |
| 1896 | p.parseErrorAt(p.nodePos(), p.nodePos(), diagnostics.Declaration_expected) |
| 1897 | name := p.createMissingIdentifier() |
| 1898 | return p.parsePropertyDeclaration(pos, jsdoc, modifiers, name, nil /*questionToken*/) |
| 1899 | } |
| 1900 | // 'isClassMemberStart' should have hinted not to attempt parsing. |
| 1901 | panic("Should not have attempted to parse class member declaration.") |
| 1902 | } |
| 1903 | |
| 1904 | func (p *Parser) parseClassStaticBlockDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node { |
| 1905 | p.parseExpectedToken(ast.KindStaticKeyword) |
nothing calls this directly
no test coverage detected