use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class LightPlatformCodeInsightTestCase method bringRealEditorBack.
protected static void bringRealEditorBack() {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
if (myEditor instanceof EditorWindow) {
Document document = ((DocumentWindow) myEditor.getDocument()).getDelegate();
myFile = PsiDocumentManager.getInstance(getProject()).getPsiFile(document);
myEditor = ((EditorWindow) myEditor).getDelegate();
myVFile = myFile.getVirtualFile();
}
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class LightPlatformCodeInsightTestCase method setupEditorForInjectedLanguage.
private static void setupEditorForInjectedLanguage() {
if (myEditor != null) {
final Ref<EditorWindow> editorWindowRef = new Ref<>();
myEditor.getCaretModel().runForEachCaret(caret -> {
Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile);
if (caret == myEditor.getCaretModel().getPrimaryCaret() && editor instanceof EditorWindow) {
editorWindowRef.set((EditorWindow) editor);
}
});
if (!editorWindowRef.isNull()) {
myEditor = editorWindowRef.get();
myFile = editorWindowRef.get().getInjectedFile();
}
}
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestUtil method doInlineRename.
@TestOnly
public static void doInlineRename(VariableInplaceRenameHandler handler, final String newName, @NotNull Editor editor, PsiElement elementAtCaret) {
Project project = editor.getProject();
TemplateManagerImpl templateManager = (TemplateManagerImpl) TemplateManager.getInstance(project);
try {
templateManager.setTemplateTesting(true);
handler.doRename(elementAtCaret, editor, DataManager.getInstance().getDataContext(editor.getComponent()));
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
}
TemplateState state = TemplateManagerImpl.getTemplateState(editor);
assert state != null;
final TextRange range = state.getCurrentVariableRange();
assert range != null;
final Editor finalEditor = editor;
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
finalEditor.getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), newName);
}
}.execute().throwException();
state = TemplateManagerImpl.getTemplateState(editor);
assert state != null;
state.gotoEnd(false);
} finally {
templateManager.setTemplateTesting(false);
}
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method getElementAtCaret.
@Override
@NotNull
public PsiElement getElementAtCaret() {
assertInitialized();
Editor editor = getCompletionEditor();
int findTargetFlags = TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED;
PsiElement element = TargetElementUtil.findTargetElement(editor, findTargetFlags);
// if no references found in injected fragment, try outer document
if (element == null && editor instanceof EditorWindow) {
element = TargetElementUtil.findTargetElement(((EditorWindow) editor).getDelegate(), findTargetFlags);
}
if (element == null) {
fail("element not found in file " + myFile.getName() + " at caret position offset " + myEditor.getCaretModel().getOffset() + "," + " psi structure:\n" + DebugUtil.psiToString(getFile(), true, true));
}
return element;
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method doHighlighting.
@Override
@NotNull
public List<HighlightInfo> doHighlighting() {
final Project project = getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = getFile();
Editor editor = getEditor();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
file = InjectedLanguageUtil.getTopLevelFile(file);
}
assertNotNull(file);
return instantiateAndRun(file, editor, ArrayUtil.EMPTY_INT_ARRAY, myAllowDirt);
}
Aggregations