use of org.jetbrains.android.inspections.CreateFileResourceQuickFix in project android by JetBrains.
the class ResourceReferenceConverter method getQuickFixes.
@Override
public LocalQuickFix[] getQuickFixes(ConvertContext context) {
AndroidFacet facet = AndroidFacet.getInstance(context);
if (facet != null) {
final DomElement domElement = context.getInvocationElement();
if (domElement instanceof GenericDomValue) {
final String value = ((GenericDomValue) domElement).getStringValue();
if (value != null) {
ResourceValue resourceValue = ResourceValue.parse(value, false, myWithPrefix, true);
if (resourceValue != null) {
String aPackage = resourceValue.getNamespace();
ResourceType resType = resourceValue.getType();
if (resType == null && myResourceTypes.size() == 1) {
resType = myResourceTypes.iterator().next();
}
final String resourceName = resourceValue.getResourceName();
if (aPackage == null && resType != null && resourceName != null && AndroidResourceUtil.isCorrectAndroidResourceName(resourceName)) {
final List<LocalQuickFix> fixes = new ArrayList<>();
ResourceFolderType folderType = AndroidResourceUtil.XML_FILE_RESOURCE_TYPES.get(resType);
if (folderType != null) {
fixes.add(new CreateFileResourceQuickFix(facet, folderType, resourceName, context.getFile(), false));
}
if (VALUE_RESOURCE_TYPES.contains(resType) && resType != ResourceType.LAYOUT) {
// layouts: aliases only
fixes.add(new CreateValueResourceQuickFix(facet, resType, resourceName, context.getFile(), false));
}
return fixes.toArray(new LocalQuickFix[fixes.size()]);
}
}
}
}
}
return LocalQuickFix.EMPTY_ARRAY;
}
Aggregations