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

Function parseMember

packages/babel-parser/src/parser/expression.ts:907–939  ·  view source on GitHub ↗
(
    this: Parser,
    base: N.Expression | N.Super,
    startLoc: Position,
    state: N.ParseSubscriptState,
    computed: boolean,
    optional: boolean,
  )

Source from the content-addressed store, hash-verified

905 // base[?Yield, ?Await] . PrivateIdentifier
906 // where `base` is one of CallExpression, MemberExpression and OptionalChain
907 parseMember(
908 this: Parser,
909 base: N.Expression | N.Super,
910 startLoc: Position,
911 state: N.ParseSubscriptState,
912 computed: boolean,
913 optional: boolean,
914 ): N.OptionalMemberExpression | N.MemberExpression {
915 const node = this.startNodeAt<
916 N.OptionalMemberExpression | N.MemberExpression
917 >(startLoc);
918 node.object = base;
919 node.computed = computed;
920 if (computed) {
921 node.property = this.parseExpression();
922 this.expect(tt.bracketR);
923 } else if (this.match(tt.privateName)) {
924 if (base.type === "Super") {
925 this.raise(Errors.SuperPrivateField, startLoc);
926 }
927 this.classScope.usePrivateName(this.state.value, this.state.startLoc);
928 node.property = this.parsePrivateName();
929 } else {
930 node.property = this.parseIdentifier(true);
931 }
932
933 if (state.optionalChainMember) {
934 (node as Undone<N.OptionalMemberExpression>).optional = optional;
935 return this.finishNode(node, "OptionalMemberExpression");
936 } else {
937 return this.finishNode(node, "MemberExpression");
938 }
939 }
940
941 // https://github.com/tc39/proposal-bind-operator#syntax
942 parseBind(

Callers

nothing calls this directly

Calls 5

matchMethod · 0.80
usePrivateNameMethod · 0.80
parsePrivateNameMethod · 0.80
parseIdentifierMethod · 0.80
finishNodeMethod · 0.80

Tested by

no test coverage detected