Search in sources :

Example 1 with NonCodeUsageSearchInfo

use of com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo in project intellij-community by JetBrains.

the class PropertiesFilesSafeDeleteProcessor method findUsages.

@Override
public NonCodeUsageSearchInfo findUsages(@NotNull final PsiElement element, @NotNull final PsiElement[] allElementsToDelete, @NotNull final List<UsageInfo> result) {
    PropertiesFile file = (PropertiesFile) element;
    List<PsiElement> elements = new ArrayList<>();
    elements.add(file.getContainingFile());
    for (IProperty property : file.getProperties()) {
        elements.add(property.getPsiElement());
    }
    for (PsiElement psiElement : elements) {
        SafeDeleteProcessor.findGenericElementUsages(psiElement, result, allElementsToDelete);
    }
    return new NonCodeUsageSearchInfo(SafeDeleteProcessor.getDefaultInsideDeletedCondition(allElementsToDelete), elements);
}
Also used : IProperty(com.intellij.lang.properties.IProperty) ArrayList(java.util.ArrayList) NonCodeUsageSearchInfo(com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) PsiElement(com.intellij.psi.PsiElement)

Example 2 with NonCodeUsageSearchInfo

use of com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo in project android by JetBrains.

the class AndroidComponentSafeDeleteProcessor method findUsages.

@Override
public NonCodeUsageSearchInfo findUsages(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete, @NotNull List<UsageInfo> result) {
    final ArrayList<UsageInfo> usages = new ArrayList<UsageInfo>();
    final NonCodeUsageSearchInfo info = getBaseHandler().findUsages(element, allElementsToDelete, usages);
    if (info == null) {
        return info;
    }
    assert element instanceof PsiClass;
    final PsiClass componentClass = (PsiClass) element;
    final AndroidAttributeValue<PsiClass> declaration = AndroidDomUtil.findComponentDeclarationInManifest(componentClass);
    if (declaration == null) {
        return info;
    }
    final XmlAttributeValue declarationAttributeValue = declaration.getXmlAttributeValue();
    for (UsageInfo usage : usages) {
        if (declarationAttributeValue != usage.getElement()) {
            result.add(usage);
        }
    }
    return info;
}
Also used : ArrayList(java.util.ArrayList) PsiClass(com.intellij.psi.PsiClass) NonCodeUsageSearchInfo(com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) UsageInfo(com.intellij.usageView.UsageInfo)

Example 3 with NonCodeUsageSearchInfo

use of com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo in project intellij by bazelbuild.

the class BuildFileSafeDeleteProcessor method findUsages.

/**
 * Delegates to JavaSafeDeleteProcessor, then removes indirect glob references which we don't want
 * to block safe delete.
 */
@Nullable
@Override
public NonCodeUsageSearchInfo findUsages(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete, @NotNull List<UsageInfo> result) {
    NonCodeUsageSearchInfo superResult = super.findUsages(element, allElementsToDelete, result);
    result.removeIf(BuildFileSafeDeleteProcessor::ignoreUsage);
    return superResult;
}
Also used : NonCodeUsageSearchInfo(com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo) Nullable(javax.annotation.Nullable)

Aggregations

NonCodeUsageSearchInfo (com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo)3 ArrayList (java.util.ArrayList)2 IProperty (com.intellij.lang.properties.IProperty)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 UsageInfo (com.intellij.usageView.UsageInfo)1 Nullable (javax.annotation.Nullable)1