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

Function parseClassStaticBlock

packages/babel-parser/src/parser/statement.ts:1995–2023  ·  view source on GitHub ↗
(
    this: Parser,
    classBody: Undone<N.ClassBody>,
    member: Undone<
      N.StaticBlock & {
        decorators?: N.Decorator[];
      }
    >,
  )

Source from the content-addressed store, hash-verified

1993 }
1994
1995 parseClassStaticBlock(
1996 this: Parser,
1997 classBody: Undone<N.ClassBody>,
1998 member: Undone<
1999 N.StaticBlock & {
2000 decorators?: N.Decorator[];
2001 }
2002 >,
2003 ) {
2004 // Start a new lexical scope
2005 this.scope.enter(
2006 ScopeFlag.CLASS | ScopeFlag.STATIC_BLOCK | ScopeFlag.SUPER,
2007 );
2008 // Start a new scope with regard to loop labels
2009 const oldLabels = this.state.labels;
2010 this.state.labels = [];
2011 // ClassStaticBlockStatementList:
2012 // StatementList[~Yield, ~Await, ~Return] opt
2013 this.prodParam.enter(ParamKind.PARAM);
2014 const body: N.Statement[] = (member.body = []);
2015 this.parseBlockOrModuleBlockBody(body, undefined, false, tt.braceR);
2016 this.prodParam.exit();
2017 this.scope.exit();
2018 this.state.labels = oldLabels;
2019 classBody.body.push(this.finishNode<N.StaticBlock>(member, "StaticBlock"));
2020 if (member.decorators?.length) {
2021 this.raise(Errors.DecoratorStaticBlock, member);
2022 }
2023 }
2024
2025 pushClassProperty(
2026 this: Parser,

Callers

nothing calls this directly

Calls 4

finishNodeMethod · 0.80
enterMethod · 0.45
exitMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected