Search in sources :

Example 1 with EditorHighlighterFactory

use of com.intellij.openapi.editor.highlighter.EditorHighlighterFactory in project intellij-community by JetBrains.

the class DiffUtil method createEditorHighlighter.

@Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @NotNull DocumentContent content) {
    FileType type = content.getContentType();
    VirtualFile file = content.getHighlightFile();
    Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);
    EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
    if (language != null) {
        SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
        return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
    }
    if (file != null && file.isValid()) {
        if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
            return highlighterFactory.createEditorHighlighter(project, file);
        }
    }
    if (type != null) {
        return highlighterFactory.createEditorHighlighter(project, type);
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Language(com.intellij.lang.Language) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) SyntaxHighlighter(com.intellij.openapi.fileTypes.SyntaxHighlighter) EditorHighlighterFactory(com.intellij.openapi.editor.highlighter.EditorHighlighterFactory)

Example 2 with EditorHighlighterFactory

use of com.intellij.openapi.editor.highlighter.EditorHighlighterFactory in project intellij-community by JetBrains.

the class LineStatusMarkerPopup method createEditorComponent.

@Nullable
private EditorFragmentComponent createEditorComponent(@Nullable FileType fileType, @Nullable List<DiffFragment> wordDiff) {
    if (myRange.getType() == Range.INSERTED)
        return null;
    EditorEx uEditor = (EditorEx) EditorFactory.getInstance().createViewer(myTracker.getVcsDocument(), myTracker.getProject());
    uEditor.setColorsScheme(myEditor.getColorsScheme());
    DiffUtil.setEditorCodeStyle(myTracker.getProject(), uEditor, fileType);
    EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
    uEditor.setHighlighter(highlighterFactory.createEditorHighlighter(myTracker.getProject(), getFileName(myTracker.getDocument())));
    if (wordDiff != null) {
        int vcsStartShift = myTracker.getVcsTextRange(myRange).getStartOffset();
        for (DiffFragment fragment : wordDiff) {
            int vcsStart = vcsStartShift + fragment.getStartOffset1();
            int vcsEnd = vcsStartShift + fragment.getEndOffset1();
            TextDiffType type = getDiffType(fragment);
            DiffDrawUtil.createInlineHighlighter(uEditor, vcsStart, vcsEnd, type);
        }
    }
    EditorFragmentComponent fragmentComponent = EditorFragmentComponent.createEditorFragmentComponent(myEditor.getContentComponent(), uEditor, myRange.getVcsLine1(), myRange.getVcsLine2(), false, false);
    EditorFactory.getInstance().releaseEditor(uEditor);
    return fragmentComponent;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) DiffFragment(com.intellij.diff.fragments.DiffFragment) EditorFragmentComponent(com.intellij.codeInsight.hint.EditorFragmentComponent) TextDiffType(com.intellij.diff.util.TextDiffType) EditorHighlighterFactory(com.intellij.openapi.editor.highlighter.EditorHighlighterFactory) HintHint(com.intellij.ui.HintHint) LightweightHint(com.intellij.ui.LightweightHint) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

EditorHighlighterFactory (com.intellij.openapi.editor.highlighter.EditorHighlighterFactory)2 EditorFragmentComponent (com.intellij.codeInsight.hint.EditorFragmentComponent)1 DiffFragment (com.intellij.diff.fragments.DiffFragment)1 TextDiffType (com.intellij.diff.util.TextDiffType)1 Language (com.intellij.lang.Language)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 FileType (com.intellij.openapi.fileTypes.FileType)1 PlainTextFileType (com.intellij.openapi.fileTypes.PlainTextFileType)1 SyntaxHighlighter (com.intellij.openapi.fileTypes.SyntaxHighlighter)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 HintHint (com.intellij.ui.HintHint)1 LightweightHint (com.intellij.ui.LightweightHint)1 Nullable (org.jetbrains.annotations.Nullable)1