use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class HippieWordCompletionHandler method computeVariants.
private static List<CompletionVariant> computeVariants(@NotNull final Editor editor, CamelHumpMatcher matcher, PsiFile file, boolean includeWordsFromOtherFiles) {
final ArrayList<CompletionVariant> words = new ArrayList<>();
final List<CompletionVariant> afterWords = new ArrayList<>();
if (includeWordsFromOtherFiles) {
for (FileEditor fileEditor : FileEditorManager.getInstance(file.getProject()).getAllEditors()) {
if (fileEditor instanceof TextEditor) {
Editor anotherEditor = ((TextEditor) fileEditor).getEditor();
if (anotherEditor != editor) {
addWordsForEditor((EditorEx) anotherEditor, matcher, words, afterWords, false);
}
}
}
} else {
addWordsForEditor((EditorEx) editor, matcher, words, afterWords, true);
}
Set<String> allWords = new HashSet<>();
List<CompletionVariant> result = new ArrayList<>();
Collections.reverse(words);
for (CompletionVariant variant : words) {
if (!allWords.contains(variant.variant)) {
result.add(variant);
allWords.add(variant.variant);
}
}
Collections.reverse(result);
allWords.clear();
for (CompletionVariant variant : afterWords) {
if (!allWords.contains(variant.variant)) {
result.add(variant);
allWords.add(variant.variant);
}
}
return result;
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class FindUsagesInFileAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null)
return;
PsiDocumentManager.getInstance(project).commitAllDocuments();
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
if (usageTargets != null) {
FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
if (fileEditor != null) {
usageTargets[0].findUsagesInEditor(fileEditor);
}
} else if (editor == null) {
Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
} else {
HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error"));
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class FindUtil method searchBack.
public static void searchBack(Project project, FileEditor fileEditor, @Nullable DataContext dataContext) {
if (!(fileEditor instanceof TextEditor))
return;
TextEditor textEditor = (TextEditor) fileEditor;
Editor editor = textEditor.getEditor();
searchBack(project, editor, dataContext);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class FindUtil method searchAgain.
public static boolean searchAgain(Project project, FileEditor fileEditor, @Nullable DataContext context) {
if (!(fileEditor instanceof TextEditor))
return false;
TextEditor textEditor = (TextEditor) fileEditor;
Editor editor = textEditor.getEditor();
return searchAgain(project, editor, context);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class SearchAgainAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
if (editor == null || project == null)
return;
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(project, () -> {
PsiDocumentManager.getInstance(project).commitAllDocuments();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
FindManager findManager = FindManager.getInstance(project);
if (!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
return;
}
FindUtil.searchAgain(project, editor, e.getDataContext());
}, IdeBundle.message("command.find.next"), null);
}
Aggregations