@Override void apply(CompilerOptions options, boolean value) { if (value) { for (String groupName : new DiagnosticGroups().getRegisteredGroups().keySet()) { options.setWarningLevel(groupName, CheckLevel.WARNING); } } }
/** * Add all the check pass that are possibly relevant to a non googler. * * @param options The CompilerOptions object to set the options on. */ private static void addVerboseWarnings(CompilerOptions options) { addDefaultWarnings(options); // checkSuspiciousCode needs to be enabled for CheckGlobalThis to get run. options.checkSuspiciousCode = true; options.checkGlobalThisLevel = CheckLevel.WARNING; options.checkSymbols = true; options.checkMissingReturn = CheckLevel.WARNING; // checkTypes has the side-effect of asserting that the // correct number of arguments are passed to a function. // Because the CodingConvention used with the web service does not provide a // way for optional arguments to be specified, these warnings may result in // false positives. options.checkTypes = true; options.checkGlobalNamesLevel = CheckLevel.WARNING; options.aggressiveVarCheck = CheckLevel.WARNING; options.setWarningLevel(DiagnosticGroups.MISSING_PROPERTIES, CheckLevel.WARNING); options.setWarningLevel(DiagnosticGroups.DEPRECATED, CheckLevel.WARNING); }
private CompilerOptions createCompilerOptions() { CompilerOptions options = new CompilerOptions(); this.compilationLevel.setOptionsForCompilationLevel(options); if (this.debugOptions) { this.compilationLevel.setDebugOptionsForCompilationLevel(options); } options.prettyPrint = this.prettyPrint; options.printInputDelimiter = this.printInputDelimiter; options.generateExports = this.generateExports; options.setLanguageIn(this.languageIn); options.setOutputCharset(this.outputEncoding); this.warningLevel.setOptionsForWarningLevel(options); options.setManageClosureDependencies(manageDependencies); convertEntryPointParameters(options); options.setTrustedStrings(true); if (replaceProperties) { convertPropertiesMap(options); } convertDefineParameters(options); for (Warning warning : warnings) { CheckLevel level = warning.getLevel(); String groupName = warning.getGroup(); DiagnosticGroup group = new DiagnosticGroups().forName(groupName); if (group == null) { throw new BuildException("Unrecognized 'warning' option value (" + groupName + ")"); } options.setWarningLevel(group, level); } if (!Strings.isNullOrEmpty(sourceMapFormat)) { options.sourceMapFormat = Format.valueOf(sourceMapFormat); } if (sourceMapOutputFile != null) { File parentFile = sourceMapOutputFile.getParentFile(); if (parentFile.mkdirs()) { log("Created missing parent directory " + parentFile, Project.MSG_DEBUG); } options.sourceMapOutputPath = parentFile.getAbsolutePath(); } return options; }
@VisibleForTesting static CompilerOptions getCompilerOptions() { CompilerOptions options = new CompilerOptions(); DependencyOptions deps = new DependencyOptions(); deps.setDependencySorting(true); options.setDependencyOptions(deps); options.setIdeMode(true); options.setCheckSuspiciousCode(true); options.setCheckSymbols(true); options.setCheckTypes(true); options.setClosurePass(true); options.setPreserveGoogRequires(true); options.setWarningLevel(DiagnosticGroups.MISSING_REQUIRE, CheckLevel.ERROR); return options; }
/** * Minimize the output using google closure compiler. * * @param output The input file to minimize. * @throws IOException If something goes wrong. * @throws MojoFailureException If something goes wrong. */ private void minimize(final File output) throws IOException, MojoFailureException { final CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new ClosureCodingConvention()); options.setOutputCharset("UTF-8"); options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); Compiler.setLoggingLevel(Level.SEVERE); Compiler compiler = new Compiler(); compiler.disableThreads(); compiler.initOptions(options); Result result = compiler.compile( Collections.<SourceFile>emptyList(), Arrays.asList(SourceFile.fromFile(output)), options); if (result.success) { FileUtils.fileWrite(output, compiler.toSource()); } else { JSError[] errors = result.errors; throw new MojoFailureException(errors[0].toString()); } }
@Override void apply(CompilerOptions options, boolean value) { if (value) { options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING); } }
@Override void apply(CompilerOptions options, boolean value) { options.setWarningLevel( DiagnosticGroups.CHECK_USELESS_CODE, value ? CheckLevel.WARNING : CheckLevel.OFF); }
@Override void apply(CompilerOptions options, boolean value) { options.setWarningLevel( DiagnosticGroups.ES5_STRICT, value ? CheckLevel.WARNING : CheckLevel.OFF); }
@Override void apply(CompilerOptions options, boolean value) { options.setWarningLevel( DiagnosticGroups.MISSING_PROPERTIES, value ? CheckLevel.WARNING : CheckLevel.OFF); }
@Override void apply(CompilerOptions options, boolean value) { options.setWarningLevel("missingReturn", value ? CheckLevel.WARNING : CheckLevel.OFF); }