Search in sources :

Example 1 with SafeDeleteReferenceSimpleDeleteUsageInfo

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

the class SafeDeleteProcessor method addNonCodeUsages.

public static void addNonCodeUsages(final PsiElement element, List<UsageInfo> usages, @Nullable final Condition<PsiElement> insideElements, boolean searchNonJava, boolean searchInCommentsAndStrings) {
    UsageInfoFactory nonCodeUsageFactory = new UsageInfoFactory() {

        @Override
        public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
            if (insideElements != null && insideElements.value(usage)) {
                return null;
            }
            return new SafeDeleteReferenceSimpleDeleteUsageInfo(usage, element, startOffset, endOffset, true, false);
        }
    };
    if (searchInCommentsAndStrings) {
        String stringToSearch = ElementDescriptionUtil.getElementDescription(element, NonCodeSearchDescriptionLocation.STRINGS_AND_COMMENTS);
        TextOccurrencesUtil.addUsagesInStringsAndComments(element, stringToSearch, usages, nonCodeUsageFactory);
    }
    if (searchNonJava) {
        String stringToSearch = ElementDescriptionUtil.getElementDescription(element, NonCodeSearchDescriptionLocation.NON_JAVA);
        TextOccurrencesUtil.addTextOccurences(element, stringToSearch, GlobalSearchScope.projectScope(element.getProject()), usages, nonCodeUsageFactory);
    }
}
Also used : SafeDeleteReferenceSimpleDeleteUsageInfo(com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo) UsageInfoFactory(com.intellij.usageView.UsageInfoFactory) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SafeDeleteReferenceSimpleDeleteUsageInfo (com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo)1 UsageInfoFactory (com.intellij.usageView.UsageInfoFactory)1 NotNull (org.jetbrains.annotations.NotNull)1