Search in sources :

Example 36 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class ExtractMethodProcessor method showMultipleExitPointsMessage.

private void showMultipleExitPointsMessage() {
    if (myShowErrorDialogs) {
        HighlightManager highlightManager = HighlightManager.getInstance(myProject);
        PsiStatement[] exitStatementsArray = myExitStatements.toArray(new PsiStatement[myExitStatements.size()]);
        EditorColorsManager manager = EditorColorsManager.getInstance();
        TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null);
        String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("there.are.multiple.exit.points.in.the.selected.code.fragment"));
        CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId);
        WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
    }
}
Also used : HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 37 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class IntroduceConstantHandler method highlightError.

private static void highlightError(Project project, Editor editor, PsiElement errorElement) {
    if (editor != null) {
        final TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        final TextRange textRange = errorElement.getTextRange();
        HighlightManager.getInstance(project).addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, new ArrayList<>());
    }
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) TextRange(com.intellij.openapi.util.TextRange)

Example 38 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class HighlightInfo method getAttributesByType.

public static TextAttributes getAttributesByType(@Nullable final PsiElement element, @NotNull HighlightInfoType type, @NotNull TextAttributesScheme colorsScheme) {
    final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(element != null ? element.getProject() : null);
    final TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(type.getSeverity(element));
    if (textAttributes != null) {
        return textAttributes;
    }
    TextAttributesKey key = type.getAttributesKey();
    return colorsScheme.getAttributes(key);
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 39 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class HighlightInfo method fromAnnotation.

@NotNull
static HighlightInfo fromAnnotation(@NotNull Annotation annotation, @Nullable TextRange fixedRange, boolean batchMode) {
    final TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes();
    TextAttributesKey key = annotation.getTextAttributes();
    final TextAttributesKey forcedAttributesKey = forcedAttributes == null ? (key == HighlighterColors.NO_HIGHLIGHTING ? null : key) : null;
    HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation), fixedRange != null ? fixedRange.getStartOffset() : annotation.getStartOffset(), fixedRange != null ? fixedRange.getEndOffset() : annotation.getEndOffset(), annotation.getMessage(), annotation.getTooltip(), annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(), 0, annotation.getProblemGroup(), annotation.getGutterIconRenderer());
    appendFixes(fixedRange, info, batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes());
    return info;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class RainbowHighlighter method getColorsFromCache.

@Nullable
private static Color[] getColorsFromCache(@NotNull TextAttributesScheme colorsScheme) {
    final Map<TextAttributesKey, TextAttributes> cache = getGeneratedTextAttributesCache(colorsScheme);
    if (cache == null) {
        return null;
    }
    List<Color> colors = new ArrayList<>();
    boolean invalidCache = false;
    for (TextAttributesKey tempKey : RAINBOW_TEMP_KEYS) {
        final TextAttributes attributes = cache.get(tempKey);
        if (attributes == null) {
            invalidCache = true;
            break;
        }
        colors.add(getRainbowColorFromAttribute(attributes));
    }
    if (invalidCache) {
        return null;
    }
    return colors.toArray(new Color[colors.size()]);
}
Also used : JBColor(com.intellij.ui.JBColor) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)215 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)40 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)33 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)31 NotNull (org.jetbrains.annotations.NotNull)29 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)28 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)26 TextRange (com.intellij.openapi.util.TextRange)23 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)23 Nullable (org.jetbrains.annotations.Nullable)21 Project (com.intellij.openapi.project.Project)20 Editor (com.intellij.openapi.editor.Editor)19 ArrayList (java.util.ArrayList)19 PsiElement (com.intellij.psi.PsiElement)12 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)11 JBColor (com.intellij.ui.JBColor)11 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)10 Document (com.intellij.openapi.editor.Document)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 ContainerUtil (com.intellij.util.containers.ContainerUtil)9