Search in sources :

Example 1 with EmptyFindUsagesProvider

use of com.intellij.lang.findUsages.EmptyFindUsagesProvider in project intellij-community by JetBrains.

the class FindUsagesInFileAction method isEnabled.

private static boolean isEnabled(DataContext dataContext) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null || EditorGutter.KEY.getData(dataContext) != null || Boolean.TRUE.equals(dataContext.getData(CommonDataKeys.EDITOR_VIRTUAL_SPACE))) {
        return false;
    }
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (editor == null) {
        UsageTarget[] target = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
        return target != null && target.length > 0;
    } else {
        PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        if (file == null) {
            return false;
        }
        Language language = PsiUtilBase.getLanguageInEditor(editor, project);
        if (language == null) {
            language = file.getLanguage();
        }
        return !(LanguageFindUsages.INSTANCE.forLanguage(language) instanceof EmptyFindUsagesProvider);
    }
}
Also used : Project(com.intellij.openapi.project.Project) Language(com.intellij.lang.Language) PsiFile(com.intellij.psi.PsiFile) EmptyFindUsagesProvider(com.intellij.lang.findUsages.EmptyFindUsagesProvider) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UsageTarget(com.intellij.usages.UsageTarget)

Aggregations

Language (com.intellij.lang.Language)1 EmptyFindUsagesProvider (com.intellij.lang.findUsages.EmptyFindUsagesProvider)1 Editor (com.intellij.openapi.editor.Editor)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1 UsageTarget (com.intellij.usages.UsageTarget)1