failed test line highlighting: "Runtime problem" text attributes

This commit is contained in:
Dmitry Avdeev
2018-05-03 17:10:24 +03:00
parent 55119fd7ab
commit e71ec105dc
7 changed files with 42 additions and 12 deletions
@@ -1,10 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.*;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.execution.*;
import com.intellij.execution.actions.ConfigurationContext;
@@ -13,6 +10,7 @@ import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.stacktrace.StackTraceLine;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.*;
@@ -35,8 +33,13 @@ public class TestFailedLineInspection extends LocalInspectionTool {
TestStateStorage.Record state = TestFailedLineManager.getInstance(call.getProject()).getFailedLineState(call);
if (state == null) return;
holder.registerProblem(call, state.errorMessage, new DebugFailedTestFix(call, state.topStacktraceLine),
new RunActionFix(call, DefaultRunExecutor.EXECUTOR_ID));
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,
ProblemHighlightType.GENERIC_ERROR);
descriptor.setTextAttributes(CodeInsightColors.RUNTIME_PROBLEM);
holder.registerProblem(descriptor);
}
};
}
@@ -1,10 +1,14 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.navigation;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.execution.TestStateStorage;
import com.intellij.execution.testframework.JavaTestLocator;
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
import com.intellij.execution.testframework.sm.runner.ui.TestStackTraceParser;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiMethodCallExpression;
@@ -15,6 +19,7 @@ import com.intellij.execution.testframework.TestFailedLineInspection;
import com.intellij.testIntegration.TestFailedLineManager;
import java.util.Date;
import java.util.List;
public class FailedLineTest extends LightCodeInsightFixtureTestCase {
@@ -35,6 +40,11 @@ public class FailedLineTest extends LightCodeInsightFixtureTestCase {
configure();
myFixture.enableInspections(new TestFailedLineInspection());
myFixture.testHighlighting();
List<HighlightInfo> infos = myFixture.doHighlighting(HighlightSeverity.ERROR);
assertEquals(1, infos.size());
TextAttributes attributes = infos.get(0).forcedTextAttributes;
assertNotNull(attributes);
assertEquals(EffectType.BOLD_DOTTED_LINE, attributes.getEffectType());
}
public void testTopStacktraceLine() {
@@ -22,6 +22,7 @@ public interface CodeInsightColors {
TextAttributesKey WARNINGS_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("WARNING_ATTRIBUTES");
TextAttributesKey GENERIC_SERVER_ERROR_OR_WARNING = TextAttributesKey.createTextAttributesKey("GENERIC_SERVER_ERROR_OR_WARNING");
TextAttributesKey DUPLICATE_FROM_SERVER = TextAttributesKey.createTextAttributesKey("DUPLICATE_FROM_SERVER");
TextAttributesKey RUNTIME_PROBLEM = TextAttributesKey.createTextAttributesKey("RUNTIME_PROBLEM");
/**
* use #WEAK_WARNING_ATTRIBUTES instead
*/
@@ -26,13 +26,9 @@ import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider;
import com.intellij.openapi.options.colors.ColorSettingsPage;
import com.intellij.openapi.util.text.StringUtil;
import java.util.HashMap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author lesya
@@ -81,6 +77,7 @@ public class ColorSettingsUtil {
descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.weak.warning"), CodeInsightColors.WEAK_WARNING_ATTRIBUTES));
descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.problems"), CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING));
descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.duplicate"), CodeInsightColors.DUPLICATE_FROM_SERVER));
descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.runtime"), CodeInsightColors.RUNTIME_PROBLEM));
for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) {
@@ -25,6 +25,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.keymap.Keymap;
@@ -353,7 +354,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
boolean isFileLevel = psiElement instanceof PsiFile && textRange.equals(psiElement.getTextRange());
final HighlightSeverity severity = highlightInfoType.getSeverity(psiElement);
TextAttributes attributes = mySeverityRegistrar.getTextAttributesBySeverity(severity);
TextAttributesKey attributesKey = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
TextAttributes attributes = attributesKey == null || getColorsScheme() == null
? mySeverityRegistrar.getTextAttributesBySeverity(severity)
: getColorsScheme().getAttributes(attributesKey);
HighlightInfo.Builder b = HighlightInfo.newHighlightInfo(highlightInfoType)
.range(psiElement, textRange.getStartOffset(), textRange.getEndOffset())
.description(message)
@@ -70,6 +70,7 @@ options.java.attribute.descriptor.warning=Errors and Warnings//Warning
options.java.attribute.descriptor.deprecated.symbol=Errors and Warnings//Deprecated symbol
options.java.attribute.descriptor.marked.for.removal.symbol=Errors and Warnings//Deprecated symbol marked for removal
options.java.attribute.descriptor.unused.symbol=Errors and Warnings//Unused symbol
options.java.attribute.descriptor.runtime=Errors and Warnings//Runtime problem
options.java.attribute.descriptor.class=Classes and Interfaces//Class
options.java.attribute.descriptor.anonymous.class=Classes and Interfaces//Anonymous class
options.java.attribute.descriptor.type.parameter=Parameters//Type parameter
@@ -296,6 +296,13 @@
<option name="ERROR_STRIPE_COLOR" value="cf5b56" deuteranopia="d95716" protanopia="d95716"/>
</value>
</option>
<option name="RUNTIME_PROBLEM">
<value>
<option name="EFFECT_COLOR" value="ff0000" />
<option name="ERROR_STRIPE_COLOR" value="cf5b56" />
<option name="EFFECT_TYPE" value="5" />
</value>
</option>
<option name="BLINKING_HIGHLIGHTS_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
@@ -1592,6 +1599,13 @@
<option name="ERROR_STRIPE_COLOR" value="9e2927" deuteranopia="ff8f40" protanopia="ff8f40"/>
</value>
</option>
<option name="RUNTIME_PROBLEM">
<value>
<option name="EFFECT_COLOR" value="bc3f3c"/>
<option name="EFFECT_TYPE" value="5" />
<option name="ERROR_STRIPE_COLOR" value="9e2927"/>
</value>
</option>
<option name="EXECUTIONPOINT_ATTRIBUTES">
<value>
<option name="BACKGROUND" value="2d6099" />