use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method setupEditorForInjectedLanguage.
private void setupEditorForInjectedLanguage() {
Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, getFile());
if (editor instanceof EditorWindow) {
myFile = ((EditorWindow) editor).getInjectedFile().getViewProvider().getVirtualFile();
myEditor = editor;
}
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method getAvailableIntentions.
@Override
@NotNull
public List<IntentionAction> getAvailableIntentions() {
doHighlighting();
PsiFile file = getFile();
Editor editor = getEditor();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
file = InjectedLanguageUtil.getTopLevelFile(file);
}
assertNotNull(file);
return getAvailableIntentions(editor, file);
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method checkResult.
private void checkResult(@NotNull String expectedFile, boolean stripTrailingSpaces, @NotNull SelectionAndCaretMarkupLoader loader, @NotNull String actualText) {
assertInitialized();
Project project = getProject();
Editor editor = getEditor();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
}
UsefulTestCase.doPostponedFormatting(getProject());
if (stripTrailingSpaces) {
actualText = stripTrailingSpaces(actualText);
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
String newFileText1 = loader.newFileText;
if (stripTrailingSpaces) {
newFileText1 = stripTrailingSpaces(newFileText1);
}
actualText = StringUtil.convertLineSeparators(actualText);
if (!Comparing.equal(newFileText1, actualText)) {
if (loader.filePath != null) {
throw new FileComparisonFailure(expectedFile, newFileText1, actualText, loader.filePath);
} else {
throw new ComparisonFailure(expectedFile, newFileText1, actualText);
}
}
EditorTestUtil.verifyCaretAndSelectionState(editor, loader.caretState, expectedFile);
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class EditorTestUtil method createEditorContext.
@NotNull
private static DataContext createEditorContext(@NotNull Editor editor) {
Object hostEditor = editor instanceof EditorWindow ? ((EditorWindow) editor).getDelegate() : editor;
Map<String, Object> map = ContainerUtil.newHashMap(Pair.create(CommonDataKeys.HOST_EDITOR.getName(), hostEditor), Pair.createNonNull(CommonDataKeys.EDITOR.getName(), editor));
DataContext parent = DataManager.getInstance().getDataContext(editor.getContentComponent());
return SimpleDataContext.getSimpleContext(map, parent);
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CompletionProgressIndicator method stop.
@Override
public void stop() {
super.stop();
myQueue.cancelAllUpdates();
myFreezeSemaphore.up();
myFinishSemaphore.up();
GuiUtils.invokeLaterIfNeeded(() -> {
final CompletionPhase phase = CompletionServiceImpl.getCompletionPhase();
if (!(phase instanceof CompletionPhase.BgCalculation) || phase.indicator != this)
return;
LOG.assertTrue(!getProject().isDisposed(), "project disposed");
if (myEditor.isDisposed()) {
myLookup.hideLookup(false);
CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
return;
}
if (myEditor instanceof EditorWindow) {
LOG.assertTrue(((EditorWindow) myEditor).getInjectedFile().isValid(), "injected file !valid");
LOG.assertTrue(((DocumentWindow) myEditor.getDocument()).isValid(), "docWindow !valid");
}
PsiFile file = myLookup.getPsiFile();
LOG.assertTrue(file == null || file.isValid(), "file !valid");
myLookup.setCalculating(false);
if (myCount == 0) {
myLookup.hideLookup(false);
if (!isAutopopupCompletion()) {
final CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
LOG.assertTrue(current == null, current + "!=" + this);
handleEmptyLookup(!((CompletionPhase.BgCalculation) phase).modifiersChanged);
}
} else {
CompletionServiceImpl.setCompletionPhase(new CompletionPhase.ItemsCalculated(this));
updateLookup();
}
}, myQueue.getModalityState());
}
Aggregations