Java: connect parents to children correctly in the inspections tree when the reference graph was not built (IJPL-166097)

GitOrigin-RevId: 33f9432081e9b44e4a1653b2bdbe4954b6526a01
This commit is contained in:
Bas Leijdekkers
2024-11-07 08:47:31 +00:00
committed by intellij-monorepo-bot
parent 1151d14dc1
commit f16888f4f3
3 changed files with 21 additions and 6 deletions
@@ -78,9 +78,14 @@ public final class RefClassImpl extends RefJavaElementImpl implements RefClass {
}
}
}
RefElement refParent = parent != null ? manager.getReference(parent.getSourcePsi()) : null;
WritableRefEntity refParent = parent != null ? (WritableRefEntity)manager.getReference(parent.getSourcePsi()) : null;
if (refParent != null) {
setOwner((WritableRefEntity)refParent);
if (!myManager.isDeclarationsFound()) {
refParent.add(this);
}
else {
setOwner(refParent);
}
}
else {
PsiFile containingFile = getContainingFile();
@@ -34,7 +34,14 @@ public final class RefFieldImpl extends RefJavaElementImpl implements RefField {
LOG.assertTrue(psi != null);
UField uElement = getUastElement();
LOG.assertTrue(uElement != null);
this.setOwner((WritableRefEntity)RefMethodImpl.findParentRef(psi, uElement, myManager));
WritableRefEntity parentRef = (WritableRefEntity)RefMethodImpl.findParentRef(psi, uElement, myManager);
if (parentRef == null) return;
if (!myManager.isDeclarationsFound()) {
parentRef.add(this);
}
else {
this.setOwner(parentRef);
}
}
@Deprecated
@@ -87,10 +87,13 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
}
}
RefElement parentRef = findParentRef(sourcePsi, method, myManager);
WritableRefEntity parentRef = (WritableRefEntity)findParentRef(sourcePsi, method, myManager);
if (parentRef == null) return;
setOwner((WritableRefEntity)parentRef);
if (!myManager.isDeclarationsFound()) return;
if (!myManager.isDeclarationsFound()) {
parentRef.add(this);
return;
}
setOwner(parentRef);
PsiMethod javaPsi = method.getJavaPsi();
if (!method.isConstructor()) {