use of com.android.tools.idea.res.DynamicResourceValueItem in project android by JetBrains.
the class AndroidResourceReferenceBase method resolveInner.
@NotNull
private ResolveResult[] resolveInner() {
final List<PsiElement> elements = new ArrayList<>();
final boolean attrReference = myResourceValue.getPrefix() == '?';
collectTargets(myFacet, myResourceValue, elements, attrReference);
final List<ResolveResult> result = new ArrayList<>();
if (elements.isEmpty() && myResourceValue.getResourceName() != null && !AndroidUtils.SYSTEM_RESOURCE_PACKAGE.equals(myResourceValue.getNamespace())) {
// Dynamic items do not appear in the XML scanning file index; look for
// these in the resource repositories.
LocalResourceRepository resources = AppResourceRepository.getAppResources(myFacet.getModule(), true);
ResourceType resourceType = myResourceValue.getType();
if (resourceType != null && (resourceType != ResourceType.ATTR || attrReference)) {
// If not, it could be some broken source, such as @android/test
assert resources != null;
List<ResourceItem> items = resources.getResourceItem(resourceType, myResourceValue.getResourceName());
if (items != null && FolderTypeRelationship.getRelatedFolders(resourceType).contains(ResourceFolderType.VALUES)) {
for (ResourceItem item : items) {
XmlTag tag = LocalResourceRepository.getItemTag(myFacet.getModule().getProject(), item);
if (tag != null) {
elements.add(tag);
} else if (item instanceof DynamicResourceValueItem) {
result.add(((DynamicResourceValueItem) item).createResolveResult());
}
}
}
}
}
if (elements.size() > 1) {
Collections.sort(elements, AndroidResourceUtil.RESOURCE_ELEMENT_COMPARATOR);
}
for (PsiElement target : elements) {
result.add(new PsiElementResolveResult(target));
}
return result.toArray(new ResolveResult[result.size()]);
}
Aggregations