@GwtIncompatible(value="Unnecessary") public abstract class AbstractCommandLineRunner<A extends Compiler,B extends CompilerOptions> extends Object
class MyCommandLineRunner extends AbstractCommandLineRunner<MyCompiler, MyOptions> { MyCommandLineRunner(String[] args) { super(args); } @Override protected MyOptions createOptions() { MyOptions options = new MyOptions(); CompilerFlagTranslator.setOptionsFromFlags(options); addMyCrazyCompilerPassThatOutputsAnExtraFile(options); return options; } @Override protected MyCompiler createCompiler() { return new MyCompiler(); } public static void main(String[] args) { (new MyCommandLineRunner(args)).run(); } }
Modifier and Type | Class and Description |
---|---|
static class |
AbstractCommandLineRunner.FlagUsageException
An exception thrown when command-line flags are used incorrectly.
|
protected static class |
AbstractCommandLineRunner.WarningGuardSpec
A little helper class to make it easier to collect warning types
from --jscomp_error, --jscomp_warning, and --jscomp_off.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addWhitelistWarningsGuard(CompilerOptions options,
File whitelistFile) |
protected void |
checkModuleName(String name)
Validates the module name.
|
protected abstract A |
createCompiler()
Returns the instance of the Compiler to use when
run() is
called. |
protected List<SourceFile> |
createExterns(CompilerOptions options) |
protected List<SourceFile> |
createInputs(List<String> files,
boolean allowStdIn)
Creates inputs from a list of files.
|
protected List<SourceFile> |
createInputs(List<String> files,
List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> jsonFiles)
Creates inputs from a list of source files and json files.
|
protected List<SourceFile> |
createInputs(List<String> files,
List<String> zips,
boolean allowStdIn)
Creates inputs from a list of source files and zips.
|
protected List<SourceFile> |
createInputs(List<String> files,
List<String> zips,
List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> jsonFiles,
boolean allowStdIn)
Creates inputs from a list of source files, zips and json files.
|
protected abstract B |
createOptions()
Returns the instance of the Options to use when
run() is called. |
protected int |
doRun()
Parses command-line arguments and runs the compiler.
|
protected OutputStream |
filenameToOutputStream(String fileName)
Converts a file name into a Outputstream.
|
static List<SourceFile> |
getBuiltinExterns(CompilerOptions options) |
protected com.google.javascript.jscomp.AbstractCommandLineRunner.CommandLineConfig |
getCommandLineConfig()
Get the command line config, so that it can be initialized.
|
protected A |
getCompiler() |
protected DiagnosticGroups |
getDiagnosticGroups()
The warning classes that are available from the command-line.
|
protected PrintStream |
getErrorPrintStream()
Returns the PrintStream for writing errors associated with this
AbstractCommandLineRunner.
|
protected boolean |
isInTestMode()
Returns whether we're in test mode.
|
List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> |
parseJsonFilesFromInputStream() |
void |
run()
Runs the Compiler and calls System.exit() with the exit status of the
compiler.
|
protected void |
setRunOptions(CompilerOptions options)
Sets options based on the configurations set flags API.
|
protected boolean isInTestMode()
protected com.google.javascript.jscomp.AbstractCommandLineRunner.CommandLineConfig getCommandLineConfig()
protected abstract A createCompiler()
run()
is
called.protected abstract B createOptions()
run()
is called.
createCompiler() is called before createOptions(), so getCompiler()
will not return null when createOptions() is called.protected DiagnosticGroups getDiagnosticGroups()
protected abstract void addWhitelistWarningsGuard(CompilerOptions options, File whitelistFile)
protected void setRunOptions(CompilerOptions options) throws AbstractCommandLineRunner.FlagUsageException, IOException
protected final A getCompiler()
public static List<SourceFile> getBuiltinExterns(CompilerOptions options) throws IOException
IOException
public final void run()
protected PrintStream getErrorPrintStream()
public List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> parseJsonFilesFromInputStream() throws IOException
IOException
protected List<SourceFile> createInputs(List<String> files, boolean allowStdIn) throws AbstractCommandLineRunner.FlagUsageException, IOException
files
- A list of filenamesallowStdIn
- Whether '-' is allowed appear as a filename to represent
stdin. If true, '-' is only allowed to appear once.AbstractCommandLineRunner.FlagUsageException
IOException
protected List<SourceFile> createInputs(List<String> files, List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> jsonFiles) throws AbstractCommandLineRunner.FlagUsageException, IOException
files
- A list of filenames.jsonFiles
- A list of json encoded files.AbstractCommandLineRunner.FlagUsageException
IOException
protected List<SourceFile> createInputs(List<String> files, List<String> zips, boolean allowStdIn) throws AbstractCommandLineRunner.FlagUsageException, IOException
files
- A list of filenames.zips
- A list of zip filenames.allowStdIn
- Whether '-' is allowed appear as a filename to represent
stdin. If true, '-' is only allowed to appear once.AbstractCommandLineRunner.FlagUsageException
IOException
protected List<SourceFile> createInputs(List<String> files, List<String> zips, List<com.google.javascript.jscomp.AbstractCommandLineRunner.JsonFileSpec> jsonFiles, boolean allowStdIn) throws AbstractCommandLineRunner.FlagUsageException, IOException
files
- A list of filenames.zips
- A list of zip filenames.jsonFiles
- A list of json encoded files.allowStdIn
- Whether '-' is allowed appear as a filename to represent
stdin. If true, '-' is only allowed to appear once.AbstractCommandLineRunner.FlagUsageException
IOException
protected void checkModuleName(String name) throws AbstractCommandLineRunner.FlagUsageException
name
- The module nameAbstractCommandLineRunner.FlagUsageException
- if the validation failsprotected int doRun() throws AbstractCommandLineRunner.FlagUsageException, IOException
AbstractCommandLineRunner.FlagUsageException
IOException
protected List<SourceFile> createExterns(CompilerOptions options) throws AbstractCommandLineRunner.FlagUsageException, IOException
protected OutputStream filenameToOutputStream(String fileName) throws IOException
IOException
Copyright © 2009-2015 Google. All Rights Reserved.