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

Function initializeScopes

packages/babel-parser/src/parser/util.ts:355–395  ·  view source on GitHub ↗
(
    this: Parser,
    inModule: boolean = this.options.sourceType === "module",
  )

Source from the content-addressed store, hash-verified

353 }
354
355 initializeScopes(
356 this: Parser,
357 inModule: boolean = this.options.sourceType === "module",
358 ): () => void {
359 // Initialize state
360 const oldLabels = this.state.labels;
361 this.state.labels = [];
362
363 const oldExportedIdentifiers = this.exportedIdentifiers;
364 this.exportedIdentifiers = new Set();
365
366 // initialize scopes
367 const oldInModule = this.inModule;
368 this.inModule = inModule;
369
370 const oldScope = this.scope;
371 const ScopeHandler = this.getScopeHandler();
372 this.scope = new ScopeHandler(this, inModule);
373
374 const oldProdParam = this.prodParam;
375 this.prodParam = new ProductionParameterHandler();
376
377 const oldClassScope = this.classScope;
378 this.classScope = new ClassScopeHandler(this);
379
380 const oldExpressionScope = this.expressionScope;
381 this.expressionScope = new ExpressionScopeHandler(this);
382
383 return () => {
384 // Revert state
385 this.state.labels = oldLabels;
386 this.exportedIdentifiers = oldExportedIdentifiers;
387
388 // Revert scopes
389 this.inModule = oldInModule;
390 this.scope = oldScope;
391 this.prodParam = oldProdParam;
392 this.classScope = oldClassScope;
393 this.expressionScope = oldExpressionScope;
394 };
395 }
396
397 enterInitialScopes() {
398 let paramFlags = ParamKind.PARAM;

Callers

nothing calls this directly

Calls 1

getScopeHandlerMethod · 0.45

Tested by

no test coverage detected