Search in sources :

Example 1 with FileEditorLocation

use of com.intellij.openapi.fileEditor.FileEditorLocation in project intellij-community by JetBrains.

the class FindUsagesManager method findUsagesInEditor.

private void findUsagesInEditor(@NotNull final PsiElement[] primaryElements, @NotNull final PsiElement[] secondaryElements, @NotNull FindUsagesHandler handler, @NotNull PsiFile scopeFile, @NotNull FileSearchScope direction, @NotNull final FindUsagesOptions findUsagesOptions, @NotNull FileEditor fileEditor) {
    initLastSearchElement(findUsagesOptions, primaryElements, secondaryElements);
    clearStatusBar();
    final FileEditorLocation currentLocation = fileEditor.getCurrentLocation();
    PsiElement2UsageTargetAdapter[] primaryTargets = PsiElement2UsageTargetAdapter.convert(primaryElements);
    PsiElement2UsageTargetAdapter[] secondaryTargets = PsiElement2UsageTargetAdapter.convert(primaryElements);
    final UsageSearcher usageSearcher = createUsageSearcher(primaryTargets, secondaryTargets, handler, findUsagesOptions, scopeFile);
    AtomicBoolean usagesWereFound = new AtomicBoolean();
    Usage fUsage = findSiblingUsage(usageSearcher, direction, currentLocation, usagesWereFound, fileEditor);
    if (fUsage != null) {
        fUsage.navigate(true);
        fUsage.selectInEditor();
    } else if (!usagesWereFound.get()) {
        String message = getNoUsagesFoundMessage(primaryElements[0]) + " in " + scopeFile.getName();
        showHintOrStatusBarMessage(message, fileEditor);
    } else {
        fileEditor.putUserData(KEY_START_USAGE_AGAIN, VALUE_START_USAGE_AGAIN);
        showHintOrStatusBarMessage(getSearchAgainMessage(primaryElements[0], direction), fileEditor);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FileEditorLocation(com.intellij.openapi.fileEditor.FileEditorLocation)

Example 2 with FileEditorLocation

use of com.intellij.openapi.fileEditor.FileEditorLocation in project intellij-community by JetBrains.

the class ShowUsagesAction method getEditorFor.

@Nullable
private static Editor getEditorFor(@NotNull Usage usage) {
    FileEditorLocation location = usage.getLocation();
    FileEditor newFileEditor = location == null ? null : location.getEditor();
    return newFileEditor instanceof TextEditor ? ((TextEditor) newFileEditor).getEditor() : null;
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditorLocation(com.intellij.openapi.fileEditor.FileEditorLocation) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileEditorLocation (com.intellij.openapi.fileEditor.FileEditorLocation)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Nullable (org.jetbrains.annotations.Nullable)1