|
20 | 20 | import java.nio.file.Files; |
21 | 21 | import java.nio.file.Paths; |
22 | 22 | import java.util.ArrayList; |
| 23 | +import java.util.Arrays; |
23 | 24 | import java.util.Collections; |
24 | 25 | import java.util.HashMap; |
| 26 | +import java.util.HashSet; |
25 | 27 | import java.util.List; |
26 | 28 | import java.util.Map; |
27 | 29 | import java.util.Objects; |
| 30 | +import java.util.Set; |
28 | 31 | import java.util.jar.Attributes; |
29 | 32 | import java.util.jar.Manifest; |
30 | 33 | import java.util.logging.Level; |
|
57 | 60 | import org.eclipse.jdt.core.dom.IMethodBinding; |
58 | 61 | import org.eclipse.jdt.core.dom.ITypeBinding; |
59 | 62 | import org.eclipse.jdt.core.dom.LambdaExpression; |
60 | | -import org.eclipse.jdt.core.dom.UnnamedClass; |
61 | 63 | import org.eclipse.jdt.core.manipulation.CoreASTProvider; |
62 | 64 | import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; |
63 | 65 | import org.eclipse.jdt.launching.IVMInstall; |
@@ -87,6 +89,9 @@ public class JdtSourceLookUpProvider implements ISourceLookUpProvider { |
87 | 89 | private static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME); |
88 | 90 | private static final String JDT_SCHEME = "jdt"; |
89 | 91 | private static final String PATH_SEPARATOR = "/"; |
| 92 | + private static final Set<String> IMPLICITLY_DECLARED_CLASSES = new HashSet<>( |
| 93 | + Arrays.asList("org.eclipse.jdt.core.dom.UnnamedClass", |
| 94 | + "org.eclipse.jdt.core.dom.ImplicitTypeDeclaration")); |
90 | 95 | private ISourceContainer[] sourceContainers = null; |
91 | 96 |
|
92 | 97 | private HashMap<String, Object> options = new HashMap<String, Object>(); |
@@ -176,7 +181,10 @@ public JavaBreakpointLocation[] getBreakpointLocations(String sourceUri, SourceB |
176 | 181 | if (astUnit != null) { |
177 | 182 | List<?> types = astUnit.types(); |
178 | 183 | String unnamedClass = null; |
179 | | - if (types.size() == 1 && types.get(0) instanceof UnnamedClass) { |
| 184 | + // See https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2220 |
| 185 | + // Given that the JDT plans to rename UnamedClass to ImplicitTypeDeclaration, we will check |
| 186 | + // the class name of the ASTNode to prevent the potential breaking in the future. |
| 187 | + if (types.size() == 1 && IMPLICITLY_DECLARED_CLASSES.contains(types.get(0).getClass().getName())) { |
180 | 188 | unnamedClass = inferPrimaryTypeName(sourceUri, astUnit); |
181 | 189 | } |
182 | 190 | Map<Integer, BreakpointLocation[]> resolvedLocations = new HashMap<>(); |
|
0 commit comments