use of org.jetbrains.android.dom.converters.AndroidResourceReferenceBase in project android by JetBrains.
the class AndroidInlineIncludeAction method doRefactorForTags.
@Override
protected void doRefactorForTags(@NotNull Project project, @NotNull final XmlTag[] tags) {
assert tags.length == 1;
final XmlTag tag = tags[0];
final PsiFile file = tag.getContainingFile();
if (file == null) {
return;
}
final LayoutUsageData usageData = AndroidInlineUtil.getLayoutUsageData(tag);
if (usageData == null) {
return;
}
final AndroidResourceReferenceBase reference = usageData.getReference();
final String title = AndroidBundle.message("android.inline.layout.title");
final PsiElement[] resolvedElements = reference.computeTargetElements();
if (resolvedElements.length == 0) {
AndroidUtils.reportError(project, "Cannot find layout by reference '" + reference.getValue() + "'", title);
return;
}
if (resolvedElements.length > 1) {
AndroidUtils.reportError(project, RefactoringBundle.getCannotRefactorMessage("Unambiguous layout reference."), title);
return;
}
final PsiElement resolvedElement = resolvedElements[0];
if (!(resolvedElement instanceof XmlFile)) {
AndroidUtils.reportError(project, "Cannot find layout by reference '" + reference.getValue() + "'", title);
return;
}
AndroidInlineUtil.doInlineLayoutFile(project, (XmlFile) resolvedElement, usageData.getReference().getElement(), myTestConfig);
}
Aggregations