Package spoon
Class FluentLauncher
java.lang.Object
spoon.FluentLauncher
FluentLauncher provides a different, fluent interface for the launcher class.
Setting options is done via calls like
noClasspath(boolean)
. This
class exists for giving a user a simpler fluent api, which is useable for
most use cases, but not all.-
Constructor Summary
ConstructorDescriptionCreates a new FluentLauncher, wrapping defaultLauncher
.FluentLauncher(SpoonAPI launcher)
Creates a new FluentLauncher, wrapping the given launcher. -
Method Summary
Modifier and TypeMethodDescriptionautoImports(boolean autoImports)
Tell to the Java printer to automatically generate imports and use simple names instead of fully-qualified name.Builds the modelcomplianceLevel(int level)
Sets the Java version compliance level.Disable all consistency checks on the AST.Set the encoding to use for parsing source codeinputResource(Iterable<String> paths)
Adds an input resource to be processed by Spoon (either a file or a folder).inputResource(String path)
Adds an input resource to be processed by Spoon (either a file or a folder).noClasspath(boolean option)
Sets the option "noclasspath", use with caution (see explanation below).outputDirectory(File outputDirectory)
Sets the output directory for source generated.outputDirectory(String path)
Sets the output directory for source generated.<T extends CtElement>
FluentLauncherAdds an instance of a processor.<T extends CtElement>
FluentLauncherAdds an instance of a processor.sourceClassPath(String[] sourceClasspath)
Sets the source class path of the Spoon model.
-
Constructor Details
-
FluentLauncher
public FluentLauncher()Creates a new FluentLauncher, wrapping defaultLauncher
. After setting options, callbuildModel()
for creating the CtModel with given settings. -
FluentLauncher
Creates a new FluentLauncher, wrapping the given launcher. This constructor allows using different launchers eg.MavenLauncher
with fluent api. After setting options, callbuildModel()
for creating the CtModel with given settings.- Parameters:
launcher
- used for delegating methods.
-
-
Method Details
-
inputResource
Adds an input resource to be processed by Spoon (either a file or a folder). -
inputResource
Adds an input resource to be processed by Spoon (either a file or a folder). -
processor
Adds an instance of a processor. The user is responsible for keeping a pointer to it for later retrieving some processing information. -
processor
Adds an instance of a processor. The user is responsible for keeping a pointer to it for later retrieving some processing information. -
buildModel
Builds the model -
outputDirectory
Sets the output directory for source generated.- Parameters:
path
- Path for the output directory.
-
outputDirectory
Sets the output directory for source generated.- Parameters:
outputDirectory
-File
for output directory.
-
autoImports
Tell to the Java printer to automatically generate imports and use simple names instead of fully-qualified name.- Parameters:
autoImports
- toggles autoImports on or off.- Returns:
- the launcher after setting the option.
-
disableConsistencyChecks
Disable all consistency checks on the AST. Dangerous! The only valid usage of this is to keep full backward-compatibility.- Returns:
- the launcher after setting the option.
-
complianceLevel
Sets the Java version compliance level.- Parameters:
level
- of java version- Returns:
- the launcher after setting the option.
-
sourceClassPath
Sets the source class path of the Spoon model. Only .jar files or directories with *.class files are accepted. The *.jar or *.java files contained in given directories are ignored.- Parameters:
sourceClasspath
- path to sources.- Returns:
- the launcher after setting the option.
- Throws:
InvalidClassPathException
- if a given classpath does not exists or does not have the right format (.jar file or directory)
-
noClasspath
Sets the option "noclasspath", use with caution (see explanation below). With this option, Spoon does not require the full classpath to build the model. In this case, all references to classes that are not in the classpath are handled with the reference mechanism. The "simplename" of the reference object refers to the unbound identifier. This option facilitates the use of Spoon when it is hard to have the complete and correct classpath, for example for mining software repositories. For writing analyses, this option works well if you don't cross the reference by a call to getDeclaration() (if you really want to do so, then check for nullness of the result before). In normal mode, compilation errors are signaled as exception, with this option enabled they are signaled as message only. The reason is that in most cases, there are necessarily errors related to the missing classpath elements.- Returns:
- the launcher after setting the option.
-
encoding
Set the encoding to use for parsing source code- Parameters:
encoding
- used for parsing.- Returns:
- the launcher after setting the option.
-