From 5be9f873041696e83aa2326b248a7faf14ec8d38 Mon Sep 17 00:00:00 2001 From: Rob Stryker Date: Fri, 23 Feb 2024 02:47:10 -0500 Subject: [PATCH] Fix CreateImportsTests suite for javac usage Signed-off-by: Rob Stryker --- .../jdt/core/dom/JavacCompilationUnitResolver.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java index 8464bb967df..33b4ca945f9 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java @@ -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; @@ -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() { @Override @@ -159,15 +163,12 @@ public void report(Diagnostic 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; }