(
this: Parser,
hadSuperClass: boolean,
oldStrict: boolean,
)
| 1656 | |
| 1657 | // https://tc39.es/ecma262/#prod-ClassBody |
| 1658 | parseClassBody( |
| 1659 | this: Parser, |
| 1660 | hadSuperClass: boolean, |
| 1661 | oldStrict: boolean, |
| 1662 | ): N.ClassBody { |
| 1663 | this.classScope.enter(); |
| 1664 | |
| 1665 | const state: N.ParseClassMemberState = { |
| 1666 | hadConstructor: false, |
| 1667 | hadSuperClass, |
| 1668 | }; |
| 1669 | let decorators: N.Decorator[] = []; |
| 1670 | const classBody = this.startNode<N.ClassBody>(); |
| 1671 | classBody.body = []; |
| 1672 | |
| 1673 | this.expect(tt.braceL); |
| 1674 | |
| 1675 | // Parse the contents within the braces. |
| 1676 | while (!this.match(tt.braceR)) { |
| 1677 | if (this.eat(tt.semi)) { |
| 1678 | if (decorators.length > 0) { |
| 1679 | throw this.raise( |
| 1680 | Errors.DecoratorSemicolon, |
| 1681 | this.state.lastTokEndLoc!, |
| 1682 | ); |
| 1683 | } |
| 1684 | continue; |
| 1685 | } |
| 1686 | |
| 1687 | if (this.match(tt.at)) { |
| 1688 | decorators.push(this.parseDecorator()); |
| 1689 | continue; |
| 1690 | } |
| 1691 | |
| 1692 | const member = this.startNode<N.ClassMember>(); |
| 1693 | |
| 1694 | // steal the decorators if there are any |
| 1695 | if (decorators.length) { |
| 1696 | member.decorators = decorators; |
| 1697 | this.resetStartLocationFromNode(member, decorators[0]); |
| 1698 | decorators = []; |
| 1699 | } |
| 1700 | |
| 1701 | this.parseClassMember(classBody, member, state); |
| 1702 | } |
| 1703 | |
| 1704 | this.state.strict = oldStrict; |
| 1705 | |
| 1706 | this.next(); // eat `}` |
| 1707 | |
| 1708 | if (decorators.length) { |
| 1709 | throw this.raise(Errors.TrailingDecorator, this.state.startLoc); |
| 1710 | } |
| 1711 | |
| 1712 | this.classScope.exit(); |
| 1713 | |
| 1714 | return this.finishNode(classBody, "ClassBody"); |
| 1715 | } |
nothing calls this directly
no test coverage detected