Skip to content

Commit b1b4e0e

Browse files
committed
createASTs with binding key also notify null without CUs
1 parent 5b30d78 commit b1b4e0e

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacCompilationUnitResolver.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,11 @@ public void accept(ISourceType[] sourceType, PackageBinding packageBinding,
300300
});
301301

302302
resolveRequestedBindingKeys(bindingResolver[0], bindingKeys,
303-
(a,b) -> requestor.acceptBinding(a,b),
304-
new Classpath[0], // TODO need some classpaths
303+
(a,b) -> {
304+
if (b != null || mockUnit != null) {
305+
requestor.acceptBinding(a,b);
306+
}
307+
}, new Classpath[0], // TODO need some classpaths
305308
new CompilerOptions(compilerOptions),
306309
units.values(), project, bindingMap, monitor);
307310
} else {
@@ -343,36 +346,32 @@ private void resolveRequestedBindingKeys(JavacBindingResolver bindingResolver, S
343346

344347
// resolve the requested bindings
345348
for (String bindingKey : bindingKeys) {
346-
347349
int arrayCount = Signature.getArrayCount(bindingKey);
348-
IBinding bindingFromMap = bindingMap.get(bindingKey);
349-
if (bindingFromMap != null) {
350-
// from parsed files
351-
requestor.acceptBinding(bindingKey, bindingFromMap);
352-
} else {
353-
if (arrayCount > 0) {
354-
String elementKey = Signature.getElementType(bindingKey);
355-
IBinding elementBinding = bindingMap.get(elementKey);
356-
if (elementBinding instanceof ITypeBinding elementTypeBinding) {
357-
requestor.acceptBinding(bindingKey, elementTypeBinding.createArrayType(arrayCount));
358-
continue;
359-
}
350+
IBinding binding = bindingMap.get(bindingKey);
351+
if (binding == null && arrayCount > 0) {
352+
String elementKey = Signature.getElementType(bindingKey);
353+
IBinding elementBinding = bindingMap.get(elementKey);
354+
if (elementBinding instanceof ITypeBinding elementTypeBinding) {
355+
binding = elementBinding;
360356
}
361-
357+
}
358+
if (binding == null) {
362359
CustomBindingKeyParser bkp = new CustomBindingKeyParser(bindingKey);
363360
bkp.parse(true);
364361
ITypeBinding type = bindingResolver.resolveWellKnownType(bkp.compoundName);
365362
if (type != null) {
366363
if (Objects.equals(bindingKey, type.getKey())) {
367-
requestor.acceptBinding(bindingKey, type);
364+
binding = type;
368365
} else {
369-
Stream.of(type.getDeclaredMethods(), type.getDeclaredFields())
366+
binding = Stream.of(type.getDeclaredMethods(), type.getDeclaredFields())
370367
.flatMap(Arrays::stream)
371-
.filter(binding -> Objects.equals(binding.getKey(), bindingKey))
372-
.forEach(binding -> requestor.acceptBinding(bindingKey, binding));
368+
.filter(b -> Objects.equals(b.getKey(), bindingKey))
369+
.findAny()
370+
.orElse(null);
373371
}
374372
}
375373
}
374+
requestor.acceptBinding(bindingKey, binding);
376375
}
377376

378377
}

0 commit comments

Comments
 (0)