use of com.intellij.util.xml.Converter in project intellij-community by JetBrains.
the class MavenSmartCompletionContributor method getVariants.
@NotNull
private static Collection<?> getVariants(CompletionParameters parameters) {
if (!MavenDomUtil.isMavenFile(parameters.getOriginalFile()))
return Collections.emptyList();
SmartList<?> result = new SmartList<>();
for (PsiReference each : getReferences(parameters)) {
if (each instanceof TagNameReference)
continue;
if (each instanceof GenericDomValueReference) {
GenericDomValueReference reference = (GenericDomValueReference) each;
Converter converter = reference.getConverter();
if (converter instanceof MavenSmartConverter) {
Collection variants = ((MavenSmartConverter) converter).getSmartVariants(reference.getConvertContext());
if (converter instanceof ResolvingConverter) {
addVariants((ResolvingConverter) converter, variants, result);
} else {
result.addAll(variants);
}
} else if (converter instanceof ResolvingConverter) {
//noinspection unchecked
ResolvingConverter resolvingConverter = (ResolvingConverter) converter;
Collection variants = resolvingConverter.getVariants(reference.getConvertContext());
addVariants(resolvingConverter, variants, result);
}
} else {
//noinspection unchecked
Collections.addAll((Collection) result, each.getVariants());
}
}
return result;
}
use of com.intellij.util.xml.Converter 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