Search in sources :

Example 6 with UsageInfoFactory

use of com.intellij.usageView.UsageInfoFactory in project intellij-community by JetBrains.

the class RenameUtil method addTextOccurrence.

private static void addTextOccurrence(final PsiElement element, final List<UsageInfo> result, final GlobalSearchScope projectScope, final String stringToSearch, final String stringToReplace) {
    UsageInfoFactory factory = new UsageInfoFactory() {

        @Override
        public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
            TextRange textRange = usage.getTextRange();
            int start = textRange == null ? 0 : textRange.getStartOffset();
            return NonCodeUsageInfo.create(usage.getContainingFile(), start + startOffset, start + endOffset, element, stringToReplace);
        }
    };
    TextOccurrencesUtil.addTextOccurences(element, stringToSearch, projectScope, result, factory);
}
Also used : UsageInfoFactory(com.intellij.usageView.UsageInfoFactory) NotNull(org.jetbrains.annotations.NotNull) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement)

Aggregations

UsageInfoFactory (com.intellij.usageView.UsageInfoFactory)6 NotNull (org.jetbrains.annotations.NotNull)5 UsageInfo (com.intellij.usageView.UsageInfo)3 PomTargetPsiElement (com.intellij.pom.PomTargetPsiElement)2 TextRange (com.intellij.openapi.util.TextRange)1 PsiCompiledElement (com.intellij.psi.PsiCompiledElement)1 PsiElement (com.intellij.psi.PsiElement)1 PsiReference (com.intellij.psi.PsiReference)1 PsiReferenceService (com.intellij.psi.PsiReferenceService)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 NonCodeUsageInfoFactory (com.intellij.refactoring.rename.NonCodeUsageInfoFactory)1 SafeDeleteReferenceSimpleDeleteUsageInfo (com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo)1