当前位置: 首页>>代码示例>>Java>>正文


Java XmlUtil.findNamespace方法代码示例

本文整理汇总了Java中com.intellij.xml.util.XmlUtil.findNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil.findNamespace方法的具体用法?Java XmlUtil.findNamespace怎么用?Java XmlUtil.findNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.xml.util.XmlUtil的用法示例。


在下文中一共展示了XmlUtil.findNamespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectDependencies

import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static void collectDependencies(@Nullable XmlTag myTag, @NotNull XmlFile myFile, @NotNull Set<PsiFile> visited) {
  if (visited.contains(myFile)) return;
  visited.add( myFile );

  if (myTag == null) return;
  XmlTag[] tags = myTag.getSubTags();

  for (final XmlTag tag : tags) {
    if (equalsToSchemaName(tag, INCLUDE_TAG_NAME) ||
        equalsToSchemaName(tag, IMPORT_TAG_NAME)
      ) {
      final String schemaLocation = tag.getAttributeValue("schemaLocation");
      if (schemaLocation != null) {
        final XmlFile xmlFile = XmlUtil.findNamespace(myFile, schemaLocation);
        addDependency(xmlFile, visited);
      }
    } else if (equalsToSchemaName(tag, REDEFINE_TAG_NAME)) {
      myRedefinedDescriptorsInProcessing.set(visited);
      try {
        final XmlFile file = getRedefinedElementDescriptorFile(tag);
        addDependency(file, visited);
      } finally {
        myRedefinedDescriptorsInProcessing.set(null);
      }
    }
  }

  final String schemaLocationDeclaration = myTag.getAttributeValue("schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
  if(schemaLocationDeclaration != null) {
    final StringTokenizer tokenizer = new StringTokenizer(schemaLocationDeclaration);

    while(tokenizer.hasMoreTokens()){
      final String uri = tokenizer.nextToken();

      if(tokenizer.hasMoreTokens()){
        PsiFile resourceLocation = ExternalResourceManager.getInstance().getResourceLocation(tokenizer.nextToken(), myFile, null);
        if (resourceLocation == null) resourceLocation = ExternalResourceManager.getInstance().getResourceLocation(uri, myFile, null);

        if (resourceLocation instanceof XmlFile) addDependency((XmlFile)resourceLocation, visited);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:XmlNSDescriptorImpl.java

示例2: processTagsInNamespaceInner

import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
private static boolean processTagsInNamespaceInner(@NotNull final XmlTag rootTag, final String[] tagNames,
                                                   final PsiElementProcessor<XmlTag> processor, Set<XmlTag> visitedTags) {
  if (visitedTags == null) visitedTags = new HashSet<XmlTag>(3);
  else if (visitedTags.contains(rootTag)) return true;

  visitedTags.add(rootTag);
  XmlTag[] tags = rootTag.getSubTags();

  NextTag:
  for (XmlTag tag : tags) {
    for(String tagName:tagNames) {
      if (equalsToSchemaName(tag, tagName)) {
        final String name = tag.getAttributeValue("name");

        if (name != null) {
          if (!processor.execute(tag)) {
            return false;
          }
        }

        continue NextTag;
      }
    }

    if (equalsToSchemaName(tag, INCLUDE_TAG_NAME)) {
      final String schemaLocation = tag.getAttributeValue("schemaLocation");

      if (schemaLocation != null) {
        final XmlFile xmlFile = XmlUtil.findNamespace(rootTag.getContainingFile(), schemaLocation);

        if (xmlFile != null) {
          final XmlDocument includedDocument = xmlFile.getDocument();

          if (includedDocument != null) {
            if (!processTagsInNamespaceInner(includedDocument.getRootTag(), tagNames, processor, visitedTags)) return false;
          }
        }
      }
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:XmlNSDescriptorImpl.java

示例3: getAttributeImpl

import com.intellij.xml.util.XmlUtil; //导入方法依赖的package包/类
@Nullable
private XmlAttributeDescriptor getAttributeImpl(String localName, String namespace, @Nullable Set<XmlTag> visited) {
  if (myTag == null) return null;

  XmlNSDescriptor nsDescriptor = myTag.getNSDescriptor(namespace, true);

  if (nsDescriptor != this && nsDescriptor instanceof XmlNSDescriptorImpl) {
    return ((XmlNSDescriptorImpl)nsDescriptor).getAttributeImpl(
      localName,
      namespace,
      visited
    );
  }

  if (visited == null) visited = new HashSet<XmlTag>(1);
  else if(visited.contains(myTag)) return null;
  visited.add(myTag);
  XmlTag[] tags = myTag.getSubTags();

  for (XmlTag tag : tags) {
    if (equalsToSchemaName(tag, ATTRIBUTE_TAG_NAME)) {
      String name = tag.getAttributeValue("name");

      if (name != null) {
        if (checkElementNameEquivalence(localName, namespace, name, tag)) {
          return createAttributeDescriptor(tag);
        }
      }
    } else if (equalsToSchemaName(tag, INCLUDE_TAG_NAME) ||
               (equalsToSchemaName(tag, IMPORT_TAG_NAME) &&
                namespace.equals(tag.getAttributeValue("namespace"))
               )
      ) {
      final String schemaLocation = tag.getAttributeValue("schemaLocation");

      if (schemaLocation != null) {
        final XmlFile xmlFile = XmlUtil.findNamespace(myTag.getContainingFile(), schemaLocation);

        if (xmlFile != null) {

          final XmlDocument includedDocument = xmlFile.getDocument();
          if (includedDocument != null) {
            final PsiMetaData data = includedDocument.getMetaData();

            if(data instanceof XmlNSDescriptorImpl){
              final XmlAttributeDescriptor attributeDescriptor = ((XmlNSDescriptorImpl)data).getAttributeImpl(localName, namespace,visited);

              if(attributeDescriptor != null){
                final CachedValue<XmlAttributeDescriptor> value = CachedValuesManager.getManager(includedDocument.getProject()).createCachedValue(
                  new CachedValueProvider<XmlAttributeDescriptor>(){
                    @Override
                    public Result<XmlAttributeDescriptor> compute() {
                      Object[] deps = attributeDescriptor.getDependences();
                      if (deps.length == 0) {
                        LOG.error(attributeDescriptor + " (" + attributeDescriptor.getClass() + ") returned no dependencies");
                      }
                      return new Result<XmlAttributeDescriptor>(attributeDescriptor, deps);
                    }
                  },
                  false
                );
                return value.getValue();
              }
            }
          }
        }
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:73,代码来源:XmlNSDescriptorImpl.java


注:本文中的com.intellij.xml.util.XmlUtil.findNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。