failed test line highlighting: highlight method name only

This commit is contained in:
Dmitry Avdeev
2018-05-23 18:28:39 +03:00
parent f39c95e6e2
commit 6cc97299ca
2 changed files with 7 additions and 3 deletions
@@ -30,13 +30,16 @@ public class TestFailedLineInspection extends LocalInspectionTool {
@Override
public void visitMethodCallExpression(PsiMethodCallExpression call) {
PsiElement nameElement = call.getMethodExpression().getReferenceNameElement();
if (nameElement == null) return;
TestStateStorage.Record state = TestFailedLineManager.getInstance(call.getProject()).getFailedLineState(call);
if (state == null) return;
LocalQuickFix[] fixes = {new DebugFailedTestFix(call, state.topStacktraceLine),
new RunActionFix(call, DefaultRunExecutor.EXECUTOR_ID)};
ProblemDescriptor descriptor = InspectionManager.getInstance(call.getProject())
.createProblemDescriptor(call, state.errorMessage, isOnTheFly, fixes,
.createProblemDescriptor(nameElement, state.errorMessage, isOnTheFly, fixes,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
descriptor.setTextAttributes(CodeInsightColors.RUNTIME_ERROR);
holder.registerProblem(descriptor);
@@ -37,7 +37,8 @@ public class FailedLineTest extends LightCodeInsightFixtureTestCase {
public void testFailedLineManager() {
configure();
myFixture.enableInspections(new TestFailedLineInspection());
myFixture.testHighlighting();
PsiElement element = PsiUtilBase.getElementAtCaret(getEditor());
PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
PsiMethod psiMethod = PsiTreeUtil.getParentOfType(callExpression, PsiMethod.class);
@@ -91,7 +92,7 @@ public class FailedLineTest extends LightCodeInsightFixtureTestCase {
myFixture.addClass("package junit.framework; public class TestCase {}");
myFixture.configureByText("MainTest.java", " public class MainTest extends junit.framework.TestCase {\n" +
" public void testFoo() {\n" +
" <warning descr=\"oops\">assertE<caret>quals()</warning>;\n" +
" <warning descr=\"oops\">assertE<caret>quals</warning>();\n" +
" assertEquals();\n" +
" }\n" +
" public void assertEquals() {}\n" +