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


Java SchemaTypeInfo类代码示例

本文整理汇总了Java中com.intellij.xml.index.SchemaTypeInfo的典型用法代码示例。如果您正苦于以下问题:Java SchemaTypeInfo类的具体用法?Java SchemaTypeInfo怎么用?Java SchemaTypeInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import com.intellij.xml.index.SchemaTypeInfo; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
  if (queryParameters instanceof XmlTagImpl) {
    final XmlTagImpl xml = (XmlTagImpl) queryParameters;
    if (isTypeElement(xml)) {
      final Collection<SchemaTypeInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<Collection<SchemaTypeInfo>>() {

        @Override
        public Collection<SchemaTypeInfo> compute() {
          return gatherInheritors(xml);
        }
      });

      if (infos != null && ! infos.isEmpty()) {
        final XmlFile file = XmlUtil.getContainingFile(xml);
        final Project project = file.getProject();
        final Module module = ModuleUtilCore.findModuleForPsiElement(queryParameters);
        //if (module == null) return false;

        final VirtualFile vf = file.getVirtualFile();
        String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
          @Override
          public String compute() {
            return XmlNamespaceIndex.getNamespace(vf, project, file);
          }
        });
        thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
        // so thisNs can be null
        if (thisNs == null) return false;
        final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<SchemaTypeInfo>(infos);
        Collections.sort(infosLst);
        final Map<String, Set<XmlFile>> nsMap = new HashMap<String, Set<XmlFile>>();
        for (final SchemaTypeInfo info : infosLst) {
          Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri());
          if (targetFiles == null) {
            targetFiles = new HashSet<XmlFile>();
            if (Comparing.equal(info.getNamespaceUri(), thisNs)) {
              targetFiles.add(file);
            }
            final Collection<XmlFile> files = ApplicationManager.getApplication().runReadAction(new Computable<Collection<XmlFile>>() {
              @Override
              public Collection<XmlFile> compute() {
                return XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module);
              }
            });
            if (files != null) {
              targetFiles.addAll(files);
            }
            nsMap.put(info.getNamespaceUri(), targetFiles);
          }
          if (! targetFiles.isEmpty()) {
            for (final XmlFile targetFile : targetFiles) {
              ApplicationManager.getApplication().runReadAction(new Runnable() {
                @Override
                public void run() {
                  final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri());
                  if (prefixByURI == null) return;
                  final PsiElementProcessor processor = new PsiElementProcessor() {
                    @Override
                    public boolean execute(@NotNull PsiElement element) {
                      if (element instanceof XmlTagImpl) {
                        if (isCertainTypeElement((XmlTagImpl)element, info.getTagName(), prefixByURI) ||
                            isElementWithEmbeddedType((XmlTagImpl)element, info.getTagName(), prefixByURI)) {
                          consumer.process(element);
                          return false;
                        }
                      }
                      return true;
                    }
                  };
                  XmlUtil.processXmlElements(targetFile, processor, true);
                }
              });
            }
          }
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:82,代码来源:SchemaDefinitionsSearch.java

示例2: gatherInheritors

import com.intellij.xml.index.SchemaTypeInfo; //导入依赖的package包/类
private Collection<SchemaTypeInfo> gatherInheritors(XmlTagImpl xml) {
  XmlAttribute name = getNameAttr(xml);
  if (name == null || StringUtil.isEmptyOrSpaces(name.getValue())) return null;
  String localName = name.getValue();
  final boolean hasPrefix = localName.contains(":");
  localName = hasPrefix ? localName.substring(localName.indexOf(':') + 1) : localName;
  final String nsPrefix = hasPrefix ? name.getValue().substring(0, name.getValue().indexOf(':')) : null;

  final XmlFile file = XmlUtil.getContainingFile(xml);
  if (file == null) return null;
  final Project project = file.getProject();
  if (project == null) return null;

  final Set<SchemaTypeInfo> result = new HashSet<SchemaTypeInfo>();
  final ArrayDeque<SchemaTypeInfo> queue = new ArrayDeque<SchemaTypeInfo>();

  String nsUri;
  if (! hasPrefix) {
    nsUri = getDefaultNs(file);
  } else {
    nsUri = XmlUtil.findNamespaceByPrefix(nsPrefix, file.getRootTag());
  }
  if (nsUri == null) return null;

  queue.add(new SchemaTypeInfo(localName, true, nsUri));

  final PairConvertor<String,String,List<Set<SchemaTypeInfo>>> worker =
    SchemaTypeInheritanceIndex.getWorker(project, file.getContainingFile().getVirtualFile());
  while (! queue.isEmpty()) {
    final SchemaTypeInfo info = queue.removeFirst();
    final List<Set<SchemaTypeInfo>> childrenOfType = worker.convert(info.getNamespaceUri(), info.getTagName());
    for (Set<SchemaTypeInfo> infos : childrenOfType) {
      for (SchemaTypeInfo typeInfo : infos) {
        if (typeInfo.isIsTypeName()) {
          queue.add(typeInfo);
        }
        result.add(typeInfo);
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:SchemaDefinitionsSearch.java

示例3: execute

import com.intellij.xml.index.SchemaTypeInfo; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
  if (queryParameters instanceof XmlTagImpl) {
    final XmlTagImpl xml = (XmlTagImpl) queryParameters;
    if (isTypeElement(xml)) {
      final Collection<SchemaTypeInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<Collection<SchemaTypeInfo>>() {

        @Override
        public Collection<SchemaTypeInfo> compute() {
          return gatherInheritors(xml);
        }
      });

      if (infos != null && ! infos.isEmpty()) {
        final XmlFile file = XmlUtil.getContainingFile(xml);
        final Project project = file.getProject();
        final Module module = ModuleUtil.findModuleForPsiElement(queryParameters);
        //if (module == null) return false;

        final VirtualFile vf = file.getVirtualFile();
        String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
          @Override
          public String compute() {
            return XmlNamespaceIndex.getNamespace(vf, project, file);
          }
        });
        thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
        // so thisNs can be null
        if (thisNs == null) return false;
        final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<SchemaTypeInfo>(infos);
        Collections.sort(infosLst);
        final Map<String, Set<XmlFile>> nsMap = new HashMap<String, Set<XmlFile>>();
        for (final SchemaTypeInfo info : infosLst) {
          Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri());
          if (targetFiles == null) {
            targetFiles = new HashSet<XmlFile>();
            if (Comparing.equal(info.getNamespaceUri(), thisNs)) {
              targetFiles.add(file);
            }
            final Collection<XmlFile> files = ApplicationManager.getApplication().runReadAction(new Computable<Collection<XmlFile>>() {
              @Override
              public Collection<XmlFile> compute() {
                return XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module);
              }
            });
            if (files != null) {
              targetFiles.addAll(files);
            }
            nsMap.put(info.getNamespaceUri(), targetFiles);
          }
          if (! targetFiles.isEmpty()) {
            for (final XmlFile targetFile : targetFiles) {
              ApplicationManager.getApplication().runReadAction(new Runnable() {
                @Override
                public void run() {
                  final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri());
                  if (prefixByURI == null) return;
                  final PsiElementProcessor processor = new PsiElementProcessor() {
                    @Override
                    public boolean execute(@NotNull PsiElement element) {
                      if (element instanceof XmlTagImpl) {
                        if (isCertainTypeElement((XmlTagImpl)element, info.getTagName(), prefixByURI) ||
                            isElementWithEmbeddedType((XmlTagImpl)element, info.getTagName(), prefixByURI)) {
                          consumer.process(element);
                          return false;
                        }
                      }
                      return true;
                    }
                  };
                  XmlUtil.processXmlElements(targetFile, processor, true);
                }
              });
            }
          }
        }
      }
    }
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:82,代码来源:SchemaDefinitionsSearch.java

示例4: gatherInheritors

import com.intellij.xml.index.SchemaTypeInfo; //导入依赖的package包/类
private Collection<SchemaTypeInfo> gatherInheritors(XmlTagImpl xml)
{
	XmlAttribute name = getNameAttr(xml);
	if(name == null || StringUtil.isEmptyOrSpaces(name.getValue()))
	{
		return null;
	}
	String localName = name.getValue();
	final boolean hasPrefix = localName.contains(":");
	localName = hasPrefix ? localName.substring(localName.indexOf(':') + 1) : localName;
	final String nsPrefix = hasPrefix ? name.getValue().substring(0, name.getValue().indexOf(':')) : null;

	final XmlFile file = XmlUtil.getContainingFile(xml);
	if(file == null)
	{
		return null;
	}
	final Project project = file.getProject();
	if(project == null)
	{
		return null;
	}

	final Set<SchemaTypeInfo> result = new HashSet<SchemaTypeInfo>();
	final ArrayDeque<SchemaTypeInfo> queue = new ArrayDeque<SchemaTypeInfo>();

	String nsUri;
	if(!hasPrefix)
	{
		nsUri = getDefaultNs(file);
	}
	else
	{
		nsUri = XmlUtil.findNamespaceByPrefix(nsPrefix, file.getRootTag());
	}
	if(nsUri == null)
	{
		return null;
	}

	queue.add(new SchemaTypeInfo(localName, true, nsUri));

	final PairConvertor<String, String, List<Set<SchemaTypeInfo>>> worker = SchemaTypeInheritanceIndex.getWorker(project, file.getContainingFile().getVirtualFile());
	while(!queue.isEmpty())
	{
		final SchemaTypeInfo info = queue.removeFirst();
		final List<Set<SchemaTypeInfo>> childrenOfType = worker.convert(info.getNamespaceUri(), info.getTagName());
		for(Set<SchemaTypeInfo> infos : childrenOfType)
		{
			for(SchemaTypeInfo typeInfo : infos)
			{
				if(typeInfo.isIsTypeName())
				{
					queue.add(typeInfo);
				}
				result.add(typeInfo);
			}
		}
	}
	return result;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:62,代码来源:SchemaDefinitionsSearch.java


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