use of com.android.SdkConstants.ATTR_NAME in project android by JetBrains.
the class StringResourceSafeDeleteProcessorDelegate method getElementsToSearch.
@NotNull
@Override
public Collection<? extends PsiElement> getElementsToSearch(@NotNull PsiElement element, @Nullable Module module, @NotNull Collection<PsiElement> elementsToDelete) {
if (element instanceof XmlTag) {
XmlTag tag = (XmlTag) element;
XmlAttribute attribute = tag.getAttribute(ATTR_NAME);
assert attribute != null;
Collection<PsiElement> elements = new ArrayList<>();
// Find usages of the string element's name attribute value, such as @string/string_name references in XML files
elements.add(attribute.getValueElement());
// R.string.string_name references in Java files that are not LightElements
Collection<PsiField> fields = Arrays.stream(AndroidResourceUtil.findResourceFieldsForValueResource(tag, true)).filter(field -> !(field instanceof LightElement)).collect(Collectors.toList());
elements.addAll(fields);
return elements;
} else if (element instanceof XmlAttributeValue) {
return getElementsToSearch(element.getParent().getParent(), module, elementsToDelete);
} else {
return Collections.emptyList();
}
}
Aggregations