use of org.jetbrains.android.dom.attrs.AttributeDefinitions in project android by JetBrains.
the class AndroidCompletionContributor method isFrameworkAttributeDeprecated.
private static boolean isFrameworkAttributeDeprecated(AndroidFacet facet, XmlAttribute attribute, String attributeName) {
final ResourceManager manager = facet.getResourceManager(AndroidUtils.SYSTEM_RESOURCE_PACKAGE, attribute.getParent());
if (manager == null) {
return false;
}
final AttributeDefinitions attributes = manager.getAttributeDefinitions();
if (attributes == null) {
return false;
}
final AttributeDefinition attributeDefinition = attributes.getAttrDefByName(attributeName);
return attributeDefinition != null && attributeDefinition.isAttributeDeprecated();
}
use of org.jetbrains.android.dom.attrs.AttributeDefinitions in project android by JetBrains.
the class ResolutionUtils method getAttributeDefinition.
@Nullable
public static AttributeDefinition getAttributeDefinition(@NotNull Module module, @Nullable Configuration configuration, @NotNull String name) {
AttributeDefinitions definitions;
if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
IAndroidTarget target;
if (configuration == null) {
AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
// same as getHighestApiTarget();
target = facet.getConfigurationManager().getDefaultTarget();
} else {
target = configuration.getRealTarget();
}
assert target != null;
AndroidTargetData androidTargetData = AndroidTargetData.getTargetData(target, module);
assert androidTargetData != null;
definitions = androidTargetData.getAllAttrDefs(module.getProject());
} else {
AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null : String.format("Module %s is not an Android module", module.getName());
definitions = facet.getLocalResourceManager().getAttributeDefinitions();
}
if (definitions == null) {
return null;
}
return definitions.getAttrDefByName(getNameFromQualifiedName(name));
}
use of org.jetbrains.android.dom.attrs.AttributeDefinitions in project android by JetBrains.
the class NlProperties method getPropertiesWithReadLock.
@NotNull
private Table<String, String, NlPropertyItem> getPropertiesWithReadLock(@NotNull AndroidFacet facet, @NotNull List<NlComponent> components, @NotNull GradleDependencyManager dependencyManager) {
ResourceManager localResourceManager = facet.getLocalResourceManager();
ResourceManager systemResourceManager = facet.getSystemResourceManager();
if (systemResourceManager == null) {
Logger.getInstance(NlProperties.class).error("No system resource manager for module: " + facet.getModule().getName());
return ImmutableTable.of();
}
AttributeDefinitions localAttrDefs = localResourceManager.getAttributeDefinitions();
AttributeDefinitions systemAttrDefs = systemResourceManager.getAttributeDefinitions();
Table<String, String, NlPropertyItem> combinedProperties = null;
for (NlComponent component : components) {
XmlTag tag = component.getTag();
if (!tag.isValid()) {
return ImmutableTable.of();
}
XmlElementDescriptor elementDescriptor = myDescriptorProvider.getDescriptor(tag);
if (elementDescriptor == null) {
return ImmutableTable.of();
}
XmlAttributeDescriptor[] descriptors = elementDescriptor.getAttributesDescriptors(tag);
Table<String, String, NlPropertyItem> properties = HashBasedTable.create(3, descriptors.length);
for (XmlAttributeDescriptor desc : descriptors) {
String namespace = getNamespace(desc, tag);
AttributeDefinitions attrDefs = NS_RESOURCES.equals(namespace) ? systemAttrDefs : localAttrDefs;
AttributeDefinition attrDef = attrDefs == null ? null : attrDefs.getAttrDefByName(desc.getName());
NlPropertyItem property = NlPropertyItem.create(components, desc, namespace, attrDef);
properties.put(StringUtil.notNullize(namespace), property.getName(), property);
}
// Exceptions:
switch(tag.getName()) {
case AUTO_COMPLETE_TEXT_VIEW:
// An AutoCompleteTextView has a popup that is created at runtime.
// Properties for this popup can be added to the AutoCompleteTextView tag.
properties.put(ANDROID_URI, ATTR_POPUP_BACKGROUND, NlPropertyItem.create(components, new AndroidAnyAttributeDescriptor(ATTR_POPUP_BACKGROUND), ANDROID_URI, systemAttrDefs != null ? systemAttrDefs.getAttrDefByName(ATTR_POPUP_BACKGROUND) : null));
break;
}
combinedProperties = combine(properties, combinedProperties);
}
// The following properties are deprecated in the support library and can be ignored by tools:
assert combinedProperties != null;
combinedProperties.remove(AUTO_URI, ATTR_PADDING_START);
combinedProperties.remove(AUTO_URI, ATTR_PADDING_END);
combinedProperties.remove(AUTO_URI, ATTR_THEME);
setUpDesignProperties(combinedProperties);
setUpSrcCompat(combinedProperties, facet, components, dependencyManager);
initStarState(combinedProperties);
//noinspection ConstantConditions
return combinedProperties;
}
use of org.jetbrains.android.dom.attrs.AttributeDefinitions in project android by JetBrains.
the class PropertyTestCase method getDefinition.
@Nullable
protected static AttributeDefinition getDefinition(@NotNull NlComponent component, @NotNull XmlAttributeDescriptor descriptor) {
AndroidFacet facet = component.getModel().getFacet();
ResourceManager localResourceManager = facet.getLocalResourceManager();
ResourceManager systemResourceManager = facet.getSystemResourceManager();
assertThat(systemResourceManager).isNotNull();
AttributeDefinitions localAttrDefs = localResourceManager.getAttributeDefinitions();
AttributeDefinitions systemAttrDefs = systemResourceManager.getAttributeDefinitions();
AttributeDefinitions attrDefs = NS_RESOURCES.equals(getNamespace(component, descriptor)) ? systemAttrDefs : localAttrDefs;
return attrDefs == null ? null : attrDefs.getAttrDefByName(descriptor.getName());
}
Aggregations