use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class DiffSideView method applyHighlighter.
private void applyHighlighter() {
EditorEx editor = myEditorSource.getEditor();
if (editor == null)
return;
EditorHighlighter highlighter = myHighlighterFactory.createHighlighter();
if (highlighter != null)
editor.setHighlighter(highlighter);
editor.getSettings().setCaretRowShown(false);
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class EditorHighlighterCache method getLexerBasedOnLexerHighlighter.
@Nullable
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
EditorHighlighter highlighter = null;
PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
final EditorHighlighter cachedEditorHighlighter;
boolean alreadyInitializedHighlighter = false;
if (document != null && (cachedEditorHighlighter = getEditorHighlighterForCachesBuilding(document)) != null && PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
highlighter = cachedEditorHighlighter;
alreadyInitializedHighlighter = true;
} else if (virtualFile != null) {
highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
}
if (highlighter != null) {
return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
}
return null;
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class EditorHighlighterCache method getEditorHighlighterForCachesBuilding.
@Nullable
public static EditorHighlighter getEditorHighlighterForCachesBuilding(Document document) {
if (document == null) {
return null;
}
final WeakReference<EditorHighlighter> editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter);
final EditorHighlighter someEditorHighlighter = SoftReference.dereference(editorHighlighterWeakReference);
if (someEditorHighlighter instanceof LexerEditorHighlighter && ((LexerEditorHighlighter) someEditorHighlighter).isValid()) {
return someEditorHighlighter;
}
document.putUserData(ourSomeEditorSyntaxHighlighter, null);
return null;
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter in project intellij-community by JetBrains.
the class UnifiedDiffViewer method performRediff.
@Override
@NotNull
protected Runnable performRediff(@NotNull final ProgressIndicator indicator) {
try {
indicator.checkCanceled();
final Document document1 = getContent1().getDocument();
final Document document2 = getContent2().getDocument();
final CharSequence[] texts = ReadAction.compute(() -> {
return new CharSequence[] { document1.getImmutableCharSequence(), document2.getImmutableCharSequence() };
});
final List<LineFragment> fragments = myTextDiffProvider.compare(texts[0], texts[1], indicator);
final DocumentContent content1 = getContent1();
final DocumentContent content2 = getContent2();
indicator.checkCanceled();
TwosideDocumentData data = ReadAction.compute(() -> {
indicator.checkCanceled();
UnifiedFragmentBuilder builder = new UnifiedFragmentBuilder(fragments, document1, document2, myMasterSide);
builder.exec();
indicator.checkCanceled();
EditorHighlighter highlighter = buildHighlighter(myProject, content1, content2, texts[0], texts[1], builder.getRanges(), builder.getText().length());
UnifiedEditorRangeHighlighter rangeHighlighter = new UnifiedEditorRangeHighlighter(myProject, document1, document2, builder.getRanges());
return new TwosideDocumentData(builder, highlighter, rangeHighlighter);
});
UnifiedFragmentBuilder builder = data.getBuilder();
FileType fileType = content2.getContentType() == null ? content1.getContentType() : content2.getContentType();
LineNumberConvertor convertor1 = builder.getConvertor1();
LineNumberConvertor convertor2 = builder.getConvertor2();
List<LineRange> changedLines = builder.getChangedLines();
boolean isContentsEqual = builder.isEqual();
CombinedEditorData editorData = new CombinedEditorData(builder.getText(), data.getHighlighter(), data.getRangeHighlighter(), fileType, convertor1.createConvertor(), convertor2.createConvertor());
return apply(editorData, builder.getBlocks(), convertor1, convertor2, changedLines, isContentsEqual);
} catch (DiffTooBigException e) {
return () -> {
clearDiffPresentation();
myPanel.setTooBigContent();
};
} catch (ProcessCanceledException e) {
throw e;
} catch (Throwable e) {
LOG.error(e);
return () -> {
clearDiffPresentation();
myPanel.setErrorContent();
};
}
}
use of com.intellij.openapi.editor.highlighter.EditorHighlighter 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);
}
Aggregations