use of com.intellij.util.xml.ResolvingConverter 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.ResolvingConverter in project android by JetBrains.
the class ToolsAttributeUtil method getConverter.
/**
* Returns a {@link ResolvingConverter} for the given attribute definition
*/
@Nullable
public static ResolvingConverter getConverter(@NotNull AttributeDefinition attrDef) {
String name = attrDef.getName();
ResolvingConverter converter = CONVERTERS.get(name);
return converter != null ? converter : AndroidDomUtil.getConverter(attrDef);
}
use of com.intellij.util.xml.ResolvingConverter in project android by JetBrains.
the class NlDesignProperties method getDefinitionByName.
private static AttributeDefinition getDefinitionByName(@NotNull String name) {
AttributeDefinition definition = ToolsAttributeUtil.getAttrDefByName(name);
assert definition != null;
ResolvingConverter converter = ToolsAttributeUtil.getConverter(definition);
// TODO: Figure out how to provide the correct reference editor depending on the converter.
if (converter instanceof StaticEnumConverter) {
Collection variants = converter.getVariants(null);
for (Object variant : variants) {
definition.addValue(variant.toString());
}
}
return definition;
}
use of com.intellij.util.xml.ResolvingConverter in project android by JetBrains.
the class AttributeProcessingUtil method registerToolsAttribute.
private static void registerToolsAttribute(@NotNull String attributeName, @NotNull AttributeProcessor callback) {
final AttributeDefinition definition = ToolsAttributeUtil.getAttrDefByName(attributeName);
if (definition != null) {
final XmlName name = new XmlName(attributeName, TOOLS_URI);
final DomExtension domExtension = callback.processAttribute(name, definition, null);
final ResolvingConverter converter = ToolsAttributeUtil.getConverter(definition);
if (domExtension != null && converter != null) {
domExtension.setConverter(converter);
}
} else {
getLog().warn("No attribute definition for tools attribute " + attributeName);
}
}
Aggregations