Search in sources :

Example 41 with FileEditor

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;
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 42 with FileEditor

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"));
    }
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UsageTarget(com.intellij.usages.UsageTarget)

Example 43 with FileEditor

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);
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 44 with FileEditor

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);
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 45 with FileEditor

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);
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FindManager(com.intellij.find.FindManager) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Aggregations

FileEditor (com.intellij.openapi.fileEditor.FileEditor)157 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 TextEditor (com.intellij.openapi.fileEditor.TextEditor)59 Editor (com.intellij.openapi.editor.Editor)43 Project (com.intellij.openapi.project.Project)40 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)37 Nullable (org.jetbrains.annotations.Nullable)21 DataContext (com.intellij.openapi.actionSystem.DataContext)20 PsiFile (com.intellij.psi.PsiFile)19 Document (com.intellij.openapi.editor.Document)15 NotNull (org.jetbrains.annotations.NotNull)14 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)14 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)10 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)9 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)8 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)7 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)6 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)6 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)6 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)6