All files / transpiler/types/symbols IScopeSymbol.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                                                                                                             
import type IBaseSymbol from "./IBaseSymbol";
import type IFunctionSymbol from "./IFunctionSymbol";
import type TVisibility from "../TVisibility";
 
/**
 * Symbol representing a scope (namespace) definition.
 * Scopes group related functions and variables.
 *
 * Note: IScopeSymbol has circular references with IFunctionSymbol.
 * Functions have a scope, scopes contain functions.
 */
interface IScopeSymbol extends IBaseSymbol {
  /** Discriminator narrowed to "scope" */
  readonly kind: "scope";
 
  /** Parent scope (global scope's parent is itself) */
  readonly parent: IScopeSymbol;
 
  /** List of member names (local names, not transpiled C names) */
  readonly members: string[];
 
  /** Functions in this scope */
  readonly functions: IFunctionSymbol[];
 
  /** Variables in this scope */
  readonly variables: unknown[];
 
  /** Visibility of each member */
  readonly memberVisibility: ReadonlyMap<string, TVisibility>;
 
  /**
   * Every block that declares this scope, as `${sourceFile}:${sourceLine}`.
   *
   * #1334: a scope may be REOPENED (ADR-016), so it has many declaration sites,
   * not one. `SymbolRegistry.getOrCreateScope` caches by path and `ScopeCollector`
   * used to overwrite `sourceFile`/`sourceLine` on the shared object, so a
   * reopened scope reported whichever block was collected LAST -- and a conflict
   * naming two definitions printed the same location twice, because there was
   * only ever one position.
   *
   * A `Set<string>` rather than a set of `{sourceFile, sourceLine}` objects: `Set`
   * deduplicates objects by reference, so two literals with identical contents
   * would both be retained -- it would look like deduplication and silently not
   * be. The string is also exactly the display format conflict messages already
   * build, so it is rendered directly and never split back apart.
   *
   * The scalar `sourceFile`/`sourceLine` inherited from IBaseSymbol carry the
   * FIRST site. That is not a lossy choice now, because the complete record is
   * here beside them.
   */
  readonly declarationSites: ReadonlySet<string>;
}
 
export default IScopeSymbol;