StatementExtractor: better diagnostics if parent is unexpectedly null

Review: IDEA-CR-21189
This commit is contained in:
Tagir Valeev
2017-06-14 10:07:30 +07:00
parent f7f8a7f214
commit 4a79dbe010
@@ -73,7 +73,10 @@ public class StatementExtractor {
}
parent = ObjectUtils.tryCast(parentElement, PsiExpression.class);
if (parent == null) {
throw new RuntimeExceptionWithAttachments("Expected to have expression parent",
String message = PsiTreeUtil.isAncestor(root, expression, false) ?
"Expected to have expression parent" :
"Supplied root is not the expression ancestor";
throw new RuntimeExceptionWithAttachments(message,
new Attachment("expression.txt", expression.getText()),
new Attachment("root.txt", root.getText()));
}