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

项目:intellij-ce-playground    文件:DomAttributeXmlDescriptor.java   
static String getQualifiedAttributeName(PsiElement context, XmlName xmlName) {
  final String localName = xmlName.getLocalName();
  if (context instanceof XmlTag) {
    final XmlTag tag = (XmlTag)context;
    final DomInvocationHandler handler = DomManagerImpl.getDomManager(context.getProject()).getDomHandler(tag);
    if (handler != null) {
      final String ns = handler.createEvaluatedXmlName(xmlName).getNamespace(tag, handler.getFile());
      if (!ns.equals(XmlUtil.EMPTY_URI) && !ns.equals(tag.getNamespace())) {
        final String prefix = tag.getPrefixByNamespace(ns);
        if (StringUtil.isNotEmpty(prefix)) {
          return prefix + ":" + localName;
        }
      }
    }
  }

  return localName;
}
项目:intellij-ce-playground    文件:DomStub.java   
@Nullable
public AttributeStub getAttributeStub(final XmlName name) {
  final List<DomStub> stubs = getChildrenStubs();
  if (stubs.isEmpty()) {
    return null;
  }

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = stubs.size(); i < size; i++) {
    final DomStub stub = stubs.get(i);
    if (stub instanceof AttributeStub &&
        stub.getName().equals(name.getLocalName())) {
      return (AttributeStub)stub;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:MavenPluginConfigurationDomExtender.java   
private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData data, final String parameterName) {
  DomExtension e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);

  if (isCollection(data.parameter)) {
    e.addExtender(new DomExtender() {
      public void registerExtensions(@NotNull DomElement domElement, @NotNull DomExtensionsRegistrar registrar) {
        for (String each : collectPossibleNameForCollectionParameter(parameterName)) {
          DomExtension inner = registrar.registerCollectionChildrenExtension(new XmlName(each), MavenDomConfigurationParameter.class);
          inner.setDeclaringElement(data.parameter);
        }
      }
    });
  }
  else {
    addValueConverter(e, data.parameter);
    if (!isInPluginManagement) {
      addRequiredAnnotation(e, data);
    }
  }

  e.setDeclaringElement(data.parameter);

  data.parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, data);
}
项目:intellij-ce-playground    文件:CustomAntElementsRegistry.java   
public List<String> getTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return Collections.singletonList(generalError);
  }
  List<String> errors = null;
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      final String err = lookupError(entry.getKey());
      if (err != null)  {
        if (errors == null) {
          errors = new ArrayList<String>();
        }
        errors.add(err);
      }
    }
  }
  return errors == null? Collections.<String>emptyList() : errors;
}
项目:tools-idea    文件:DomAttributeXmlDescriptor.java   
static String getQualifiedAttributeName(PsiElement context, XmlName xmlName) {
  final String localName = xmlName.getLocalName();
  if (context instanceof XmlTag) {
    final XmlTag tag = (XmlTag)context;
    final DomInvocationHandler handler = DomManagerImpl.getDomManager(context.getProject()).getDomHandler(tag);
    if (handler != null) {
      final String ns = handler.createEvaluatedXmlName(xmlName).getNamespace(tag, handler.getFile());
      if (!ns.equals(XmlUtil.EMPTY_URI) && !ns.equals(tag.getNamespace())) {
        final String prefix = tag.getPrefixByNamespace(ns);
        if (StringUtil.isNotEmpty(prefix)) {
          return prefix + ":" + localName;
        }
      }
    }
  }

  return localName;
}
项目:tools-idea    文件:DomStub.java   
@Nullable
public AttributeStub getAttributeStub(final XmlName name) {
  final List<DomStub> stubs = getChildrenStubs();
  if (stubs.isEmpty()) {
    return null;
  }

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = stubs.size(); i < size; i++) {
    final DomStub stub = stubs.get(i);
    if (stub instanceof AttributeStub &&
        stub.getName().equals(name.getLocalName())) {
      return (AttributeStub)stub;
    }
  }
  return null;
}
项目:tools-idea    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:MavenPluginConfigurationDomExtender.java   
private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData data, final String parameterName) {
  DomExtension e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);

  if (isCollection(data.parameter)) {
    e.addExtender(new DomExtender() {
      public void registerExtensions(@NotNull DomElement domElement, @NotNull DomExtensionsRegistrar registrar) {
        for (String each : collectPossibleNameForCollectionParameter(parameterName)) {
          DomExtension inner = registrar.registerCollectionChildrenExtension(new XmlName(each), MavenDomConfigurationParameter.class);
          inner.setDeclaringElement(data.parameter);
        }
      }
    });
  }
  else {
    addValueConverter(e, data.parameter);
    if (!isInPluginManagement) {
      addRequiredAnnotation(e, data);
    }
  }

  e.setDeclaringElement(data.parameter);

  data.parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, data);
}
项目:tools-idea    文件:CustomAntElementsRegistry.java   
public List<String> getTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return Collections.singletonList(generalError);
  }
  List<String> errors = null;
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      final String err = lookupError(entry.getKey());
      if (err != null)  {
        if (errors == null) {
          errors = new ArrayList<String>();
        }
        errors.add(err);
      }
    }
  }
  return errors == null? Collections.<String>emptyList() : errors;
}
项目:consulo-apache-ant    文件:AntDomExtender.java   
public Set<EvaluatedXmlName> getCompletionVariants(@NotNull DomElement parent) {
  if (!(parent instanceof AntDomElement)) {
    return Collections.emptySet();
  }
  final AntDomElement element = (AntDomElement)parent;
  final AntDomProject antDomProject = element.getAntProject();
  if (antDomProject == null) {
    return Collections.emptySet();
  }
  final CustomAntElementsRegistry registry = CustomAntElementsRegistry.getInstance(antDomProject);
  final Set<EvaluatedXmlName> result = new HashSet<EvaluatedXmlName>();
  for (XmlName variant : registry.getCompletionVariants(element)) {
    final String ns = variant.getNamespaceKey();
    result.add(new DummyEvaluatedXmlName(variant, ns != null? ns : ""));
  }
  return result;
}
项目:consulo-apache-ant    文件:CustomAntElementsRegistry.java   
public List<String> getTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return Collections.singletonList(generalError);
  }
  List<String> errors = null;
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      final String err = lookupError(entry.getKey());
      if (err != null)  {
        if (errors == null) {
          errors = new ArrayList<String>();
        }
        errors.add(err);
      }
    }
  }
  return errors == null? Collections.<String>emptyList() : errors;
}
项目:consulo-xml    文件:DomAttributeXmlDescriptor.java   
static String getQualifiedAttributeName(PsiElement context, XmlName xmlName) {
  final String localName = xmlName.getLocalName();
  if (context instanceof XmlTag) {
    final XmlTag tag = (XmlTag)context;
    final DomInvocationHandler handler = DomManagerImpl.getDomManager(context.getProject()).getDomHandler(tag);
    if (handler != null) {
      final String ns = handler.createEvaluatedXmlName(xmlName).getNamespace(tag, handler.getFile());
      if (!ns.equals(XmlUtil.EMPTY_URI) && !ns.equals(tag.getNamespace())) {
        final String prefix = tag.getPrefixByNamespace(ns);
        if (StringUtil.isNotEmpty(prefix)) {
          return prefix + ":" + localName;
        }
      }
    }
  }

  return localName;
}
项目:consulo-xml    文件:DomStub.java   
@Nullable
public AttributeStub getAttributeStub(final XmlName name)
{
    final List<DomStub> stubs = getChildrenStubs();
    if(stubs.isEmpty())
    {
        return null;
    }

    //noinspection ForLoopReplaceableByForEach
    for(int i = 0, size = stubs.size(); i < size; i++)
    {
        final DomStub stub = stubs.get(i);
        if(stub instanceof AttributeStub && stub.getName().equals(name.getLocalName()))
        {
            return (AttributeStub) stub;
        }
    }
    return null;
}
项目:consulo-xml    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ChildrenDescriptionsHolder.java   
@Nullable
final T findDescription(@NotNull final String localName) {
  for (final XmlName xmlName : myMap.keySet()) {
    if (xmlName.getLocalName().equals(localName)) return myMap.get(xmlName);
  }
  return myDelegate != null ? myDelegate.findDescription(localName) : null;
}
项目:intellij-ce-playground    文件:AndroidManifestUtils.java   
public static boolean isRequiredAttribute(XmlName attrName, DomElement element) {
  if (element instanceof CompatibleScreensScreen &&
      SdkConstants.NS_RESOURCES.equals(attrName.getNamespaceKey())) {
    final String localName = attrName.getLocalName();
    return "screenSize".equals(localName) || "screenDensity".equals(localName);
  }
  return false;
}
项目:intellij-ce-playground    文件:MavenPluginConfigurationParameterDomExtender.java   
@Override
public void registerExtensions(@NotNull MavenDomConfigurationParameter param, @NotNull DomExtensionsRegistrar r) {
  for (XmlAttribute each : param.getXmlTag().getAttributes()) {
    String name = each.getName();
    if (CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.equals(name)) continue;
    r.registerGenericAttributeValueChildExtension(new XmlName(name), String.class);
  }
}
项目:intellij-ce-playground    文件:CustomAntElementsRegistry.java   
public boolean hasTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return true;
  }
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      if (lookupError(entry.getKey()) != null)  {
        return true;
      }
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:InternalDomExtender.java   
private static void addInternalAttribute(@NotNull DomExtensionsRegistrar registrar, Class clazz) {
  if (!ApplicationManager.getApplication().isInternal()) {
    return;
  }

  registrar.registerGenericAttributeValueChildExtension(new XmlName("internal"), clazz)
    .setConverter(BooleanValueConverter.getInstance(false));
  registrar.registerGenericAttributeValueChildExtension(new XmlName("overrides"), clazz)
    .setConverter(BooleanValueConverter.getInstance(false));
}
项目:tools-idea    文件:ChildrenDescriptionsHolder.java   
@Nullable
final T findDescription(@NotNull final String localName) {
  for (final XmlName xmlName : myMap.keySet()) {
    if (xmlName.getLocalName().equals(localName)) return myMap.get(xmlName);
  }
  return myDelegate != null ? myDelegate.findDescription(localName) : null;
}
项目:tools-idea    文件:MavenPluginConfigurationParameterDomExtender.java   
@Override
public void registerExtensions(@NotNull MavenDomConfigurationParameter param, @NotNull DomExtensionsRegistrar r) {
  for (XmlAttribute each : param.getXmlTag().getAttributes()) {
    String name = each.getName();
    if (CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.equals(name)) continue;
    r.registerGenericAttributeValueChildExtension(new XmlName(name), String.class);
  }
}
项目:tools-idea    文件:CustomAntElementsRegistry.java   
public boolean hasTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return true;
  }
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      if (lookupError(entry.getKey()) != null)  {
        return true;
      }
    }
  }
  return false;
}
项目:tools-idea    文件:InternalDomExtender.java   
private static void addInternalAttribute(@NotNull DomExtensionsRegistrar registrar, Class clazz) {
  if (!ApplicationManager.getApplication().isInternal()) {
    return;
  }

  registrar.registerGenericAttributeValueChildExtension(new XmlName("internal"), clazz)
    .setConverter(BooleanValueConverter.getInstance(false));
}
项目:consulo-apache-ant    文件:AntDomExtender.java   
@Nullable
private static DomExtension registerChild(DomExtensionsRegistrar registrar, DomGenericInfo elementInfo, String childName) {
  if (elementInfo.getCollectionChildDescription(childName) == null) { // register if not yet defined statically
    Class<? extends AntDomElement> modelClass = getModelClass(childName);
    if (modelClass == null) {
      modelClass = AntDomElement.class;
    }
    return registrar.registerCollectionChildrenExtension(new XmlName(childName), modelClass);
  }
  return null;
}
项目:consulo-apache-ant    文件:AntDomExtender.java   
@Nullable
private static PomTarget doFindDeclaration(DomElement parent, XmlName xmlName) {
  if (!(parent instanceof AntDomElement)) {
    return null;
  }
  final AntDomElement parentElement = (AntDomElement)parent;
  final AntDomProject antDomProject = parentElement.getAntProject();
  if (antDomProject == null) {
    return null;
  }
  final CustomAntElementsRegistry registry = CustomAntElementsRegistry.getInstance(antDomProject);
  final AntDomElement declaringElement = registry.findDeclaringElement(parentElement, xmlName);
  if (declaringElement == null) {
    return null;
  }
  DomTarget target = DomTarget.getTarget(declaringElement);
  if (target == null && declaringElement instanceof AntDomTypeDef) {
    final AntDomTypeDef typedef = (AntDomTypeDef)declaringElement;
    final GenericAttributeValue<PsiFileSystemItem> resource = typedef.getResource();
    if (resource != null) {
      target = DomTarget.getTarget(declaringElement, resource);
    }
    if (target == null) {
      final GenericAttributeValue<PsiFileSystemItem> file = typedef.getFile();
      if (file != null) {
        target = DomTarget.getTarget(declaringElement, file);
      }
    }
  }
  return target;
}
项目:consulo-apache-ant    文件:CustomAntElementsRegistry.java   
public boolean hasTypeLoadingErrors(AntDomTypeDef typedef) {
  final String generalError = myTypeDefErrors.get(typedef);
  if (generalError != null) {
    return true;
  }
  for (Map.Entry<XmlName, AntDomNamedElement> entry : myDeclarations.entrySet()) {
    if (typedef.equals(entry.getValue())) {
      if (lookupError(entry.getKey()) != null)  {
        return true;
      }
    }
  }
  return false;
}
项目:consulo-xml    文件:ChildrenDescriptionsHolder.java   
@Nullable
final T findDescription(@NotNull final String localName) {
  for (final XmlName xmlName : myMap.keySet()) {
    if (xmlName.getLocalName().equals(localName)) return myMap.get(xmlName);
  }
  return myDelegate != null ? myDelegate.findDescription(localName) : null;
}
项目:intellij-ce-playground    文件:DomExtensionImpl.java   
public DomExtensionImpl(final Type type, final XmlName xmlName) {
  myType = type;
  myXmlName = xmlName;
}
项目:intellij-ce-playground    文件:DomExtensionImpl.java   
@NotNull
public XmlName getXmlName() {
  return myXmlName;
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
@NotNull
public final DomExtension registerFixedNumberChildrenExtension(@NotNull final XmlName name, @NotNull final Type type, final int count) {
  assert count > 0;
  return addExtension(myFixeds, name, type).setCount(count);
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
@Override
@NotNull
public DomExtension registerFixedNumberChildExtension(@NotNull final XmlName name, @NotNull final Type type) {
  return registerFixedNumberChildrenExtension(name, type, 1);
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
@Override
@NotNull
public DomExtension registerCollectionChildrenExtension(@NotNull final XmlName name, @NotNull final Type type) {
  return addExtension(myCollections, name, type);
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
@Override
@NotNull
public DomExtension registerGenericAttributeValueChildExtension(@NotNull final XmlName name, final Type parameterType) {
  return addExtension(myAttributes, name, new ParameterizedTypeImpl(GenericAttributeValue.class, parameterType));
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
@Override
@NotNull
public DomExtension registerAttributeChildExtension(@NotNull final XmlName name, @NotNull final Type type) {
  assert GenericAttributeValue.class.isAssignableFrom(ReflectionUtil.getRawType(type));
  return addExtension(myAttributes, name, type);
}
项目:intellij-ce-playground    文件:DomExtensionsRegistrarImpl.java   
private static DomExtensionImpl addExtension(final List<DomExtensionImpl> list, @Nullable final XmlName name, final Type type) {
  final DomExtensionImpl extension = new DomExtensionImpl(type, name);
  list.add(extension);
  return extension;
}
项目:intellij-ce-playground    文件:DomChildDescriptionImpl.java   
protected DomChildDescriptionImpl(final XmlName tagName, @NotNull final Type type) {
  super(type);
  myTagName = tagName;
}
项目:intellij-ce-playground    文件:DomChildDescriptionImpl.java   
@Override
@NotNull
public final XmlName getXmlName() {
  return myTagName;
}
项目:intellij-ce-playground    文件:ChildrenDescriptionsHolder.java   
@Nullable
final T getDescription(final XmlName name) {
  final T t = myMap.get(name);
  if (t != null) return t;
  return myDelegate != null ? myDelegate.getDescription(name) : null;
}
项目:intellij-ce-playground    文件:ChildrenDescriptionsHolder.java   
@Nullable
final T getDescription(@NotNull final String localName, String namespaceKey) {
  return getDescription(new XmlName(localName, namespaceKey));
}