mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-91311 StackOverflow Error in ApplicationImpl
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
@@ -31,23 +32,27 @@ public class PsiInvalidElementAccessException extends RuntimeException {
|
||||
private final SoftReference<PsiElement> myElementReference; // to prevent leaks, since exceptions are stored in IdeaLogger
|
||||
|
||||
public PsiInvalidElementAccessException(PsiElement element) {
|
||||
this(element, null, null);
|
||||
this(element, (String)null);
|
||||
}
|
||||
|
||||
public PsiInvalidElementAccessException(PsiElement element, String message) {
|
||||
this(element, message, null);
|
||||
public PsiInvalidElementAccessException(PsiElement element, @Nullable String message) {
|
||||
this(element, getMessageWithReason(element, message), null);
|
||||
}
|
||||
|
||||
public PsiInvalidElementAccessException(PsiElement element, Throwable cause) {
|
||||
this(element, null, cause);
|
||||
public PsiInvalidElementAccessException(PsiElement element, @Nullable Throwable cause) {
|
||||
this(element, getMessageWithReason(element, null), cause);
|
||||
}
|
||||
|
||||
public PsiInvalidElementAccessException(PsiElement element, String message, Throwable cause) {
|
||||
super((element != null ? "Element: " + element.getClass() + " because: " + reason(element) : "Unknown psi element") +
|
||||
(message == null ? "" : "; " + message), cause);
|
||||
public PsiInvalidElementAccessException(PsiElement element, @Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
myElementReference = new SoftReference<PsiElement>(element);
|
||||
}
|
||||
|
||||
private static String getMessageWithReason(@Nullable PsiElement element, @Nullable String message) {
|
||||
return (element != null ? "Element: " + element.getClass() + " because: " + reason(element) : "Unknown psi element") +
|
||||
(message == null ? "" : "; " + message);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@NotNull
|
||||
private static String reason(@NotNull PsiElement root){
|
||||
@@ -71,6 +76,7 @@ public class PsiInvalidElementAccessException extends RuntimeException {
|
||||
return "psi is outdated";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getPsiElement() {
|
||||
return myElementReference.get();
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
}
|
||||
PsiFile psi = (PsiFile)stub.getPsi();
|
||||
if (psi == null) {
|
||||
throw new PsiInvalidElementAccessException(this);
|
||||
throw new PsiInvalidElementAccessException(this, "no psi for file stub " + stub, null);
|
||||
}
|
||||
return psi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user