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 5bfee1c2cd5..e2a590aca4a 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 @@ -14,8 +14,10 @@ package org.eclipse.jdt.internal.javac; import java.io.IOException; +import java.util.HashSet; import java.util.Locale; import java.util.Map; +import java.util.Set; import javax.tools.Diagnostic; import javax.tools.JavaFileObject; @@ -49,6 +51,10 @@ public class JavacProblemConverter { private final CompilerOptions compilerOptions; private final Context context; + private final Set existingProblems = new HashSet<>(); + + private final record FileAndPosition(String filePath, int position) {} + public JavacProblemConverter(Map options, Context context) { this(new CompilerOptions(options), context); } @@ -74,6 +80,11 @@ public JavacProblem createJavacProblem(Diagnostic diag return null; } org.eclipse.jface.text.Position diagnosticPosition = getDiagnosticPosition(diagnostic, context); + FileAndPosition fileAndPosition = new FileAndPosition(diagnostic.getSource().toUri().toString(), diagnosticPosition.getOffset()); + if (existingProblems.contains(fileAndPosition)) { + return null; + } + existingProblems.add(fileAndPosition); return new JavacProblem( diagnostic.getSource().getName().toCharArray(), diagnostic.getMessage(Locale.getDefault()),