Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: compile comments only if needed #1487

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions src/main/java/spoon/support/compiler/jdt/JDTBatchCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,25 @@ this.jdtCompiler.requestor, getProblemFactory(), this.out,
final CompilationUnitDeclaration[] result = treeBuilderCompiler.buildUnits(getCompilationUnits());

// now adding the doc
for (int i = 0; i < result.length; i++) {
CompilationUnitDeclaration unit = result[i];
CommentRecorderParser parser =
new CommentRecorderParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
new DefaultProblemFactory(Locale.getDefault())),
false);

//reuse the source compilation unit
ICompilationUnit sourceUnit = unit.compilationResult.compilationUnit;

final CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
CompilationUnitDeclaration tmpDeclForComment = parser.dietParse(sourceUnit, compilationResult);
unit.comments = tmpDeclForComment.comments;
if (jdtCompiler.getEnvironment().isCommentsEnabled()) {
//compile comments only if they are needed
for (int i = 0; i < result.length; i++) {
CompilationUnitDeclaration unit = result[i];
CommentRecorderParser parser =
new CommentRecorderParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
compilerOptions,
new DefaultProblemFactory(Locale.getDefault())),
false);

//reuse the source compilation unit
ICompilationUnit sourceUnit = unit.compilationResult.compilationUnit;

final CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
CompilationUnitDeclaration tmpDeclForComment = parser.dietParse(sourceUnit, compilationResult);
unit.comments = tmpDeclForComment.comments;
}
}
return result;
}
Expand Down