use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class TypeCheckNoTranspileTest method testClosureTypesMultipleWarnings.
private void testClosureTypesMultipleWarnings(String js, List<String> descriptions) {
compiler.initOptions(compiler.getOptions());
Node n = compiler.parseTestCode(js);
Node externs = IR.root();
IR.root(externs, n);
assertEquals("parsing error: " + Joiner.on(", ").join(compiler.getErrors()), 0, compiler.getErrorCount());
// For processing goog.addDependency for forward typedefs.
new ProcessClosurePrimitives(compiler, null, CheckLevel.ERROR, false).process(externs, n);
new TypeCheck(compiler, new ClosureReverseAbstractInterpreter(registry).append(new SemanticReverseAbstractInterpreter(registry)).getFirst(), registry).processForTesting(null, n);
assertEquals("unexpected error(s) : " + Joiner.on(", ").join(compiler.getErrors()), 0, compiler.getErrorCount());
if (descriptions == null) {
assertEquals("unexpected warning(s) : " + Joiner.on(", ").join(compiler.getWarnings()), 0, compiler.getWarningCount());
} else {
assertEquals("unexpected warning(s) : " + Joiner.on(", ").join(compiler.getWarnings()), descriptions.size(), compiler.getWarningCount());
Set<String> actualWarningDescriptions = new HashSet<>();
for (int i = 0; i < descriptions.size(); i++) {
actualWarningDescriptions.add(compiler.getWarnings()[i].description);
}
assertEquals(new HashSet<>(descriptions), actualWarningDescriptions);
}
}
use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class TypeCheckTest method testClosureTypesMultipleWarnings.
private void testClosureTypesMultipleWarnings(String js, List<String> descriptions) {
compiler.initOptions(compiler.getOptions());
Node jsRoot = IR.root(compiler.parseTestCode(js));
Node externs = IR.root(compiler.parseTestCode(new TestExternsBuilder().addString().addClosureExterns().addExtra(CLOSURE_DEFS).build()));
IR.root(externs, jsRoot);
assertWithMessage("parsing error: " + Joiner.on(", ").join(compiler.getErrors())).that(compiler.getErrorCount()).isEqualTo(0);
new GatherModuleMetadata(compiler, false, ResolutionMode.BROWSER).process(externs, jsRoot);
// For processing goog.forwardDeclare for forward typedefs.
new ProcessClosurePrimitives(compiler).process(externs, jsRoot);
new TypeCheck(compiler, new ClosureReverseAbstractInterpreter(registry).append(new SemanticReverseAbstractInterpreter(registry)).getFirst(), registry).processForTesting(externs, jsRoot);
assertWithMessage("unexpected error(s) : " + Joiner.on(", ").join(compiler.getErrors())).that(compiler.getErrorCount()).isEqualTo(0);
if (descriptions == null) {
assertWithMessage("unexpected warning(s) : " + Joiner.on(", ").join(compiler.getWarnings())).that(compiler.getWarningCount()).isEqualTo(0);
} else {
assertWithMessage("unexpected warning(s) : " + Joiner.on(", ").join(compiler.getWarnings())).that(compiler.getWarningCount()).isEqualTo(descriptions.size());
Set<String> actualWarningDescriptions = new HashSet<>();
for (int i = 0; i < descriptions.size(); i++) {
actualWarningDescriptions.add(compiler.getWarnings().get(i).getDescription());
}
assertThat(actualWarningDescriptions).isEqualTo(new HashSet<>(descriptions));
}
}
use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class Compiler method getReverseAbstractInterpreter.
@Override
public ReverseAbstractInterpreter getReverseAbstractInterpreter() {
if (abstractInterpreter == null) {
ChainableReverseAbstractInterpreter interpreter = new SemanticReverseAbstractInterpreter(getTypeRegistry());
if (options.closurePass) {
interpreter = new ClosureReverseAbstractInterpreter(getTypeRegistry()).append(interpreter).getFirst();
}
abstractInterpreter = interpreter;
}
return abstractInterpreter;
}
use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class ExpressionDecomposerTest method processForTypecheck.
private void processForTypecheck(AbstractCompiler compiler, Node jsRoot) {
Node root = IR.root(IR.root(), IR.root(jsRoot));
JSTypeRegistry registry = compiler.getTypeRegistry();
(new TypeCheck(compiler, new SemanticReverseAbstractInterpreter(registry), registry)).processForTesting(root.getFirstChild(), root.getSecondChild());
compiler.setTypeCheckingHasRun(true);
}
use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class SemanticReverseAbstractInterpreterTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
interpreter = new SemanticReverseAbstractInterpreter(registry);
}
Aggregations