Search in sources :

Example 91 with EditorColorsScheme

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

the class JavaLineMarkerProvider method getLineMarkerInfo.

@Override
@Nullable
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
    PsiElement parent;
    if (element instanceof PsiIdentifier && (parent = element.getParent()) instanceof PsiMethod) {
        if (!myOverridingOption.isEnabled() && !myImplementingOption.isEnabled())
            return null;
        PsiMethod method = (PsiMethod) parent;
        MethodSignatureBackedByPsiMethod superSignature = SuperMethodsSearch.search(method, null, true, false).findFirst();
        if (superSignature != null) {
            boolean overrides = method.hasModifierProperty(PsiModifier.ABSTRACT) == superSignature.getMethod().hasModifierProperty(PsiModifier.ABSTRACT);
            final Icon icon;
            if (overrides) {
                if (!myOverridingOption.isEnabled())
                    return null;
                icon = AllIcons.Gutter.OverridingMethod;
            } else {
                if (!myImplementingOption.isEnabled())
                    return null;
                icon = AllIcons.Gutter.ImplementingMethod;
            }
            return createSuperMethodLineMarkerInfo(element, icon, Pass.LINE_MARKERS);
        }
    }
    final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element);
    final PsiElement firstChild = element.getFirstChild();
    if (interfaceMethod != null && firstChild != null && myLambdaOption.isEnabled()) {
        return createSuperMethodLineMarkerInfo(firstChild, AllIcons.Gutter.ImplementingFunctionalInterface, Pass.LINE_MARKERS);
    }
    if (myDaemonSettings.SHOW_METHOD_SEPARATORS && firstChild == null) {
        PsiElement element1 = element;
        boolean isMember = false;
        while (element1 != null && !(element1 instanceof PsiFile) && element1.getPrevSibling() == null) {
            element1 = element1.getParent();
            if (element1 instanceof PsiMember) {
                isMember = true;
                break;
            }
        }
        if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) {
            PsiFile file = element1.getContainingFile();
            Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getLastCommittedDocument(file);
            boolean drawSeparator = false;
            if (document != null) {
                CharSequence documentChars = document.getCharsSequence();
                int category = getCategory(element1, documentChars);
                for (PsiElement child = element1.getPrevSibling(); child != null; child = child.getPrevSibling()) {
                    int category1 = getCategory(child, documentChars);
                    if (category1 == 0)
                        continue;
                    drawSeparator = category != 1 || category1 != 1;
                    break;
                }
            }
            if (drawSeparator) {
                LineMarkerInfo info = new LineMarkerInfo<>(element, element.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
                EditorColorsScheme scheme = myColorsManager.getGlobalScheme();
                info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
                info.separatorPlacement = SeparatorPlacement.TOP;
                return info;
            }
        }
    }
    return null;
}
Also used : MethodSignatureBackedByPsiMethod(com.intellij.psi.util.MethodSignatureBackedByPsiMethod) MethodSignatureBackedByPsiMethod(com.intellij.psi.util.MethodSignatureBackedByPsiMethod) Document(com.intellij.openapi.editor.Document) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Nullable(org.jetbrains.annotations.Nullable)

Example 92 with EditorColorsScheme

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

the class TodoPackageNode method update.

@Override
protected void update(PresentationData data) {
    super.update(data);
    final PackageElement packageElement = getValue();
    try {
        if (packageElement == null || !packageElement.getPackage().isValid()) {
            setValue(null);
            return;
        }
        int fileCount = getFileCount(packageElement);
        if (fileCount == 0) {
            setValue(null);
            return;
        }
        PsiPackage aPackage = packageElement.getPackage();
        String newName;
        if (getStructure().areFlattenPackages()) {
            newName = aPackage.getQualifiedName();
        } else {
            newName = myPresentationName != null ? myPresentationName : "";
        }
        int nameEndOffset = newName.length();
        int todoItemCount = getTodoItemCount(packageElement);
        newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
        myHighlightedRegions.clear();
        TextAttributes textAttributes = new TextAttributes();
        Color newColor = null;
        if (CopyPasteManager.getInstance().isCutElement(packageElement)) {
            newColor = CopyPasteManager.CUT_COLOR;
        }
        textAttributes.setForegroundColor(newColor);
        myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
        EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
        myHighlightedRegions.add(new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
        data.setPresentableText(newName);
    } catch (IndexNotReadyException e) {
        LOG.info(e);
        data.setPresentableText("N/A");
    }
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) HighlightedRegion(com.intellij.ui.HighlightedRegion) PsiPackage(com.intellij.psi.PsiPackage) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) PackageElement(com.intellij.ide.projectView.impl.nodes.PackageElement)

Example 93 with EditorColorsScheme

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

the class DocumentationComponent method applyFontSize.

private void applyFontSize() {
    Document document = myEditorPane.getDocument();
    if (!(document instanceof StyledDocument)) {
        return;
    }
    final StyledDocument styledDocument = (StyledDocument) document;
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = colorsManager.getGlobalScheme();
    StyleConstants.setFontSize(myFontSizeStyle, JBUI.scale(getQuickDocFontSize().getSize()));
    if (Registry.is("documentation.component.editor.font")) {
        StyleConstants.setFontFamily(myFontSizeStyle, scheme.getEditorFontName());
    }
    ApplicationManager.getApplication().executeOnPooledThread(() -> styledDocument.setCharacterAttributes(0, styledDocument.getLength(), myFontSizeStyle, false));
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) HTMLDocument(javax.swing.text.html.HTMLDocument)

Example 94 with EditorColorsScheme

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

the class LineMarkersPass method createMethodSeparatorLineMarker.

@NotNull
public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) {
    LineMarkerInfo info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
    EditorColorsScheme scheme = colorsManager.getGlobalScheme();
    info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
    info.separatorPlacement = SeparatorPlacement.TOP;
    return info;
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) NotNull(org.jetbrains.annotations.NotNull)

Example 95 with EditorColorsScheme

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

the class BraceHighlightingHandler method highlightBrace.

private void highlightBrace(@NotNull TextRange braceRange, boolean matched) {
    EditorColorsScheme scheme = myEditor.getColorsScheme();
    final TextAttributes attributes = matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES) : scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
    RangeHighlighter rbraceHighlighter = myEditor.getMarkupModel().addRangeHighlighter(braceRange.getStartOffset(), braceRange.getEndOffset(), HighlighterLayer.LAST + 1, attributes, HighlighterTargetArea.EXACT_RANGE);
    rbraceHighlighter.setGreedyToLeft(false);
    rbraceHighlighter.setGreedyToRight(false);
    registerHighlighter(rbraceHighlighter);
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Aggregations

EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)105 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)31 NotNull (org.jetbrains.annotations.NotNull)28 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)17 Nullable (org.jetbrains.annotations.Nullable)15 Document (com.intellij.openapi.editor.Document)14 Project (com.intellij.openapi.project.Project)14 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)12 Editor (com.intellij.openapi.editor.Editor)11 DocumentMarkupModel (com.intellij.openapi.editor.impl.DocumentMarkupModel)10 EditorEx (com.intellij.openapi.editor.ex.EditorEx)8 TextRange (com.intellij.openapi.util.TextRange)8 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)7 PsiFile (com.intellij.psi.PsiFile)7 List (java.util.List)7 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)6 ApplicationManager (com.intellij.openapi.application.ApplicationManager)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 java.awt (java.awt)6 java.util (java.util)6