[global inspections] try to avoid race conditions by waiting until elements are initialized before building references

GitOrigin-RevId: de52d36337741d435ea14a81b77d5340b355f905
This commit is contained in:
Bas Leijdekkers
2021-10-12 11:36:23 +02:00
committed by intellij-monorepo-bot
parent 5b7c6af5af
commit b3ac7c53f3
7 changed files with 49 additions and 18 deletions

View File

@@ -327,6 +327,7 @@ public class RefJavaUtilImpl extends RefJavaUtil {
if (refClass != null) {
boolean hasConstructorsMarked = false;
refClass.waitForInitialized();
if (defaultConstructorOnly) {
WritableRefElement refDefaultConstructor = (WritableRefElement)refClass.getDefaultConstructor();
@@ -485,6 +486,7 @@ public class RefJavaUtilImpl extends RefJavaUtil {
@Override
public RefClass getTopLevelClass(@NotNull RefElement refElement) {
LOG.assertTrue(refElement.isInitialized(), refElement.getName() + " not initialized");
RefEntity refParent = refElement.getOwner();
while (refParent instanceof RefElement && !(refParent instanceof RefFile)) {
@@ -564,6 +566,7 @@ public class RefJavaUtilImpl extends RefJavaUtil {
@Override
@Nullable
public RefClass getOwnerClass(RefElement refElement) {
LOG.assertTrue(refElement.isInitialized(), refElement.getName() + " not initialized");
RefEntity parent = refElement.getOwner();
while (!(parent instanceof RefClass) && parent instanceof RefElement) {