mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: exclude non code usages inside inlined elements
This commit is contained in:
+7
-1
@@ -105,7 +105,13 @@ public class InlineConstantFieldProcessor extends BaseRefactoringProcessor {
|
||||
usages.add(info);
|
||||
}
|
||||
if (mySearchInCommentsAndStrings || mySearchForTextOccurrences) {
|
||||
TextOccurrencesUtil.UsageInfoFactory nonCodeUsageFactory = new NonCodeUsageInfoFactory(myField, myField.getName());
|
||||
TextOccurrencesUtil.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);
|
||||
|
||||
@@ -131,16 +131,22 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
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, new NonCodeUsageInfoFactory(myMethod, myMethod.getName()));
|
||||
TextOccurrencesUtil.addUsagesInStringsAndComments(myMethod, stringToSearch, usages, infoFactory);
|
||||
}
|
||||
|
||||
if (mySearchForTextOccurrences) {
|
||||
String stringToSearch = ElementDescriptionUtil.getElementDescription(myMethod, NonCodeSearchDescriptionLocation.NON_JAVA);
|
||||
TextOccurrencesUtil
|
||||
.addTextOccurences(myMethod, stringToSearch, GlobalSearchScope.projectScope(myProject), usages, new NonCodeUsageInfoFactory(myMethod, myMethod.getName()));
|
||||
.addTextOccurences(myMethod, stringToSearch, GlobalSearchScope.projectScope(myProject), usages, infoFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user