diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java index f38c6c4c85b..f3989855db5 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java @@ -180,6 +180,16 @@ ITypeBinding resolveType(EnumDeclaration enumDecl) { return null; } + @Override + ITypeBinding resolveType(AnonymousClassDeclaration anonymousClassDecl) { + resolve(); + JCTree javacNode = this.converter.domToJavac.get(anonymousClassDecl); + if (javacNode instanceof JCClassDecl jcClassDecl) { + return new JavacTypeBinding(jcClassDecl.type, this); + } + return null; + } + public IBinding getBinding(final Symbol owner, final com.sun.tools.javac.code.Type type) { if (owner instanceof final PackageSymbol other) { return new JavacPackageBinding(other, this); 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 24d6dbe3956..bde8d0a55ee 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 @@ -246,12 +246,14 @@ private ExportsDirective convert(JCExports javac) { res.setName(toName(javac.getPackageName())); commonSettings(res, javac); List mods = javac.getModuleNames(); - Iterator it = mods.iterator(); - while(it.hasNext()) { - JCExpression jcpe = it.next(); - Expression e = convertExpression(jcpe); - if( e != null ) - res.modules().add(e); + if (mods != null) { + Iterator it = mods.iterator(); + while(it.hasNext()) { + JCExpression jcpe = it.next(); + Expression e = convertExpression(jcpe); + if( e != null ) + res.modules().add(e); + } } return res; } @@ -729,14 +731,14 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent) retType = convertToType(unwrapDimensions(jcatt, dims)); } } - + if( retType != null || isConstructor) { if( this.ast.apiLevel != AST.JLS2_INTERNAL) { res.setReturnType2(retType); } else { res.internalSetReturnType(retType); } - } + } javac.getParameters().stream().map(this::convertVariableDeclaration).forEach(res.parameters()::add); @@ -790,7 +792,7 @@ private MethodDeclaration convertMethodDecl(JCMethodDecl javac, ASTNode parent) } return res; } - + private AbstractUnnamedTypeDeclaration findSurroundingTypeDeclaration(ASTNode parent) { if( parent == null ) return null; @@ -1415,7 +1417,7 @@ private AnonymousClassDeclaration createAnonymousClassDeclaration(JCClassDecl ja private int countDimensions(JCArrayTypeTree tree) { return countDimensionsAfterPosition(tree, 0); } - + private int countDimensionsAfterPosition(JCArrayTypeTree tree, int pos) { int ret = 0; JCTree elem = tree; @@ -1426,7 +1428,7 @@ private int countDimensionsAfterPosition(JCArrayTypeTree tree, int pos) { } return ret; } - + private JCTree unwrapDimensions(JCArrayTypeTree tree, int count) { JCTree elem = tree; while (elem != null && elem.hasTag(TYPEARRAY) && count > 0) { @@ -1829,7 +1831,7 @@ private Statement convertStatement(JCStatement javac, ASTNode parent) { if( jcAssert.getDetail() != null ) { Expression det = convertExpression(jcAssert.getDetail()); if( det != null ) - res.setMessage(det); + res.setMessage(det); } return res; } diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacProblemConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacProblemConverter.java index 3b01f0a62b5..12b51aea470 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacProblemConverter.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacProblemConverter.java @@ -132,7 +132,7 @@ private static org.eclipse.jface.text.Position getDiagnosticPosition(JCDiagnosti private static org.eclipse.jface.text.Position getDiagnosticPosition(String name, int startPosition, JCDiagnostic jcDiagnostic) throws IOException { - if (name != null) { + if (name != null && !name.isEmpty()) { DiagnosticSource source = jcDiagnostic.getDiagnosticSource(); JavaFileObject fileObject = source.getFile(); CharSequence charContent = fileObject.getCharContent(true); @@ -194,6 +194,7 @@ public static int toProblemId(Diagnostic diagnostic) { case "compiler.err.cant.apply.symbol" -> convertInApplicableSymbols(diagnostic); case "compiler.err.premature.eof" -> IProblem.ParsingErrorUnexpectedEOF; // syntax error case "compiler.err.report.access" -> convertNotVisibleAccess(diagnostic); + case "compiler.err.does.not.override.abstract" -> IProblem.AbstractMethodMustBeImplemented; case COMPILER_WARN_MISSING_SVUID -> IProblem.MissingSerialVersion; case COMPILER_WARN_NON_SERIALIZABLE_INSTANCE_FIELD -> 99999999; // JDT doesn't have this diagnostic case "compiler.err.ref.ambiguous" -> convertAmbiguous(diagnostic);