Skip to content

Commit

Permalink
Fix CreateImportsTests suite for javac usage
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <stryker@redhat.com>
  • Loading branch information
Rob Stryker committed Feb 23, 2024
1 parent 3fc8c17 commit 5be9f87
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.I
}
// For comparison
CompilationUnit res2 = CompilationUnitResolver.FACADE.toCompilationUnit(sourceUnit, initialNeedsToResolveBinding, project, classpaths, nodeSearcher, apiLevel, compilerOptions, typeRootWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor);

//res.typeAndFlags=res2.typeAndFlags;
String res1a = res.toString();
String res2a = res2.toString();
return res;
Expand All @@ -136,6 +136,10 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws java.io.
options.put(Option.XLINT_CUSTOM, "all"); // TODO refine according to compilerOptions
// TODO populate more from compilerOptions and/or project settings
AST ast = createAST(compilerOptions, apiLevel, context);
// int savedDefaultNodeFlag = ast.getDefaultNodeFlag();
// ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
// ast.setDefaultNodeFlag(savedDefaultNodeFlag);
ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
CompilationUnit res = ast.newCompilationUnit();
context.put(DiagnosticListener.class, new DiagnosticListener<JavaFileObject>() {
@Override
Expand All @@ -159,15 +163,12 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
javac.genEndPos = true;
javac.lineDebugInfo = true;
JCCompilationUnit javacCompilationUnit = javac.parse(fileObject);
int savedDefaultNodeFlag = ast.getDefaultNodeFlag();
ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
JavacConverter converter = new JavacConverter(ast, javacCompilationUnit, context);
converter.populateCompilationUnit(res, javacCompilationUnit);
attachComments(res, context, fileObject, converter, compilerOptions);
ast.setBindingResolver(new JavacBindingResolver(javac, javaProject, context, converter));
//
ast.setOriginalModificationCount(ast.modificationCount()); // "un-dirty" AST so Rewrite can process it
ast.setDefaultNodeFlag(savedDefaultNodeFlag);
return res;
}

Expand Down

0 comments on commit 5be9f87

Please sign in to comment.