mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
failed test line highlighting: highlight method name only
This commit is contained in:
+4
-1
@@ -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);
|
||||
|
||||
+3
-2
@@ -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" +
|
||||
|
||||
Reference in New Issue
Block a user