use of com.intellij.injected.editor.EditorWindow in project intellij-plugins by JetBrains.
the class FlexIntroduceConstantTest method doTest.
private void doTest(final JSIntroduceConstantHandler handler, String fileName, String ext) throws Exception {
configureByFile(fileName + "." + ext);
Editor injectedEditor = BaseCodeInsightAction.getInjectedEditor(myProject, myEditor);
if (injectedEditor != null) {
myEditor = injectedEditor;
myFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
}
handler.invoke(getProject(), getEditor(), getFile(), null);
if (injectedEditor instanceof EditorWindow) {
myEditor = ((EditorWindow) injectedEditor).getDelegate();
myFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
}
checkResultByFile(fileName + "_after." + ext);
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class ShowIntentionActionsHandler method invoke.
@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (editor instanceof EditorWindow) {
editor = ((EditorWindow) editor).getDelegate();
file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
}
final LookupEx lookup = LookupManager.getActiveLookup(editor);
if (lookup != null) {
lookup.showElementActions();
return;
}
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project);
letAutoImportComplete(editor, file, codeAnalyzer);
ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
IntentionHintComponent hintComponent = codeAnalyzer.getLastIntentionHint();
if (hintComponent != null) {
IntentionHintComponent.PopupUpdateResult result = hintComponent.isForEditor(editor) ? hintComponent.updateActions(intentions) : IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE;
if (result == IntentionHintComponent.PopupUpdateResult.HIDE_AND_RECREATE) {
hintComponent.hide();
}
}
if (HintManagerImpl.getInstanceImpl().performCurrentQuestionAction())
return;
//intentions check isWritable before modification: if (!file.isWritable()) return;
TemplateState state = TemplateManagerImpl.getTemplateState(editor);
if (state != null && !state.isFinished()) {
return;
}
if (!intentions.isEmpty()) {
IntentionHintComponent.showIntentionHint(project, file, editor, intentions, true);
}
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class ParameterInfoController method showHint.
public void showHint(boolean requestFocus) {
Pair<Point, Short> pos = myProvider.getBestPointPosition(myHint, myComponent.getParameterOwner(), myLbraceMarker.getStartOffset(), true, HintManager.UNDER);
HintHint hintHint = HintManagerImpl.createHintHint(myEditor, pos.getFirst(), myHint, pos.getSecond());
hintHint.setExplicitClose(true);
hintHint.setRequestFocus(requestFocus);
Editor editorToShow = myEditor instanceof EditorWindow ? ((EditorWindow) myEditor).getDelegate() : myEditor;
// is case of injection we need to calculate position for EditorWindow
// also we need to show the hint in the main editor because of intention bulb
HintManagerImpl.getInstanceImpl().showEditorHint(myHint, editorToShow, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
updateComponent();
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class HighlightUsagesHandler method isClearHighlights.
public static boolean isClearHighlights(@NotNull Editor editor) {
if (editor instanceof EditorWindow)
editor = ((EditorWindow) editor).getDelegate();
RangeHighlighter[] highlighters = ((HighlightManagerImpl) HighlightManager.getInstance(editor.getProject())).getHighlighters(editor);
int caretOffset = editor.getCaretModel().getOffset();
for (RangeHighlighter highlighter : highlighters) {
if (TextRange.create(highlighter).grown(1).contains(caretOffset)) {
return true;
}
}
return false;
}
use of com.intellij.injected.editor.EditorWindow in project intellij-community by JetBrains.
the class HighlightUsagesHandler method doRangeHighlighting.
private static void doRangeHighlighting(Editor editor, Project project) {
if (!editor.getSelectionModel().hasSelection())
return;
final String text = editor.getSelectionModel().getSelectedText();
if (text == null)
return;
if (editor instanceof EditorWindow) {
// highlight selection in the whole editor, not injected fragment only
editor = ((EditorWindow) editor).getDelegate();
}
EditorSearchSession oldSearch = EditorSearchSession.get(editor);
if (oldSearch != null) {
if (oldSearch.hasMatches()) {
String oldText = oldSearch.getTextInField();
if (!oldSearch.getFindModel().isRegularExpressions()) {
oldText = StringUtil.escapeToRegexp(oldText);
oldSearch.getFindModel().setRegularExpressions(true);
}
String newText = oldText + '|' + StringUtil.escapeToRegexp(text);
oldSearch.setTextInField(newText);
return;
}
}
EditorSearchSession.start(editor, project).getFindModel().setRegularExpressions(false);
}
Aggregations