make "'Throwable' printed to 'System.out'" inspection warn in more cases

This commit is contained in:
Bas Leijdekkers
2014-09-12 16:01:57 +02:00
parent 1aabb6b27c
commit 30f03aa7f6
2 changed files with 6 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,11 +69,7 @@ public class ThrowablePrintedToSystemOutInspection extends BaseInspection {
return;
}
final PsiExpression argument = arguments[0];
if (!(argument instanceof PsiReferenceExpression)) {
return;
}
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)argument;
if (!TypeUtils.expressionHasTypeOrSubtype(referenceExpression, CommonClassNames.JAVA_LANG_THROWABLE)) {
if (!TypeUtils.expressionHasTypeOrSubtype(argument, CommonClassNames.JAVA_LANG_THROWABLE)) {
return;
}
final PsiMethod method = expression.resolveMethod();
@@ -30,6 +30,10 @@ public class ThrowablePrintedToSystemOutInspectionTest extends LightInspectionTe
"}\n");
}
public void testEvenSimpler() {
doStatementTest("System.out.println(/*Throwable argument 'new RuntimeException()' to 'System.out.println()' call*/new RuntimeException()/**/);");
}
@Override
protected InspectionProfileEntry getInspection() {
return new ThrowablePrintedToSystemOutInspection();