MCPcopy Create free account
hub / github.com/babel/babel / parseObjectMethod

Function parseObjectMethod

packages/babel-parser/src/parser/expression.ts:2272–2311  ·  view source on GitHub ↗
(
    this: Parser,
    prop: Undone<N.ObjectMethod>,
    isGenerator: boolean,
    isAsync: boolean,
    isPattern: boolean,
    isAccessor: boolean,
  )

Source from the content-addressed store, hash-verified

2270
2271 // https://tc39.es/ecma262/#prod-MethodDefinition
2272 parseObjectMethod(
2273 this: Parser,
2274 prop: Undone<N.ObjectMethod>,
2275 isGenerator: boolean,
2276 isAsync: boolean,
2277 isPattern: boolean,
2278 isAccessor: boolean,
2279 ): N.ObjectMethod | undefined | null {
2280 if (isAccessor) {
2281 // isAccessor implies isAsync: false, isPattern: false, isGenerator: false
2282 const finishedProp = this.parseMethod(
2283 prop,
2284 // This _should_ be false, but with error recovery, we allow it to be
2285 // set for informational purposes
2286 isGenerator,
2287 /* isAsync */ false,
2288 /* isConstructor */ false,
2289 false,
2290 "ObjectMethod",
2291 );
2292 this.checkGetterSetterParams(finishedProp);
2293 return finishedProp;
2294 }
2295
2296 if (isAsync || isGenerator || this.match(tt.parenL)) {
2297 if (isPattern) this.unexpected();
2298 prop.kind = "method";
2299 // @ts-expect-error todo: Undocumented property for ESTree compatibility.
2300 // Consider move to the ESTree plugin
2301 prop.method = true;
2302 return this.parseMethod(
2303 prop,
2304 isGenerator,
2305 isAsync,
2306 /* isConstructor */ false,
2307 false,
2308 "ObjectMethod",
2309 );
2310 }
2311 }
2312
2313 // if `isPattern` is true, parse https://tc39.es/ecma262/#prod-BindingProperty
2314 // else https://tc39.es/ecma262/#prod-PropertyDefinition

Callers

nothing calls this directly

Calls 3

matchMethod · 0.80
parseMethodMethod · 0.45

Tested by

no test coverage detected