public class Launcher extends java.lang.Object implements SpoonAPI
main(String[])
) for detailed
usage.Modifier and Type | Field and Description |
---|---|
static org.apache.commons.io.filefilter.IOFileFilter |
ALL_DIR_FILTER |
protected Factory |
factory |
protected com.martiansoftware.jsap.JSAPResult |
jsapActualArgs |
static org.slf4j.Logger |
LOGGER
A default logger to be used by Spoon.
|
static java.lang.String |
OUTPUTDIR |
static org.apache.commons.io.filefilter.IOFileFilter |
RESOURCES_FILE_FILTER |
static java.lang.String |
SPOONED_CLASSES |
Modifier and Type | Method and Description |
---|---|
void |
addInputResource(SpoonResource resource)
adds a resource to be parsed to build the spoon model
|
void |
addInputResource(java.lang.String path)
Adds an input resource to be processed by Spoon (either a file or a folder).
|
<T extends CtElement> |
addProcessor(Processor<T> processor)
Adds an instance of a processor.
|
void |
addProcessor(java.lang.String name)
Adds a processor (fully qualified name).
|
void |
addTemplateResource(SpoonResource resource) |
CtModel |
buildModel()
Builds the model
|
SpoonModelBuilder |
createCompiler()
Creates a new Spoon compiler (for building the model)
|
SpoonModelBuilder |
createCompiler(Factory factory)
Creates a new Spoon Java compiler in order to process and compile Java
source code.
|
SpoonModelBuilder |
createCompiler(Factory factory,
java.util.List<SpoonResource> inputSources) |
SpoonModelBuilder |
createCompiler(Factory factory,
java.util.List<SpoonResource> inputSources,
java.util.List<SpoonResource> templateSources)
Creates a new Spoon Java compiler in order to process and compile Java
source code.
|
SpoonModelBuilder |
createCompiler(java.util.List<SpoonResource> inputSources)
Creates a new Spoon Java compiler with a default factory and a list of
input sources.
|
Environment |
createEnvironment()
Creates a new Spoon environment (may be overridden)
|
Factory |
createFactory()
Creates a new Spoon factory (may be overridden)
|
JavaOutputProcessor |
createOutputWriter() |
PrettyPrinter |
createPrettyPrinter() |
protected static com.martiansoftware.jsap.JSAP |
defineArgs()
Defines the common arguments for sub-launchers.
|
protected com.martiansoftware.jsap.JSAPResult |
getArguments()
Returns the command-line given launching arguments in JSAP format.
|
protected SpoonModelBuilder |
getCompilerInstance(Factory factory)
Instantiates the compiler.
|
Environment |
getEnvironment()
Returns the current environment.
|
Factory |
getFactory()
Returns the current factory
|
CtModel |
getModel()
Returns the model built from the sources given via
SpoonAPI.addInputResource(String) |
SpoonModelBuilder |
getModelBuilder() |
protected java.util.List<Processor<? extends CtElement>> |
getProcessors()
Gets the list of processors instance to be initially applied during the
processing.
|
protected java.util.List<java.lang.String> |
getProcessorTypes()
Gets the list of processor types to be initially applied during the
processing (-p option).
|
static void |
main(java.lang.String[] args)
A default program entry point (instantiates a launcher with the given
arguments and calls
run() ). |
protected com.martiansoftware.jsap.JSAPResult |
parseArgs()
Parses the arguments given by the command line.
|
static CtClass<?> |
parseClass(java.lang.String code)
returns the AST of an inline class
|
void |
prettyprint()
Write the transformed files to disk
|
void |
printUsage() |
void |
process()
Processes the model with the processors given previously with
SpoonAPI.addProcessor(String) |
protected void |
processArguments() |
protected void |
reportClassPathMode() |
void |
run()
Runs Spoon using the given compiler, with the given run options.
|
void |
run(java.lang.String[] args)
Runs Spoon with these arguments (used by the "main" method)
|
void |
setArgs(java.lang.String[] args2) |
void |
setBinaryOutputDirectory(java.io.File outputDirectory)
Sets the output directory for binary generated.
|
void |
setBinaryOutputDirectory(java.lang.String path)
Sets the output directory for binary generated.
|
void |
setOutputFilter(Filter<CtType<?>> typeFilter)
Applies a filter when the output-type is defined on classes.
|
void |
setOutputFilter(java.lang.String... qualifedNames)
Creates a filter from names in argument when the output-type is defined on classes.
|
void |
setSourceOutputDirectory(java.io.File outputDirectory)
Sets the output directory for source generated.
|
void |
setSourceOutputDirectory(java.lang.String path)
Sets the output directory for source generated.
|
public static final java.lang.String SPOONED_CLASSES
public static final java.lang.String OUTPUTDIR
protected Factory factory
protected com.martiansoftware.jsap.JSAPResult jsapActualArgs
public static final org.slf4j.Logger LOGGER
public static final org.apache.commons.io.filefilter.IOFileFilter RESOURCES_FILE_FILTER
public static final org.apache.commons.io.filefilter.IOFileFilter ALL_DIR_FILTER
public Launcher()
public Launcher(Factory pFactory)
pFactory
- The Factory
that will be utilized in buildModel()
.java.lang.IllegalArgumentException
- If pFactory == null
.public static void main(java.lang.String[] args)
run()
).public void run(java.lang.String[] args)
SpoonAPI
public void setArgs(java.lang.String[] args2)
public void printUsage()
public void addInputResource(java.lang.String path)
SpoonAPI
addInputResource
in interface SpoonAPI
public void addInputResource(SpoonResource resource)
public void addProcessor(java.lang.String name)
SpoonAPI
addProcessor
in interface SpoonAPI
public <T extends CtElement> void addProcessor(Processor<T> processor)
SpoonAPI
addProcessor
in interface SpoonAPI
public void addTemplateResource(SpoonResource resource)
public Environment getEnvironment()
SpoonAPI
getEnvironment
in interface SpoonAPI
protected static com.martiansoftware.jsap.JSAP defineArgs()
protected final com.martiansoftware.jsap.JSAPResult getArguments()
protected void processArguments()
protected void reportClassPathMode()
protected java.util.List<java.lang.String> getProcessorTypes()
protected java.util.List<Processor<? extends CtElement>> getProcessors()
protected com.martiansoftware.jsap.JSAPResult parseArgs()
public SpoonModelBuilder createCompiler(Factory factory)
factory
- the factory this compiler works onprotected SpoonModelBuilder getCompilerInstance(Factory factory)
createCompiler(Factory)
to retrieve
an empty compiler instance. Clients can override this method to use their custom compiler implementation.factory
- the factory to pass on to the compiler.createCompiler(Factory)
public SpoonModelBuilder createCompiler(Factory factory, java.util.List<SpoonResource> inputSources)
public SpoonModelBuilder createCompiler(Factory factory, java.util.List<SpoonResource> inputSources, java.util.List<SpoonResource> templateSources)
public SpoonModelBuilder createCompiler()
SpoonAPI
createCompiler
in interface SpoonAPI
public SpoonModelBuilder createCompiler(java.util.List<SpoonResource> inputSources)
public Factory createFactory()
SpoonAPI
createFactory
in interface SpoonAPI
public Factory getFactory()
SpoonAPI
getFactory
in interface SpoonAPI
public Environment createEnvironment()
SpoonAPI
createEnvironment
in interface SpoonAPI
public JavaOutputProcessor createOutputWriter()
public PrettyPrinter createPrettyPrinter()
public void run()
SpoonModelBuilder.build()
.SpoonModelBuilder.build()
.SpoonModelBuilder.instantiateAndProcess(List)
.OutputType.NO_OUTPUT
):
SpoonModelBuilder.generateProcessedSourceFiles(OutputType)
.public CtModel buildModel()
SpoonAPI
buildModel
in interface SpoonAPI
public void process()
SpoonAPI
SpoonAPI.addProcessor(String)
public void prettyprint()
SpoonAPI
prettyprint
in interface SpoonAPI
public SpoonModelBuilder getModelBuilder()
public void setSourceOutputDirectory(java.lang.String path)
SpoonAPI
setSourceOutputDirectory
in interface SpoonAPI
path
- Path for the output directory.public void setSourceOutputDirectory(java.io.File outputDirectory)
SpoonAPI
setSourceOutputDirectory
in interface SpoonAPI
outputDirectory
- File
for output directory.public void setOutputFilter(Filter<CtType<?>> typeFilter)
SpoonAPI
setOutputFilter
in interface SpoonAPI
typeFilter
- Filter on CtType to know which type Spoon must print.public void setOutputFilter(java.lang.String... qualifedNames)
SpoonAPI
setOutputFilter
in interface SpoonAPI
qualifedNames
- Names of class in fully qualified name to know which type Spoon must print.public void setBinaryOutputDirectory(java.lang.String path)
SpoonAPI
setBinaryOutputDirectory
in interface SpoonAPI
path
- Path for the binary output directory.public void setBinaryOutputDirectory(java.io.File outputDirectory)
SpoonAPI
setBinaryOutputDirectory
in interface SpoonAPI
outputDirectory
- File
for the binary output directory.public CtModel getModel()
SpoonAPI
SpoonAPI.addInputResource(String)
public static CtClass<?> parseClass(java.lang.String code)
Copyright © 2007–2021 Inria. All rights reserved.