diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StatementExtractor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StatementExtractor.java index c2e917d42179..82af144cd8b4 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StatementExtractor.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StatementExtractor.java @@ -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())); }