@Nullable private static ResolvingConverter findConverterForAttribute(String nsPrefix, String localName, @NotNull AndroidFacet facet, @NotNull GenericDomValue element) { ResourceManager manager = facet.getResourceManager("android".equals(nsPrefix) ? AndroidUtils.SYSTEM_RESOURCE_PACKAGE : null, element.getXmlElement()); if (manager != null) { AttributeDefinitions attrDefs = manager.getAttributeDefinitions(); if (attrDefs != null) { AttributeDefinition attr = attrDefs.getAttrDefByName(localName); if (attr != null) { return AndroidDomUtil.getConverter(attr); } } } return null; }
@Override @NotNull public Collection<String> getVariants(ConvertContext context) { List<String> variants = new ArrayList<String>(); for (ResolvingConverter<String> converter : converters) { variants.addAll(converter.getVariants(context)); } return variants; }
private static <T> void addVariants(ResolvingConverter<T> converter, Collection<T> variants, Collection result) { for (T variant : variants) { LookupElement lookupElement = converter.createLookupElement(variant); if (lookupElement != null) { result.add(lookupElement); } else { result.add(variant); } } }
@NotNull private static Collection<?> getVariants(CompletionParameters parameters) { if (!MavenDomUtil.isMavenFile(parameters.getOriginalFile())) return Collections.emptyList(); SmartList<?> result = new SmartList<Object>(); 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) { result.addAll(((MavenSmartConverter)converter).getSmartVariants(reference.getConvertContext())); } else if (converter instanceof ResolvingConverter) { //noinspection unchecked result.addAll(((ResolvingConverter)converter).getVariants(reference.getConvertContext())); } } else { //noinspection unchecked Collections.addAll((Collection)result, each.getVariants()); } } return result; }
public FlagConverter(@Nullable ResolvingConverter<String> additionalConverter, @NotNull String... values) { super("|"); this.additionalConverter = additionalConverter; Collections.addAll(myValues, values); }
public void addConverter(@NotNull ResolvingConverter<String> converter) { converters.add(converter); }
@NotNull public List<ResolvingConverter<String>> getConverters() { return converters; }