mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiInvalidElementAccessException: prevent creation SOE (EA-84774), construct from an ASTNode
This commit is contained in:
@@ -75,13 +75,7 @@ public class PsiInvalidElementAccessException extends RuntimeException implement
|
||||
try {
|
||||
Object trace = recursiveInvocation ? null : getPsiInvalidationTrace(element);
|
||||
myMessage = getMessageWithReason(element, message, recursiveInvocation, trace);
|
||||
if (trace == null) {
|
||||
myDiagnostic = Attachment.EMPTY_ARRAY;
|
||||
}
|
||||
else {
|
||||
myDiagnostic = new Attachment[]{trace instanceof Throwable ? new Attachment("invalidation", (Throwable)trace)
|
||||
: new Attachment("diagnostic.txt", trace.toString())};
|
||||
}
|
||||
myDiagnostic = createAttachments(trace);
|
||||
}
|
||||
finally {
|
||||
element.putUserData(REPORTING_EXCEPTION, null);
|
||||
@@ -89,6 +83,20 @@ public class PsiInvalidElementAccessException extends RuntimeException implement
|
||||
}
|
||||
}
|
||||
|
||||
public PsiInvalidElementAccessException(@NotNull ASTNode node, @Nullable String message) {
|
||||
myElementReference = new SoftReference<PsiElement>(null);
|
||||
myMessage = "Element " + node.getClass() + " of type " + node.getElementType() + (message == null ? "" : "; " + message);
|
||||
myDiagnostic = createAttachments(findInvalidationTrace(node));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Attachment[] createAttachments(@Nullable Object trace) {
|
||||
return trace == null
|
||||
? Attachment.EMPTY_ARRAY
|
||||
: new Attachment[]{trace instanceof Throwable ? new Attachment("invalidation", (Throwable)trace)
|
||||
: new Attachment("diagnostic.txt", trace.toString())};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Object getPsiInvalidationTrace(@NotNull PsiElement element) {
|
||||
Object trace = getInvalidationTrace(element);
|
||||
|
||||
@@ -242,7 +242,11 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
return mySubstrateRef.getContainingFile();
|
||||
}
|
||||
catch (PsiInvalidElementAccessException e) {
|
||||
throw new PsiInvalidElementAccessException(this, e);
|
||||
if (PsiInvalidElementAccessException.getInvalidationTrace(this) != null) {
|
||||
throw new PsiInvalidElementAccessException(this, e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class SubstrateRef {
|
||||
@Override
|
||||
public PsiFile getContainingFile() {
|
||||
PsiFile file = SharedImplUtil.getContainingFile(node);
|
||||
if (file == null) throw new PsiInvalidElementAccessException(node.getPsi());
|
||||
if (file == null) throw new PsiInvalidElementAccessException(node, null);
|
||||
return file;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user