Search in sources :

Example 26 with TextAttributesKey

use of com.intellij.openapi.editor.colors.TextAttributesKey in project scss-lint-plugin by idok.

the class AnnotatorUtils method getTextAttributes.

@NotNull
public static TextAttributes getTextAttributes(@Nullable EditorColorsScheme editorColorsScheme, @NotNull SeverityRegistrar severityRegistrar, @NotNull HighlightSeverity severity) {
    TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(severity);
    if (textAttributes != null) {
        return textAttributes;
    }
    EditorColorsScheme colorsScheme = getColorsScheme(editorColorsScheme);
    HighlightInfoType.HighlightInfoTypeImpl infoType = severityRegistrar.getHighlightInfoTypeBySeverity(severity);
    TextAttributesKey key = infoType.getAttributesKey();
    return colorsScheme.getAttributes(key);
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with TextAttributesKey

use of com.intellij.openapi.editor.colors.TextAttributesKey in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoHighlightingAnnotator method annotate.

@Override
public void annotate(@NotNull PsiElement o, @NotNull AnnotationHolder holder) {
    if (!o.isValid())
        return;
    if (o instanceof GoImportSpec && ((GoImportSpec) o).isDot()) {
        //noinspection SynchronizationOnLocalVariableOrMethodParameter
        synchronized (o) {
            List<PsiElement> importUsers = o.getUserData(GoReferenceBase.IMPORT_USERS);
            if (importUsers != null) {
                List<PsiElement> newImportUsers = ContainerUtil.newSmartList();
                newImportUsers.addAll(importUsers.stream().filter(PsiElement::isValid).collect(Collectors.toList()));
                o.putUserData(GoReferenceBase.IMPORT_USERS, newImportUsers.isEmpty() ? null : newImportUsers);
            }
        }
    } else if (o instanceof GoLiteral) {
        if (((GoLiteral) o).getHex() != null || ((GoLiteral) o).getOct() != null) {
            setHighlighting(o, holder, NUMBER);
        }
    } else if (o instanceof GoReferenceExpressionBase) {
        PsiReference reference = o.getReference();
        highlightRefIfNeeded((GoReferenceExpressionBase) o, reference != null ? reference.resolve() : null, holder);
    } else if (o instanceof GoTypeSpec) {
        TextAttributesKey key = getColor((GoTypeSpec) o);
        setHighlighting(((GoTypeSpec) o).getIdentifier(), holder, key);
    } else if (o instanceof GoConstDefinition) {
        setHighlighting(o, holder, getColor((GoConstDefinition) o));
    } else if (o instanceof GoVarDefinition) {
        setHighlighting(o, holder, getColor((GoVarDefinition) o));
    } else if (o instanceof GoFieldDefinition) {
        setHighlighting(o, holder, getColor((GoFieldDefinition) o));
    } else if (o instanceof GoParamDefinition) {
        setHighlighting(o, holder, FUNCTION_PARAMETER);
    } else if (o instanceof GoReceiver) {
        PsiElement identifier = ((GoReceiver) o).getIdentifier();
        if (identifier != null) {
            setHighlighting(identifier, holder, METHOD_RECEIVER);
        }
    } else if (o instanceof GoLabelDefinition || o instanceof GoLabelRef) {
        setHighlighting(o, holder, LABEL);
    } else if (o instanceof GoNamedSignatureOwner) {
        PsiElement identifier = ((GoNamedSignatureOwner) o).getIdentifier();
        if (identifier != null) {
            setHighlighting(identifier, holder, getColor((GoNamedSignatureOwner) o));
        }
    }
}
Also used : PsiReference(com.intellij.psi.PsiReference) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) PsiElement(com.intellij.psi.PsiElement)

Example 28 with TextAttributesKey

use of com.intellij.openapi.editor.colors.TextAttributesKey in project smali by JesusFreke.

the class SmaliHighlightingColors method createTextAttributesKey.

private static TextAttributesKey createTextAttributesKey(String name, TextAttributesKey defaultColor) {
    TextAttributesKey key = TextAttributesKey.createTextAttributesKey(name, defaultColor);
    allKeys.add(key);
    return key;
}
Also used : TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 29 with TextAttributesKey

use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.

the class NodeRenderer method getSimpleTextAttributes.

public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation, @NotNull EditorColorsScheme colorsScheme) {
    if (presentation instanceof ColoredItemPresentation) {
        final TextAttributesKey textAttributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
        if (textAttributesKey == null)
            return SimpleTextAttributes.REGULAR_ATTRIBUTES;
        final TextAttributes textAttributes = colorsScheme.getAttributes(textAttributesKey);
        return textAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.fromTextAttributes(textAttributes);
    }
    return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
Also used : ColoredItemPresentation(com.intellij.navigation.ColoredItemPresentation) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 30 with TextAttributesKey

use of com.intellij.openapi.editor.colors.TextAttributesKey in project intellij-community by JetBrains.

the class AbstractProjectViewPSIPane method createComponent.

@Override
public JComponent createComponent() {
    if (myComponent != null)
        return myComponent;
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
    DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    myTree = createTree(treeModel);
    enableDnD();
    myComponent = ScrollPaneFactory.createScrollPane(myTree);
    if (Registry.is("error.stripe.enabled")) {
        ErrorStripePainter painter = new ErrorStripePainter(true);
        Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {

            @Override
            protected void update(ErrorStripePainter painter, int index, Object object) {
                if (object instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
                    object = node.getUserObject();
                }
                if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
                    object = null;
                }
                super.update(painter, index, object);
            }

            @Override
            protected ErrorStripe getErrorStripe(Object object) {
                if (object instanceof PresentableNodeDescriptor) {
                    PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
                    PresentationData presentation = node.getPresentation();
                    TextAttributesKey key = presentation.getTextAttributesKey();
                    if (key != null) {
                        TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
                        if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
                            return ErrorStripe.create(attributes.getEffectColor(), 1);
                        }
                    }
                }
                return null;
            }
        });
    }
    myTreeStructure = createStructure();
    BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
    installComparator(treeBuilder);
    setTreeBuilder(treeBuilder);
    initTree();
    Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {

        private boolean showing;

        @Override
        public void showNotify() {
            if (!showing) {
                showing = true;
                restoreExpandedPaths();
            }
        }

        @Override
        public void hideNotify() {
            if (showing) {
                showing = false;
                saveExpandedPaths();
            }
        }
    }));
    return myComponent;
}
Also used : ErrorStripe(com.intellij.ui.stripe.ErrorStripe) PresentableNodeDescriptor(com.intellij.ide.util.treeView.PresentableNodeDescriptor) PresentationData(com.intellij.ide.projectView.PresentationData) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Activatable(com.intellij.util.ui.update.Activatable) ErrorStripePainter(com.intellij.ui.stripe.ErrorStripePainter) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder)

Aggregations

TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)49 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)28 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)12 NotNull (org.jetbrains.annotations.NotNull)9 IElementType (com.intellij.psi.tree.IElementType)8 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)7 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)6 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)6 TextRange (com.intellij.openapi.util.TextRange)5 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)4 HighlightData (com.intellij.application.options.colors.highlighting.HighlightData)3 PresentationData (com.intellij.ide.projectView.PresentationData)3 Language (com.intellij.lang.Language)3 Lexer (com.intellij.lexer.Lexer)3 SyntaxHighlighter (com.intellij.openapi.fileTypes.SyntaxHighlighter)3 AttributesDescriptor (com.intellij.openapi.options.colors.AttributesDescriptor)3 Project (com.intellij.openapi.project.Project)3 Pair (com.intellij.openapi.util.Pair)3 PsiElement (com.intellij.psi.PsiElement)3 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)3