@Override protected CompilerOptions getOptions() { CompilerOptions options = super.getOptions(); options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.ERROR); options.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY, CheckLevel.ERROR); return options; }
/** * Gets the compiler options to use for this test. Use getProcessor to determine what passes * should be run. */ protected CompilerOptions getOptions(CompilerOptions options) { options.setLanguageIn(acceptedLanguage); // This doesn't affect whether checkSymbols is run--it just affects // whether variable warnings are filtered. options.checkSymbols = true; options.setWarningLevel(DiagnosticGroups.MISSING_PROPERTIES, CheckLevel.WARNING); options.setWarningLevel(DiagnosticGroups.INVALID_CASTS, CheckLevel.WARNING); options.setCodingConvention(getCodingConvention()); return options; }
@Override protected CompilerOptions getOptions() { CompilerOptions options = super.getOptions(); options.setWarningLevel(DiagnosticGroups.MISSING_PROPERTIES, CheckLevel.OFF); options.setCodingConvention(getCodingConvention()); return options; }
private final void parseAndTypeCheck(String externs, String js) { setUp(); final CompilerOptions options = compiler.getOptions(); options.setClosurePass(true); options.setNewTypeInference(true); options.setWarningLevel(DiagnosticGroups.NEW_CHECK_TYPES_ALL_CHECKS, CheckLevel.WARNING); compiler.init( ImmutableList.of(SourceFile.fromCode("[externs]", externs)), ImmutableList.of(SourceFile.fromCode("[testcode]", js)), options); Node externsRoot = IR.block(); externsRoot.setIsSyntheticBlock(true); externsRoot.addChildToFront(compiler.getInput(new InputId("[externs]")).getAstRoot(compiler)); Node astRoot = IR.block(); astRoot.setIsSyntheticBlock(true); astRoot.addChildToFront(compiler.getInput(new InputId("[testcode]")).getAstRoot(compiler)); assertEquals( "parsing error: " + Joiner.on(", ").join(compiler.getErrors()), 0, compiler.getErrorCount()); assertEquals( "parsing warning: " + Joiner.on(", ").join(compiler.getWarnings()), 0, compiler.getWarningCount()); // Create common parent of externs and ast; needed by Es6RewriteBlockScopedDeclaration. Node block = IR.block(externsRoot, astRoot); block.setIsSyntheticBlock(true); // Run ASTValidator (new AstValidator(compiler)).validateRoot(block); DeclaredGlobalExternsOnWindow rewriteExterns = new DeclaredGlobalExternsOnWindow(compiler); passes.add(makePassFactory("globalExternsOnWindow", rewriteExterns)); ProcessClosurePrimitives closurePass = new ProcessClosurePrimitives(compiler, null, CheckLevel.ERROR, false); passes.add(makePassFactory("ProcessClosurePrimitives", closurePass)); if (options.getLanguageIn() == CompilerOptions.LanguageMode.ECMASCRIPT6_TYPED) { passes.add(makePassFactory("convertEs6TypedToEs6", new Es6TypedToEs6Converter(compiler))); } if (options.getLanguageIn().isEs6OrHigher()) { passes.add( makePassFactory( "Es6RenameVariablesInParamLists", new Es6RenameVariablesInParamLists(compiler))); passes.add( makePassFactory( "Es6SplitVariableDeclarations", new Es6SplitVariableDeclarations(compiler))); passes.add(makePassFactory("es6ConvertSuper", new Es6ConvertSuper(compiler))); passes.add(makePassFactory("convertEs6", new Es6ToEs3Converter(compiler))); passes.add( makePassFactory( "Es6RewriteBlockScopedDeclaration", new Es6RewriteBlockScopedDeclaration(compiler))); passes.add(makePassFactory("rewriteGenerators", new Es6RewriteGenerators(compiler))); passes.add(makePassFactory("Es6RuntimeLibrary", new InjectEs6RuntimeLibrary(compiler))); passes.add( makePassFactory("Es6StaticInheritance", new Es6ToEs3ClassSideInheritance(compiler))); } passes.add(makePassFactory("GlobalTypeInfo", compiler.getSymbolTable())); passes.add(makePassFactory("NewTypeInference", new NewTypeInference(compiler))); PhaseOptimizer phaseopt = new PhaseOptimizer(compiler, null, null); phaseopt.consume(passes); phaseopt.process(externsRoot, astRoot); }
/** Adds warning levels by name. */ void setWarningLevel(CompilerOptions options, String name, CheckLevel level) { DiagnosticGroup group = forName(name); Preconditions.checkNotNull(group, "No warning class for name: %s", name); options.setWarningLevel(group, level); }