(hasConstructor)
| 3163 | // https://tc39.github.io/ecma262/#sec-class-definitions |
| 3164 | |
| 3165 | parseClassElement(hasConstructor): Node.Property { |
| 3166 | let token = this.lookahead; |
| 3167 | const node = this.createNode(); |
| 3168 | |
| 3169 | let kind: string = ''; |
| 3170 | let key: Node.PropertyKey | null = null; |
| 3171 | let value: Node.FunctionExpression | null = null; |
| 3172 | let computed = false; |
| 3173 | let method = false; |
| 3174 | let isStatic = false; |
| 3175 | let isAsync = false; |
| 3176 | |
| 3177 | if (this.match('*')) { |
| 3178 | this.nextToken(); |
| 3179 | } else { |
| 3180 | computed = this.match('['); |
| 3181 | key = this.parseObjectPropertyKey(); |
| 3182 | const id = key as Node.Identifier; |
| 3183 | if (id.name === 'static' && (this.qualifiedPropertyName(this.lookahead) || this.match('*'))) { |
| 3184 | token = this.lookahead; |
| 3185 | isStatic = true; |
| 3186 | computed = this.match('['); |
| 3187 | if (this.match('*')) { |
| 3188 | this.nextToken(); |
| 3189 | } else { |
| 3190 | key = this.parseObjectPropertyKey(); |
| 3191 | } |
| 3192 | } |
| 3193 | if ((token.type === Token.Identifier) && !this.hasLineTerminator && (token.value === 'async')) { |
| 3194 | const punctuator = this.lookahead.value; |
| 3195 | if (punctuator !== ':' && punctuator !== '(' && punctuator !== '*') { |
| 3196 | isAsync = true; |
| 3197 | token = this.lookahead; |
| 3198 | key = this.parseObjectPropertyKey(); |
| 3199 | if (token.type === Token.Identifier && token.value === 'constructor') { |
| 3200 | this.tolerateUnexpectedToken(token, Messages.ConstructorIsAsync); |
| 3201 | } |
| 3202 | } |
| 3203 | } |
| 3204 | } |
| 3205 | |
| 3206 | const lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead); |
| 3207 | if (token.type === Token.Identifier) { |
| 3208 | if (token.value === 'get' && lookaheadPropertyKey) { |
| 3209 | kind = 'get'; |
| 3210 | computed = this.match('['); |
| 3211 | key = this.parseObjectPropertyKey(); |
| 3212 | this.context.allowYield = false; |
| 3213 | value = this.parseGetterMethod(); |
| 3214 | } else if (token.value === 'set' && lookaheadPropertyKey) { |
| 3215 | kind = 'set'; |
| 3216 | computed = this.match('['); |
| 3217 | key = this.parseObjectPropertyKey(); |
| 3218 | value = this.parseSetterMethod(); |
| 3219 | } |
| 3220 | } else if (token.type === Token.Punctuator && token.value === '*' && lookaheadPropertyKey) { |
| 3221 | kind = 'init'; |
| 3222 | computed = this.match('['); |
no test coverage detected