use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class MergePanel2 method setHighlighterSettings.
private void setHighlighterSettings(@Nullable EditorColorsScheme settings, @NotNull EditorPlace place) {
if (settings == null) {
settings = EditorColorsManager.getInstance().getGlobalScheme();
}
Editor editor = place.getEditor();
DiffEditorState editorState = place.getState();
if (editor != null) {
((EditorEx) editor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(editorState.getFileType(), settings, editorState.getProject()));
}
}
use of com.intellij.openapi.editor.ex.EditorEx 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);
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-plugins by JetBrains.
the class CfmlTypedHandler method beforeCharTyped.
public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile file, final FileType fileType) {
PsiFile cfmlFile = file.getViewProvider().getPsi(CfmlLanguage.INSTANCE);
if (isNotCfmlFile(cfmlFile, editor)) {
return Result.CONTINUE;
}
int offset = editor.getCaretModel().getOffset();
if (c == '{') {
CfmlBraceMatcher braceMatcher = new CfmlBraceMatcher();
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset);
if (!braceMatcher.isLBraceToken(iterator, editor.getDocument().getCharsSequence(), fileType)) {
EditorModificationUtil.insertStringAtCaret(editor, "}", true, 0);
// return Result.STOP;
}
return Result.CONTINUE;
}
if (c == '#') {
if (ourEnableDoublePoundInsertion && CfmlEditorUtil.countSharpsBalance(editor) == 0) {
char charAtOffset = DocumentUtils.getCharAt(editor.getDocument(), offset);
if (charAtOffset == '#') {
EditorModificationUtil.moveCaretRelatively(editor, 1);
return Result.STOP;
}
EditorModificationUtil.insertStringAtCaret(editor, "#", true, 0);
}
} else if (c == '>') {
if (((EditorEx) editor).getHighlighter().createIterator(editor.getCaretModel().getOffset()).getTokenType() == CfmlTokenTypes.COMMENT || ((EditorEx) editor).getHighlighter().createIterator(editor.getCaretModel().getOffset()).getTokenType().getLanguage() != CfmlLanguage.INSTANCE) {
return Result.CONTINUE;
}
insertCloseTagIfNeeded(editor, cfmlFile, project);
return Result.STOP;
}
return Result.CONTINUE;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-plugins by JetBrains.
the class CfmlTypedHandlerTest method testEditing.
public void testEditing() throws Throwable {
@NonNls final String s1 = "<table bgcolor=\"#FFFFFF\"><cfoutput>\n" + " <div id=\"#bColumn2";
String s2 = "\" />\n" + "</cfoutput></table>";
String s = s1 + s2;
final Document doc = new DocumentImpl(s);
EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(doc);
try {
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), CfmlFileType.INSTANCE);
editor.setHighlighter(highlighter);
CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> doc.insertString(s1.length(), "#")), "", null);
List tokensAfterUpdate = getAllTokens(highlighter);
highlighter = HighlighterFactory.createHighlighter(getProject(), CfmlFileType.INSTANCE);
editor.setHighlighter(highlighter);
List tokensWithoutUpdate = getAllTokens(highlighter);
TestCase.assertEquals(tokensWithoutUpdate, tokensAfterUpdate);
} finally {
EditorFactory.getInstance().releaseEditor(editor);
}
}
use of com.intellij.openapi.editor.ex.EditorEx in project android by JetBrains.
the class AndroidFindUsagesTest method findUsages.
private static Collection<UsageInfo> findUsages(String fileName, final JavaCodeInsightTestFixture fixture, String newFilePath) throws Throwable {
VirtualFile file = fixture.copyFileToProject(BASE_PATH + fileName, newFilePath);
fixture.configureFromExistingVirtualFile(file);
final UsageTarget[] targets = UsageTargetUtil.findUsageTargets(new DataProvider() {
@Override
public Object getData(@NonNls String dataId) {
return ((EditorEx) fixture.getEditor()).getDataContext().getData(dataId);
}
});
assert targets != null && targets.length > 0 && targets[0] instanceof PsiElementUsageTarget;
return fixture.findUsages(((PsiElementUsageTarget) targets[0]).getElement());
}
Aggregations