use of org.jetbrains.android.dom.converters.ManifestPlaceholderConverter in project android by JetBrains.
the class AttributeProcessingUtil method registerAttribute.
private static void registerAttribute(@NotNull AttributeDefinition attrDef, @Nullable String parentStyleableName, @Nullable String namespaceKey, @NotNull DomElement element, @NotNull AttributeProcessor callback) {
String name = attrDef.getName();
if (!NS_RESOURCES.equals(namespaceKey) && name.startsWith(PREFIX_ANDROID)) {
// A styleable-definition in the app namespace (user specified or from a library) can include
// a reference to a platform attribute. In such a case, register it under the android namespace
// as opposed to the app namespace. See https://code.google.com/p/android/issues/detail?id=171162
name = name.substring(PREFIX_ANDROID.length());
namespaceKey = NS_RESOURCES;
}
XmlName xmlName = new XmlName(name, namespaceKey);
final DomExtension extension = callback.processAttribute(xmlName, attrDef, parentStyleableName);
if (extension == null) {
return;
}
Converter converter = AndroidDomUtil.getSpecificConverter(xmlName, element);
if (converter == null) {
if (TOOLS_URI.equals(namespaceKey)) {
converter = ToolsAttributeUtil.getConverter(attrDef);
} else {
converter = AndroidDomUtil.getConverter(attrDef);
if (converter != null && element.getParentOfType(Manifest.class, true) != null) {
converter = new ManifestPlaceholderConverter(converter);
}
}
}
if (converter != null) {
extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats()));
}
// tag completion. If attribute is not required, no additional action is needed.
if (element instanceof LayoutElement && isLayoutAttributeRequired(xmlName, element) || element instanceof ManifestElement && AndroidManifestUtils.isRequiredAttribute(xmlName, element)) {
extension.addCustomAnnotation(new RequiredImpl());
}
}
Aggregations