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

Function parseObjectMethod

packages/babel-parser/src/parser/expression.ts:2273–2312  ·  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

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