use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testLightBulbIsHiddenWhenFixRangeIsCollapsed.
public void testLightBulbIsHiddenWhenFixRangeIsCollapsed() {
configureByText(StdFileTypes.JAVA, "class S { void foo() { boolean var; if (<selection>va<caret>r</selection>) {}} }");
((EditorImpl) myEditor).getScrollPane().getViewport().setSize(1000, 1000);
final Set<LightweightHint> visibleHints = ContainerUtil.newIdentityTroveSet();
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, new EditorHintListener() {
@Override
public void hintShown(final Project project, final LightweightHint hint, final int flags) {
visibleHints.add(hint);
hint.addHintListener(new HintListener() {
@Override
public void hintHidden(EventObject event) {
visibleHints.remove(hint);
hint.removeHintListener(this);
}
});
}
});
highlightErrors();
IntentionHintComponent lastHintBeforeDeletion = myDaemonCodeAnalyzer.getLastIntentionHint();
assertNotNull(lastHintBeforeDeletion);
delete(myEditor);
highlightErrors();
IntentionHintComponent lastHintAfterDeletion = myDaemonCodeAnalyzer.getLastIntentionHint();
assertSame(lastHintBeforeDeletion, lastHintAfterDeletion);
assertEmpty(visibleHints);
}
use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testBulbAppearsAfterType.
public void testBulbAppearsAfterType() throws Throwable {
String text = "class S { ArrayList<caret>XXX x;}";
configureByText(StdFileTypes.JAVA, text);
((EditorImpl) myEditor).getScrollPane().getViewport().setSize(1000, 1000);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
final Set<LightweightHint> shown = ContainerUtil.newIdentityTroveSet();
getProject().getMessageBus().connect().subscribe(EditorHintListener.TOPIC, (project, hint, flags) -> {
shown.add(hint);
hint.addHintListener(event -> shown.remove(hint));
});
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject());
highlightErrors();
IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
assertNotNull(hintComponent);
assertFalse(hintComponent.isDisposed());
assertNotNull(hintComponent.getComponentHint());
assertTrue(shown.contains(hintComponent.getComponentHint()));
type("x");
highlightErrors();
hintComponent = codeAnalyzer.getLastIntentionHint();
assertNotNull(hintComponent);
assertFalse(hintComponent.isDisposed());
assertNotNull(hintComponent.getComponentHint());
assertTrue(shown.contains(hintComponent.getComponentHint()));
}
use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.
the class EditorPaintingPerformanceTest method doTestScrollingPerformance.
private static void doTestScrollingPerformance(String message, int expectedMs) {
EditorImpl editor = (EditorImpl) myEditor;
int editorHeight = editor.getPreferredHeight();
int[] result = { 0 };
PlatformTestUtil.startPerformanceTest(message, expectedMs, () -> {
for (int y = 0; y < editorHeight; y += 1000) {
Rectangle clip = new Rectangle(0, y, EDITOR_WIDTH_PX, 1000);
NullGraphics2D g = new NullGraphics2D(clip);
editor.getContentComponent().paintComponent(g);
result[0] += g.getResult();
}
}).cpuBound().assertTiming();
System.out.println(result[0]);
}
use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.
the class LanguagePanel method updateHighlighters.
void updateHighlighters() {
final EditorImpl editor = ((EditorImpl) myPrefix.getEditor());
if (editor == null)
return;
final EditorImpl editor2 = ((EditorImpl) mySuffix.getEditor());
assert editor2 != null;
final Language language = InjectedLanguage.findLanguageById(getLanguage());
if (language == null) {
editor.setHighlighter(new LexerEditorHighlighter(new PlainSyntaxHighlighter(), editor.getColorsScheme()));
editor2.setHighlighter(new LexerEditorHighlighter(new PlainSyntaxHighlighter(), editor.getColorsScheme()));
} else {
final SyntaxHighlighter s1 = SyntaxHighlighterFactory.getSyntaxHighlighter(language, myProject, null);
final SyntaxHighlighter s2 = SyntaxHighlighterFactory.getSyntaxHighlighter(language, myProject, null);
editor.setHighlighter(new LexerEditorHighlighter(s1, editor.getColorsScheme()));
editor2.setHighlighter(new LexerEditorHighlighter(s2, editor2.getColorsScheme()));
}
}
use of com.intellij.openapi.editor.impl.EditorImpl in project intellij-community by JetBrains.
the class TextEditorComponent method createEditor.
@NotNull
private Editor createEditor() {
Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
((EditorEx) editor).getGutterComponentEx().setForceShowRightFreePaintersArea(true);
((EditorEx) editor).setFile(myFile);
((EditorEx) editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);
((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));
TextEditorProvider.putTextEditor(editor, myTextEditor);
return editor;
}
Aggregations