use of com.intellij.refactoring.rename.NonCodeUsageInfoFactory in project intellij-community by JetBrains.
the class InlineToAnonymousClassProcessor method findUsages.
@NotNull
protected UsageInfo[] findUsages() {
if (myInlineThisOnly) {
return new UsageInfo[] { new UsageInfo(myCallToInline) };
}
Set<UsageInfo> usages = new HashSet<>();
final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject);
for (PsiReference reference : ReferencesSearch.search(myClass, searchScope)) {
usages.add(new UsageInfo(reference.getElement()));
}
final String qName = myClass.getQualifiedName();
if (qName != null) {
List<UsageInfo> nonCodeUsages = new ArrayList<>();
if (mySearchInComments) {
TextOccurrencesUtil.addUsagesInStringsAndComments(myClass, qName, nonCodeUsages, new NonCodeUsageInfoFactory(myClass, qName));
}
if (mySearchInNonJavaFiles) {
TextOccurrencesUtil.addTextOccurences(myClass, qName, searchScope, nonCodeUsages, new NonCodeUsageInfoFactory(myClass, qName));
}
usages.addAll(nonCodeUsages);
}
return usages.toArray(new UsageInfo[usages.size()]);
}
use of com.intellij.refactoring.rename.NonCodeUsageInfoFactory in project intellij-community by JetBrains.
the class InlineMethodProcessor method findUsages.
@NotNull
protected UsageInfo[] findUsages() {
if (myInlineThisOnly)
return new UsageInfo[] { new UsageInfo(myReference) };
Set<UsageInfo> usages = new HashSet<>();
if (myReference != null) {
usages.add(new UsageInfo(myReference));
}
GlobalSearchScope searchScope = GlobalSearchScope.projectScope(myProject);
for (PsiReference reference : ReferencesSearch.search(myMethod, searchScope)) {
usages.add(new UsageInfo(reference.getElement()));
}
OverridingMethodsSearch.search(myMethod, searchScope, false).forEach(method -> {
if (AnnotationUtil.isAnnotated(method, Override.class.getName(), false)) {
usages.add(new UsageInfo(method));
}
return true;
});
if (mySearchInComments || mySearchForTextOccurrences) {
final NonCodeUsageInfoFactory infoFactory = new NonCodeUsageInfoFactory(myMethod, myMethod.getName()) {
@Override
public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
if (PsiTreeUtil.isAncestor(myMethod, usage, false))
return null;
return super.createUsageInfo(usage, startOffset, endOffset);
}
};
if (mySearchInComments) {
String stringToSearch = ElementDescriptionUtil.getElementDescription(myMethod, NonCodeSearchDescriptionLocation.STRINGS_AND_COMMENTS);
TextOccurrencesUtil.addUsagesInStringsAndComments(myMethod, stringToSearch, usages, infoFactory);
}
if (mySearchForTextOccurrences) {
String stringToSearch = ElementDescriptionUtil.getElementDescription(myMethod, NonCodeSearchDescriptionLocation.NON_JAVA);
TextOccurrencesUtil.addTextOccurences(myMethod, stringToSearch, searchScope, usages, infoFactory);
}
}
return usages.toArray(new UsageInfo[usages.size()]);
}
use of com.intellij.refactoring.rename.NonCodeUsageInfoFactory in project intellij-community by JetBrains.
the class InlineConstantFieldProcessor method findUsages.
@Override
@NotNull
protected UsageInfo[] findUsages() {
if (myInlineThisOnly)
return new UsageInfo[] { new UsageInfo(myRefExpr) };
List<UsageInfo> usages = new ArrayList<>();
for (PsiReference ref : ReferencesSearch.search(myField, GlobalSearchScope.projectScope(myProject), false)) {
PsiElement element = ref.getElement();
UsageInfo info = new UsageInfo(element);
if (!(element instanceof PsiExpression) && PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class) == null) {
info = new UsageFromJavaDoc(element);
}
usages.add(info);
}
if (mySearchInCommentsAndStrings || mySearchForTextOccurrences) {
UsageInfoFactory nonCodeUsageFactory = new NonCodeUsageInfoFactory(myField, myField.getName()) {
@Override
public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
if (PsiTreeUtil.isAncestor(myField, usage, false))
return null;
return super.createUsageInfo(usage, startOffset, endOffset);
}
};
if (mySearchInCommentsAndStrings) {
String stringToSearch = ElementDescriptionUtil.getElementDescription(myField, NonCodeSearchDescriptionLocation.STRINGS_AND_COMMENTS);
TextOccurrencesUtil.addUsagesInStringsAndComments(myField, stringToSearch, usages, nonCodeUsageFactory);
}
if (mySearchForTextOccurrences) {
String stringToSearch = ElementDescriptionUtil.getElementDescription(myField, NonCodeSearchDescriptionLocation.NON_JAVA);
TextOccurrencesUtil.addTextOccurences(myField, stringToSearch, GlobalSearchScope.projectScope(myProject), usages, nonCodeUsageFactory);
}
}
return usages.toArray(new UsageInfo[usages.size()]);
}
Aggregations