Search in sources :

Example 11 with SymbolScope

use of com.google.javascript.jscomp.SymbolTable.SymbolScope in project closure-compiler by google.

the class SymbolTableTest method testLocalVarInExterns.

@Test
public void testLocalVarInExterns() {
    SymbolTable table = createSymbolTable("", "function customExternFn(customExternArg) {}");
    Symbol arg = getLocalVar(table, "customExternArg");
    List<Reference> refs = table.getReferenceList(arg);
    assertThat(refs).hasSize(1);
    Symbol fn = getGlobalVar(table, "customExternFn");
    SymbolScope scope = table.getEnclosingScope(refs.get(0).getNode());
    assertThat(scope.isGlobalScope()).isFalse();
    assertThat(table.getSymbolForScope(scope)).isEqualTo(fn);
}
Also used : Symbol(com.google.javascript.jscomp.SymbolTable.Symbol) Reference(com.google.javascript.jscomp.SymbolTable.Reference) SymbolScope(com.google.javascript.jscomp.SymbolTable.SymbolScope) Test(org.junit.Test)

Aggregations

Symbol (com.google.javascript.jscomp.SymbolTable.Symbol)11 SymbolScope (com.google.javascript.jscomp.SymbolTable.SymbolScope)11 Test (org.junit.Test)11 Node (com.google.javascript.rhino.Node)4 NodeSubject.assertNode (com.google.javascript.rhino.testing.NodeSubject.assertNode)4 Reference (com.google.javascript.jscomp.SymbolTable.Reference)2 EqualsTester (com.google.common.testing.EqualsTester)1