Search in sources :

Example 31 with EditorColorsScheme

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

the class TextEditorImpl method loadEditorInBackground.

@NotNull
protected Runnable loadEditorInBackground() {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, scheme, myProject);
    EditorEx editor = (EditorEx) getEditor();
    highlighter.setText(editor.getDocument().getImmutableCharSequence());
    return () -> editor.setHighlighter(highlighter);
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter) BackgroundEditorHighlighter(com.intellij.codeHighlighting.BackgroundEditorHighlighter) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with EditorColorsScheme

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

the class IterationStateTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
    DEFAULT_BACKGROUND = colorsScheme.getDefaultBackground();
    CARET_ROW_BACKGROUND = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR);
    SELECTION_BACKGROUND = colorsScheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR);
    assertEquals(3, new HashSet<>(Arrays.asList(DEFAULT_BACKGROUND, CARET_ROW_BACKGROUND, SELECTION_BACKGROUND)).size());
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) HashSet(java.util.HashSet)

Example 33 with EditorColorsScheme

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

the class DartMethodLineMarkerProvider method getLineMarkerInfo.

@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
    if (!myDaemonSettings.SHOW_METHOD_SEPARATORS) {
        return null;
    }
    // only continue if element is one of the markable elements (such as methods)
    if (isMarkableElement(element)) {
        // the method line markers are not nestable, aka, methods inside of methods, are not marked
        if (PsiTreeUtil.findFirstParent(element, true, DartMethodLineMarkerProvider::isMarkableElement) != null) {
            return null;
        }
        // move the marker to previous siblings until comments have been included
        PsiElement markerLocation = element;
        while (markerLocation.getPrevSibling() != null && (markerLocation.getPrevSibling() instanceof PsiComment || (markerLocation.getPrevSibling() instanceof PsiWhiteSpace && markerLocation.getPrevSibling().getPrevSibling() != null && markerLocation.getPrevSibling().getPrevSibling() instanceof PsiComment))) {
            markerLocation = markerLocation.getPrevSibling();
        }
        // if the markerLocation element doesn't have a previous sibling (not whitespace), do not mark
        PsiElement prevElement = markerLocation;
        while (prevElement.getPrevSibling() != null && prevElement.getPrevSibling() instanceof PsiWhiteSpace) {
            prevElement = prevElement.getPrevSibling();
        }
        if (prevElement.getPrevSibling() == null) {
            return null;
        }
        // finally, create the marker
        LineMarkerInfo info = new LineMarkerInfo<>(markerLocation, markerLocation.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 : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) PsiComment(com.intellij.psi.PsiComment) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) PsiElement(com.intellij.psi.PsiElement) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace) Nullable(org.jetbrains.annotations.Nullable)

Example 34 with EditorColorsScheme

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

the class CodeStyleAbstractPanel method updatePreviewHighlighter.

private void updatePreviewHighlighter(final EditorEx editor) {
    EditorColorsScheme scheme = editor.getColorsScheme();
    editor.getSettings().setCaretRowShown(false);
    editor.setHighlighter(createHighlighter(scheme));
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 35 with EditorColorsScheme

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

the class DefaultHighlightInfoProcessor method highlightsOutsideVisiblePartAreProduced.

@Override
public void highlightsOutsideVisiblePartAreProduced(@NotNull final HighlightingSession session, @NotNull final List<HighlightInfo> infos, @NotNull final TextRange priorityRange, @NotNull final TextRange restrictedRange, final int groupId) {
    final PsiFile psiFile = session.getPsiFile();
    final Project project = psiFile.getProject();
    final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
    if (document == null)
        return;
    final long modificationStamp = document.getModificationStamp();
    ((HighlightingSessionImpl) session).applyInEDT(() -> {
        if (project.isDisposed() || modificationStamp != document.getModificationStamp())
            return;
        EditorColorsScheme scheme = session.getColorsScheme();
        UpdateHighlightersUtil.setHighlightersOutsideRange(project, document, psiFile, infos, scheme, restrictedRange.getStartOffset(), restrictedRange.getEndOffset(), ProperTextRange.create(priorityRange), groupId);
        Editor editor = session.getEditor();
        if (editor != null) {
            DaemonListeners.repaintErrorStripeRenderer(editor, project);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Document(com.intellij.openapi.editor.Document) Editor(com.intellij.openapi.editor.Editor)

Aggregations

EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)103 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