Class SymbolTable

java.lang.Object
com.google.javascript.jscomp.SymbolTable
All Implemented Interfaces:
StaticSymbolTable<SymbolTable.Symbol,SymbolTable.Reference>

public final class SymbolTable extends Object implements StaticSymbolTable<SymbolTable.Symbol,SymbolTable.Reference>
A symbol table for people that want to use Closure Compiler as an indexer. Contains an index of all the symbols in the code within a compilation job. The API is designed for people who want to visit all the symbols, rather than people who want to lookup a specific symbol by a certain key. We can use this to combine different types of symbol tables. For example, one class might have a StaticSymbolTable of all variable references, and another class might have a StaticSymbolTable of all type names in JSDoc comments. This class allows you to combine them into a unified index. Most passes build their own "partial" symbol table that implements the same interface (StaticSymbolTable, StaticSlot, and friends). Individual compiler passes usually need more or less metadata about the certainty of symbol information. Building a complete symbol table with all the necessary metadata for all passes would be too slow. However, as long as these "partial" symbol tables implement the proper interfaces, we should be able to add them to this symbol table to make it more complete. If clients want fast lookup, they should build their own wrapper around this symbol table that indexes symbols or references by the desired lookup key. By design, when this symbol table creates symbols for types, it tries to mimic the symbol table you would get in an OO language. For example, the "type Foo" and "the constructor that creates objects of type Foo" are the same symbol. The types of "Foo.prototype" and "new Foo()" also have the same symbol. Although JSCompiler internally treats these as distinct symbols, we assume that most clients will not care about the distinction.
See Also:
  • For more information on how to write plugins for this symbol table.
  • Field Details

    • GLOBAL_THIS

      public static final String GLOBAL_THIS
      The name we use for the JavaScript built-in Global object. It's anonymous in JavaScript, so we have to give it an invalid identifier to avoid conflicts with user-defined property names.
      See Also:
  • Method Details