Skip to content

Commit

Permalink
refactor: JDTBatchCompiler arg.sources not needed (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvojtechovsky authored and monperrus committed Nov 11, 2016
1 parent a9da3fc commit ee2ca24
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ protected CompilationUnitDeclaration[] buildUnits(JDTBuilder jdtBuilder, SpoonFo
.classpathOptions(new ClasspathOptions().encoding(this.encoding).classpath(classpath)) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
.sources(new SourceOptions().sources(sourceFiles)) //
.sources(new SourceOptions().sources()) // no sources, handled by the JDTBatchCompiler
.build();
} else {
args = jdtBuilder.build();
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/spoon/support/compiler/jdt/JDTSnippetCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
import spoon.SpoonException;
import spoon.compiler.Environment;
import spoon.compiler.SpoonFile;
import spoon.compiler.builder.AdvancedOptions;
import spoon.compiler.builder.ClasspathOptions;
import spoon.compiler.builder.ComplianceOptions;
import spoon.compiler.builder.JDTBuilder;
import spoon.compiler.builder.JDTBuilderImpl;
import spoon.compiler.builder.SourceOptions;
import spoon.reflect.cu.CompilationUnit;
import spoon.reflect.factory.Factory;
import spoon.support.compiler.SnippetCompilationError;
Expand Down Expand Up @@ -80,19 +75,6 @@ public boolean build(JDTBuilder builder) {

@Override
protected boolean buildSources(JDTBuilder jdtBuilder) {
if (jdtBuilder == null) {
jdtBuilder = new JDTBuilderImpl() //
.classpathOptions(new ClasspathOptions().encoding(this.encoding).classpath(getSourceClasspath())) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
/*
* compiler requires some sources, otherwise it does not pass batchCompiler.configure(args) well
* But it does not checks if the file really exists.
* The CompilationUnits are delivered to compiler in different way,
* so it is just a trick to initialize other Compiler configurations well
*/
.sources(new SourceOptions().sources("./Tmp.java"));
}
return buildUnitsAndModel(jdtBuilder, sources, getSourceClasspath(), "snippet ", false);
}

Expand Down

0 comments on commit ee2ca24

Please sign in to comment.