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

Function parseObjectMethod

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

2161
2162 // https://tc39.es/ecma262/#prod-MethodDefinition
2163 parseObjectMethod(
2164 this: Parser,
2165 prop: Undone<N.ObjectMethod>,
2166 isGenerator: boolean,
2167 isAsync: boolean,
2168 isPattern: boolean,
2169 isAccessor: boolean,
2170 ): N.ObjectMethod | undefined | null {
2171 if (isAccessor) {
2172 // isAccessor implies isAsync: false, isPattern: false, isGenerator: false
2173 const finishedProp = this.parseMethod(
2174 prop,
2175 // This _should_ be false, but with error recovery, we allow it to be
2176 // set for informational purposes
2177 isGenerator,
2178 /* isAsync */ false,
2179 /* isConstructor */ false,
2180 false,
2181 "ObjectMethod",
2182 );
2183 this.checkGetterSetterParams(finishedProp);
2184 return finishedProp;
2185 }
2186
2187 if (isAsync || isGenerator || this.match(tt.parenL)) {
2188 if (isPattern) this.unexpected();
2189 prop.kind = "method";
2190 // @ts-expect-error todo: Undocumented property for ESTree compatibility.
2191 // Consider move to the ESTree plugin
2192 prop.method = true;
2193 return this.parseMethod(
2194 prop,
2195 isGenerator,
2196 isAsync,
2197 /* isConstructor */ false,
2198 false,
2199 "ObjectMethod",
2200 );
2201 }
2202 }
2203
2204 // if `isPattern` is true, parse https://tc39.es/ecma262/#prod-BindingProperty
2205 // 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