use of com.google.javascript.jscomp.SymbolTable.Symbol in project closure-compiler by google.
the class SymbolTableTest method testJSDocAssociationWithBadNamespace.
@Test
public void testJSDocAssociationWithBadNamespace() {
SymbolTable table = createSymbolTable(// about goog.Foo.
"/** @constructor */ goog.Foo = function(){};");
Symbol foo = getGlobalVar(table, "goog.Foo");
assertThat(foo).isNotNull();
JSDocInfo info = foo.getJSDocInfo();
assertThat(info).isNotNull();
assertThat(info.isConstructor()).isTrue();
}
use of com.google.javascript.jscomp.SymbolTable.Symbol in project closure-compiler by google.
the class SymbolTableTest method testGetEnclosingFunctionScope_FunctionNoNestedScopes.
@Test
public void testGetEnclosingFunctionScope_FunctionNoNestedScopes() {
SymbolTable table = createSymbolTable("function foo() { const baz = 1; }");
Symbol baz = getLocalVar(table, "baz");
SymbolScope bazFunctionScope = table.getEnclosingFunctionScope(baz.getDeclarationNode());
assertThat(bazFunctionScope).isNotNull();
Node foo = getGlobalVar(table, "foo").getDeclarationNode().getParent();
assertThat(bazFunctionScope.getRootNode()).isEqualTo(foo);
}
use of com.google.javascript.jscomp.SymbolTable.Symbol in project closure-compiler by google.
the class SymbolTableTest method testObjectLiteralWithNewlineInKey.
public void testObjectLiteralWithNewlineInKey() throws Exception {
SymbolTable table = createSymbolTable("var obj = {'foo\\nbar': 0};");
Symbol foo = getGlobalVar(table, "obj.foo\\nbar");
assertThat(foo.getName()).isEqualTo("obj.foo\\nbar");
}
use of com.google.javascript.jscomp.SymbolTable.Symbol in project closure-compiler by google.
the class SymbolTableTest method testObjectLiteralQuoted.
public void testObjectLiteralQuoted() throws Exception {
SymbolTable table = createSymbolTable("var obj = {'foo': 0};");
Symbol foo = getGlobalVar(table, "obj.foo");
assertThat(foo.getName()).isEqualTo("foo");
}
use of com.google.javascript.jscomp.SymbolTable.Symbol in project closure-compiler by google.
the class SymbolTableTest method testGlobalThisPropertyReferences.
@Test
public void testGlobalThisPropertyReferences() {
SymbolTable table = createSymbolTable("/** @constructor */ function Foo() {} this.Foo;");
Symbol foo = getGlobalVar(table, "Foo");
assertThat(foo).isNotNull();
List<Reference> refs = table.getReferenceList(foo);
assertThat(refs).hasSize(2);
}
Aggregations