Java 类com.intellij.util.xml.Converter 实例源码

项目:intellij-ce-playground    文件:StyleItemConverter.java   
@Override
public Converter getConverter(@NotNull GenericDomValue element) {
  StyleItem item = (StyleItem)element;
  String name = item.getName().getValue();
  if (name != null) {
    String[] strs = name.split(":");
    if (strs.length == 1 || strs.length == 2) {
      AndroidFacet facet = AndroidFacet.getInstance(element);
      if (facet != null) {
        String namespacePrefix = strs.length == 2 ? strs[0] : null;
        String localName = strs[strs.length - 1];
        return findConverterForAttribute(namespacePrefix, localName, facet, element);
      }
    }
  }
  return null;
}
项目:consulo-apache-ant    文件:AntDomExtender.java   
private static Map<String, Pair<Type, Class>> getStaticallyRegisteredAttributes(final DomGenericInfo genericInfo) {
  final Map<String, Pair<Type, Class>> map = new HashMap<String, Pair<Type, Class>>();
  for (DomAttributeChildDescription description : genericInfo.getAttributeChildrenDescriptions()) {
    final Type type = description.getType();
    if (type instanceof ParameterizedType) {
      final Type[] typeArguments = ((ParameterizedType)type).getActualTypeArguments();
      if (typeArguments.length == 1) {
        String name = description.getXmlElementName();
        final Type attribType = typeArguments[0];
        Class<? extends Converter> converterType = null;
        final Convert converterAnnotation = description.getAnnotation(Convert.class);
        if (converterAnnotation != null) {
          converterType = converterAnnotation.value();
        }
        map.put(name.toLowerCase(Locale.US), new Pair<Type, Class>(attribType, converterType));
      }
    }
  }
  return map;
}
项目:consulo-javaee    文件:ContextParamValueConverter.java   
@Override
public Converter getConverter(@NotNull GenericDomValue domElement) {
  Module module = domElement.getModule();

  ParamValue value = domElement.getParentOfType(ParamValue.class, false);
  if (value != null) {
    String paramName = value.getParamName().getStringValue();
    if (paramName != null) {
      for (ContextParamsProvider provider : Extensions.getExtensions(ContextParamsProvider.EP_NAME)) {
        Converter converter = provider.getContextParamValueConverter(paramName, module);
        if (converter != null) return converter;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull final PsiType type) {
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return Comparing.equal(pair.getFirst(), type);
    }
  });
}
项目:intellij-ce-playground    文件:GenericDomValueConvertersRegistry.java   
@Nullable
public Converter<?> getConverter(@NotNull GenericDomValue domValue, @Nullable PsiType type) {
  final Pair<PsiType, GenericDomValue> pair = Pair.create(type, domValue);
  for (@NotNull Condition<Pair<PsiType, GenericDomValue>> condition : myConditionConverters.keySet()) {
    if (condition.value(pair)) {
      return myConditionConverters.get(condition);
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class type) {
  final String name = type.getCanonicalName();
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return pair.first != null && Comparing.equal(name, pair.first.getCanonicalText());
    }
  });
}
项目:intellij-ce-playground    文件:AndroidCompletionContributor.java   
private static void completeTailsInFlagAttribute(CompletionParameters parameters,
                                                 CompletionResultSet resultSet,
                                                 XmlAttributeValue parent) {
  final String currentValue = parent.getValue();

  if (currentValue == null || currentValue.length() == 0 || currentValue.endsWith("|")) {
    return;
  }
  final PsiElement gp = parent.getParent();

  if (!(gp instanceof XmlAttribute)) {
    return;
  }
  final GenericAttributeValue domValue = DomManager.getDomManager(gp.getProject()).getDomElement((XmlAttribute)gp);
  final Converter converter = domValue != null ? domValue.getConverter() : null;

  if (!(converter instanceof FlagConverter)) {
    return;
  }
  final TextRange valueRange = parent.getValueTextRange();

  if (valueRange != null && valueRange.getEndOffset() == parameters.getOffset()) {
    final Set<String> valueSet = ((FlagConverter)converter).getValues();

    if (valueSet.size() > 0) {
      final String prefix = resultSet.getPrefixMatcher().getPrefix();

      if (valueSet.contains(prefix)) {
        final ArrayList<String> filteredValues = new ArrayList<String>(valueSet);
        //noinspection unchecked
        DelimitedListConverter.filterVariants(filteredValues, domValue);

        for (String variant : filteredValues) {
          resultSet.addElement(LookupElementBuilder.create(prefix + "|" + variant));
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:AndroidDomInspection.java   
@Override
protected boolean shouldCheckResolveProblems(GenericDomValue value) {
  final Converter realConverter = WrappingConverter.getDeepestConverter(value.getConverter(), value);
  return !(realConverter instanceof AndroidPackageConverter) &&
         !(realConverter instanceof DeclareStyleableNameConverter) &&
         !(realConverter instanceof OnClickConverter) &&
         !(realConverter instanceof ConstantFieldConverter);
}
项目:intellij-ce-playground    文件:MavenModelInspection.java   
@Override
protected boolean shouldCheckResolveProblems(GenericDomValue value) {
  if (!isElementInsideManagedFile(value)) {
    return false;
  }

  Converter converter = value.getConverter();
  if (converter instanceof MavenDomSoftAwareConverter) {
    return !((MavenDomSoftAwareConverter)converter).isSoft(value);
  }

  return true;
}
项目:intellij-ce-playground    文件:MavenPluginCustomParameterValueConverter.java   
@Override
public Converter getConverter(@NotNull GenericDomValue domElement) {
  Project project = domElement.getManager().getProject();

  JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project));
  if (psiClass != null) {
    GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry();
    return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass));
  }

  return null;
}
项目:intellij-ce-playground    文件:AntDomPropertyValueConverter.java   
@NotNull public List<Converter> getConverters(@NotNull GenericDomValue domElement) {
  final String raw = domElement.getRawText();
  if (raw != null) {
    if (raw.contains("${") || raw.contains(File.separator) || (File.separatorChar != '/' && raw.contains("/"))) {
      return Collections.<Converter>singletonList(new AntPathConverter());
    }
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull final PsiType type) {
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return Comparing.equal(pair.getFirst(), type);
    }
  });
}
项目:tools-idea    文件:GenericDomValueConvertersRegistry.java   
@Nullable
public Converter<?> getConverter(@NotNull GenericDomValue domValue, @Nullable PsiType type) {
  final Pair<PsiType, GenericDomValue> pair = new Pair<PsiType, GenericDomValue>(type, domValue);
  for (@NotNull Condition<Pair<PsiType, GenericDomValue>> condition : myConditionConverters.keySet()) {
    if (condition.value(pair)) {
      return myConditionConverters.get(condition);
    }
  }
  return null;
}
项目:tools-idea    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class type) {
  final String name = type.getCanonicalName();
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return pair.first != null && Comparing.equal(name, pair.first.getCanonicalText());
    }
  });
}
项目:tools-idea    文件:MavenSmartCompletionContributor.java   
@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;
}
项目:tools-idea    文件:MavenModelInspection.java   
@Override
protected boolean shouldCheckResolveProblems(GenericDomValue value) {
  if (!isElementInsideManagedFile(value)) {
    return false;
  }

  Converter converter = value.getConverter();
  if (converter instanceof MavenDomSoftAwareConverter) {
    return !((MavenDomSoftAwareConverter)converter).isSoft(value);
  }

  return true;
}
项目:tools-idea    文件:MavenPluginCustomParameterValueConverter.java   
@Override
public Converter getConverter(@NotNull GenericDomValue domElement) {
  Project project = domElement.getManager().getProject();

  JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project));
  if (psiClass != null) {
    GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry();
    return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass));
  }

  return null;
}
项目:tools-idea    文件:AntDomPropertyValueConverter.java   
@NotNull public List<Converter> getConverters(@NotNull GenericDomValue domElement) {
  final String raw = domElement.getRawText();
  if (raw != null) {
    if (raw.contains("${") || raw.contains(File.separator) || (File.separatorChar != '/' && raw.contains("/"))) {
      return Collections.<Converter>singletonList(new AntPathConverter());
    }
  }
  return Collections.emptyList();
}
项目:consulo-apache-ant    文件:AntDomPropertyValueConverter.java   
@NotNull public List<Converter> getConverters(@NotNull GenericDomValue domElement) {
  final String raw = domElement.getRawText();
  if (raw != null) {
    if (raw.contains("${") || raw.contains(File.separator) || (File.separatorChar != '/' && raw.contains("/"))) {
      return Collections.<Converter>singletonList(new AntPathConverter());
    }
  }
  return Collections.emptyList();
}
项目:consulo-java    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull final PsiType type) {
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return Comparing.equal(pair.getFirst(), type);
    }
  });
}
项目:consulo-java    文件:GenericDomValueConvertersRegistry.java   
@Nullable
public Converter<?> getConverter(@NotNull GenericDomValue domValue, @Nullable PsiType type) {
  final Pair<PsiType, GenericDomValue> pair = new Pair<PsiType, GenericDomValue>(type, domValue);
  for (@NotNull Condition<Pair<PsiType, GenericDomValue>> condition : myConditionConverters.keySet()) {
    if (condition.value(pair)) {
      return myConditionConverters.get(condition);
    }
  }
  return null;
}
项目:consulo-java    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class type) {
  final String name = type.getCanonicalName();
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return pair.first != null && Comparing.equal(name, pair.first.getCanonicalText());
    }
  });
}
项目:intellij-ce-playground    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Condition<Pair<PsiType, GenericDomValue>> condition) {
  myConditionConverters.put(condition, provider);
}
项目:intellij-ce-playground    文件:DomExtensionImpl.java   
@Override
public DomExtension setConverter(@NotNull Converter converter) {
  return setConverter(converter, false);
}
项目:intellij-ce-playground    文件:DomExtensionImpl.java   
@Override
public final DomExtension setConverter(@NotNull final Converter converter, final boolean soft) {
  myConverter = converter;
  mySoft = soft;
  return this;
}
项目:intellij-ce-playground    文件:SetInvocation.java   
protected SetInvocation(final Converter converter) {
  myConverter = converter;
}
项目:intellij-ce-playground    文件:ConvertAnnotationImpl.java   
public ConvertAnnotationImpl(final Converter converter, final boolean soft) {
  myConverter = converter;
  mySoft = soft;
}
项目:intellij-ce-playground    文件:ConvertAnnotationImpl.java   
public Converter getConverter() {
  return myConverter;
}
项目:intellij-ce-playground    文件:ConvertAnnotationImpl.java   
@Override
public Class<? extends Converter> value() {
  return myConverter.getClass();
}
项目:intellij-ce-playground    文件:AntDomPropertyValueConverter.java   
public Converter getConverter(@NotNull GenericDomValue domElement) {
  final List<Converter> converterList = getConverters(domElement);
  return converterList.isEmpty()? null : converterList.get(0);
}
项目:tools-idea    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Condition<Pair<PsiType, GenericDomValue>> condition) {
  myConditionConverters.put(condition, provider);
}
项目:tools-idea    文件:DomExtensionImpl.java   
public DomExtension setConverter(@NotNull Converter converter) {
  return setConverter(converter, false);
}
项目:tools-idea    文件:DomExtensionImpl.java   
public final DomExtension setConverter(@NotNull final Converter converter, final boolean soft) {
  myConverter = converter;
  mySoft = soft;
  return this;
}
项目:tools-idea    文件:SetInvocation.java   
protected SetInvocation(final Converter converter) {
  myConverter = converter;
}
项目:tools-idea    文件:ConvertAnnotationImpl.java   
public ConvertAnnotationImpl(final Converter converter, final boolean soft) {
  myConverter = converter;
  mySoft = soft;
}
项目:tools-idea    文件:ConvertAnnotationImpl.java   
public Converter getConverter() {
  return myConverter;
}
项目:tools-idea    文件:ConvertAnnotationImpl.java   
public Class<? extends Converter> value() {
  return myConverter.getClass();
}
项目:tools-idea    文件:AntDomPropertyValueConverter.java   
public Converter getConverter(@NotNull GenericDomValue domElement) {
  final List<Converter> converterList = getConverters(domElement);
  return converterList.isEmpty()? null : converterList.get(0);
}
项目:consulo-apache-ant    文件:AntDomPropertyValueConverter.java   
public Converter getConverter(@NotNull GenericDomValue domElement) {
  final List<Converter> converterList = getConverters(domElement);
  return converterList.isEmpty()? null : converterList.get(0);
}
项目:consulo-javaee    文件:ContextParamsProvider.java   
@Nullable
public abstract Converter getContextParamValueConverter(@NotNull String paramName, @Nullable Module module);