Search in sources :

Example 11 with PsiElementUsage

use of com.intellij.usages.rules.PsiElementUsage in project intellij-community by JetBrains.

the class PyImportFilteringRule method isVisible.

@Override
public boolean isVisible(@NotNull Usage usage) {
    if (usage instanceof PsiElementUsage) {
        final PsiElement psiElement = ((PsiElementUsage) usage).getElement();
        final PsiFile containingFile = psiElement.getContainingFile();
        if (containingFile instanceof PyFile) {
            // check whether the element is in the import list
            final PyImportStatementBase importStatement = PsiTreeUtil.getParentOfType(psiElement, PyImportStatementBase.class, true);
            return importStatement == null;
        }
    }
    return true;
}
Also used : PsiFile(com.intellij.psi.PsiFile) PyImportStatementBase(com.jetbrains.python.psi.PyImportStatementBase) PyFile(com.jetbrains.python.psi.PyFile) PsiElement(com.intellij.psi.PsiElement) PsiElementUsage(com.intellij.usages.rules.PsiElementUsage)

Aggregations

PsiElementUsage (com.intellij.usages.rules.PsiElementUsage)11 PsiElement (com.intellij.psi.PsiElement)8 PsiFile (com.intellij.psi.PsiFile)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 NotNull (org.jetbrains.annotations.NotNull)3 UsageInfo (com.intellij.usageView.UsageInfo)2 Usage (com.intellij.usages.Usage)2 CustomUsageSearcher (com.intellij.find.findUsages.CustomUsageSearcher)1 FindUsagesOptions (com.intellij.find.findUsages.FindUsagesOptions)1 FavoritesManager (com.intellij.ide.favoritesTreeView.FavoritesManager)1 AbstractUrl (com.intellij.ide.projectView.impl.AbstractUrl)1 InjectedLanguageManager (com.intellij.lang.injection.InjectedLanguageManager)1 JSImportStatement (com.intellij.lang.javascript.psi.ecmal4.JSImportStatement)1 Editor (com.intellij.openapi.editor.Editor)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 Project (com.intellij.openapi.project.Project)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)1 MoveRenameUsageInfo (com.intellij.refactoring.util.MoveRenameUsageInfo)1