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

Function parseClassStaticBlock

packages/babel-parser/src/parser/statement.ts:1998–2026  ·  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

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