From 3dda5a5127d64c415f4dc665e26f29373caf8c8b Mon Sep 17 00:00:00 2001 From: Rob Stryker Date: Wed, 11 Dec 2024 14:21:32 -0500 Subject: [PATCH] Fix regressions ASTConverterAST3Test.test0009 and others; also Cleanup Signed-off-by: Rob Stryker --- .../jdt/core/dom/JavacCompilationUnitResolver.java | 12 +----------- .../src/org/eclipse/jdt/core/dom/JavacConverter.java | 3 +-- 2 files changed, 2 insertions(+), 13 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 65329b80b9f..49f06737391 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 @@ -541,22 +541,12 @@ public CompilationUnit toCompilationUnit(org.eclipse.jdt.internal.compiler.env.I pathToUnit.put(pathOfClassUnderAnalysis, sourceUnit); } - // TODO currently only parse + //CompilationUnit res2 = CompilationUnitResolver.getInstance().toCompilationUnit(sourceUnit, resolveBindings, project, classpaths, focalPoint, apiLevel, compilerOptions, typeRootWorkingCopyOwner, typeRootWorkingCopyOwner, flags, monitor); CompilationUnit res = parse(pathToUnit.values().toArray(org.eclipse.jdt.internal.compiler.env.ICompilationUnit[]::new), apiLevel, compilerOptions, resolveBindings, flags, project, workingCopyOwner, focalPoint, monitor).get(sourceUnit); if (resolveBindings) { resolveBindings(res, apiLevel); } - // 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(); -// -// AnnotationTypeDeclaration l1 = (AnnotationTypeDeclaration)res.types().get(0); -// AnnotationTypeDeclaration l2 = (AnnotationTypeDeclaration)res2.types().get(0); -// Object o1 = l1.bodyDeclarations().get(0); -// Object o2 = l2.bodyDeclarations().get(0); return res; } diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java index ef16c063a29..f1ceb29280b 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java @@ -2002,7 +2002,6 @@ private ArrayInitializer createArrayInitializerFromJCNewArray(JCNewArray jcNewAr commonSettings(initializer, jcNewArray); if (!jcNewArray.getInitializers().isEmpty()) { jcNewArray.getInitializers().stream().map(this::convertExpression).filter(Objects::nonNull).forEach(initializer.expressions()::add); - this.rawText.charAt(0); int start = ((Expression)initializer.expressions().getFirst()).getStartPosition() - 1; while (start >= 0 && this.rawText.charAt(start) != '{') { start--; @@ -2012,7 +2011,7 @@ private ArrayInitializer createArrayInitializerFromJCNewArray(JCNewArray jcNewAr while (end < this.rawText.length() && this.rawText.charAt(end) != '}') { end++; } - initializer.setSourceRange(start, end - start); + initializer.setSourceRange(start, end - start + 1); } return initializer; }