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


Java PsiElementProcessor.CollectElements方法代码示例

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


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

示例1: checkPatterns

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public PsiElement checkPatterns(ConfigurationContext context, LinkedHashSet<String> classes) {
  PsiElement[] result;
  final DataContext dataContext = context.getDataContext();
  if (TestsUIUtil.isMultipleSelectionImpossible(dataContext)) {
    return null;
  }
  final PsiElement[] locationElements = collectLocationElements(classes, dataContext);
  PsiElementProcessor.CollectElements<PsiElement> processor = new PsiElementProcessor.CollectElements<PsiElement>();
  if (locationElements != null) {
    collectTestMembers(locationElements, false, true, processor);
    result = processor.toArray();
  }
  else if (collectContextElements(dataContext, true, true, classes, processor)) {
    result = processor.toArray();
  }
  else {
    return null;
  }
  if (result.length <= 1) {
    return null;
  }
  return result[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractPatternBasedConfigurationProducer.java

示例2: findChildrenOfAnyType

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@NotNull
public static <T extends PsiElement> Collection<T> findChildrenOfAnyType(@Nullable final PsiElement element,
                                                                         @NotNull final Class<? extends T>... classes) {
  if (element == null) {
    return ContainerUtil.emptyList();
  }

  PsiElementProcessor.CollectElements<T> processor = new PsiElementProcessor.CollectElements<T>() {
    @Override
    public boolean execute(@NotNull T each) {
      if (each == element) return true;
      if (instanceOf(each, classes)) {
        return super.execute(each);
      }
      return true;
    }
  };
  processElements(element, processor);
  return processor.getCollection();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiTreeUtil.java

示例3: getDependences

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
public Object[] getDependences() {
  if (myPattern != null) {
    if (DumbService.isDumb(myElement.getProject())) {
      return new Object[] { ModificationTracker.EVER_CHANGED, ExternalResourceManager.getInstance()};
    }
    final Object[] a = { myElement, ExternalResourceManager.getInstance() };
    final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<XmlFile>();
    RelaxIncludeIndex.processForwardDependencies(myFile, processor);
    if (processor.getCollection().size() > 0) {
      return ArrayUtil.mergeArrays(a, processor.toArray());
    } else {
      return a;
    }
  }
  return new Object[]{ ModificationTracker.EVER_CHANGED };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RngNsDescriptor.java

示例4: visitDefine

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
public void visitDefine(RncDefine pattern) {
  final RncGrammar grammar = PsiTreeUtil.getParentOfType(pattern, RncGrammar.class);
  final PsiFile file = pattern.getContainingFile();
  if (grammar != null) {
    if (processRncUsages(pattern, new LocalSearchScope(grammar))) return;
  } else {
    if (processRncUsages(pattern, new LocalSearchScope(file))) return;
  }

  final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<XmlFile>();
  RelaxIncludeIndex.processBackwardDependencies((XmlFile)file, collector);

  if (processRncUsages(pattern, new LocalSearchScope(collector.toArray()))) return;

  final ASTNode astNode = ((RncDefineImpl)pattern).getNameNode();
  myHolder.registerProblem(astNode.getPsi(), "Unreferenced define", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new MyFix<RncDefine>(pattern));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:UnusedDefineInspection.java

示例5: collectTestMembers

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public void collectTestMembers(PsiElement[] psiElements,
                               boolean checkAbstract,
                               boolean checkIsTest,
                               PsiElementProcessor.CollectElements<PsiElement> collectingProcessor) {
  for (PsiElement psiElement : psiElements) {
    if (psiElement instanceof PsiClassOwner) {
      final PsiClass[] classes = ((PsiClassOwner)psiElement).getClasses();
      for (PsiClass aClass : classes) {
        if ((!checkIsTest && aClass.hasModifierProperty(PsiModifier.PUBLIC) || checkIsTest && isTestClass(aClass)) && 
            !collectingProcessor.execute(aClass)) {
          return;
        }
      }
    } else if (psiElement instanceof PsiClass) {
      if ((!checkIsTest && ((PsiClass)psiElement).hasModifierProperty(PsiModifier.PUBLIC) || checkIsTest && isTestClass((PsiClass)psiElement)) && 
          !collectingProcessor.execute(psiElement)) {
        return;
      }
    } else if (psiElement instanceof PsiMethod) {
      if (checkIsTest && isTestMethod(checkAbstract, psiElement) && !collectingProcessor.execute(psiElement)) {
        return;
      }
      if (!checkIsTest) {
        final PsiClass containingClass = ((PsiMethod)psiElement).getContainingClass();
        if (containingClass != null && containingClass.hasModifierProperty(PsiModifier.PUBLIC) && !collectingProcessor.execute(psiElement)) {
          return;
        }
      }
    } else if (psiElement instanceof PsiDirectory) {
      final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory)psiElement);
      if (aPackage != null && !collectingProcessor.execute(aPackage)) {
        return;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AbstractPatternBasedConfigurationProducer.java

示例6: collectContextElements

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private boolean collectContextElements(DataContext dataContext,
                                       boolean checkAbstract,
                                       boolean checkIsTest, 
                                       LinkedHashSet<String> classes,
                                       PsiElementProcessor.CollectElements<PsiElement> processor) {
  PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
  if (elements != null) {
    collectTestMembers(elements, checkAbstract, checkIsTest, processor);
    for (PsiElement psiClass : processor.getCollection()) {
      classes.add(getQName(psiClass));
    }
    return true;
  }
  else {
    final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (files != null) {
      Project project = CommonDataKeys.PROJECT.getData(dataContext);
      if (project != null) {
        final PsiManager psiManager = PsiManager.getInstance(project);
        for (VirtualFile file : files) {
          final PsiFile psiFile = psiManager.findFile(file);
          if (psiFile instanceof PsiClassOwner) {
            collectTestMembers(((PsiClassOwner)psiFile).getClasses(), checkAbstract, checkIsTest, processor);
            for (PsiElement psiMember : processor.getCollection()) {
              classes.add(((PsiClass)psiMember).getQualifiedName());
            }
          }
        }
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:AbstractPatternBasedConfigurationProducer.java

示例7: getChildren

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElement[] getChildren() {
  final PsiElementProcessor.CollectElements<PsiFileSystemItem> collector = new PsiElementProcessor.CollectElements<PsiFileSystemItem>();
  processChildren(collector);
  return collector.toArray(new PsiFileSystemItem[0]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:SyntheticFileSystemItem.java

示例8: getCachedSchema

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public static Schema getCachedSchema(final XmlFile descriptorFile) {
  CachedValue<Schema> value = descriptorFile.getUserData(SCHEMA_KEY);
  if (value == null) {
    final CachedValueProvider<Schema> provider = new CachedValueProvider<Schema>() {
      @Override
      public Result<Schema> compute() {
        final InputSource inputSource = makeInputSource(descriptorFile);

        try {
          final Schema schema = new MySchemaReader(descriptorFile).createSchema(inputSource, EMPTY_PROPS);
          final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<XmlFile>();
          RelaxIncludeIndex.processForwardDependencies(descriptorFile, processor);
          if (processor.getCollection().size() > 0) {
            return Result.create(schema, processor.toArray(), descriptorFile);
          } else {
            return Result.createSingleDependency(schema, descriptorFile);
          }
        } catch (Exception e) {
          LOG.info(e);
          return Result.createSingleDependency(null, descriptorFile);
        }
      }
    };

    final CachedValuesManager mgr = CachedValuesManager.getManager(descriptorFile.getProject());
    value = mgr.createCachedValue(provider,  false);
    descriptorFile.putUserData(SCHEMA_KEY, value);
  }
  return value.getValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:RngParser.java

示例9: getClickAction

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
@Override
@Nullable
public AnAction getClickAction() {
  return new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      final PsiElement element = myDefine.getPsiElement();
      if (element == null || !element.isValid()) return;

      final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<XmlFile>();
      final XmlFile localFile = (XmlFile)element.getContainingFile();
      RelaxIncludeIndex.processBackwardDependencies(localFile, collector);
      final Collection<XmlFile> files = collector.getCollection();

      final List<Define> result = new SmartList<Define>();
      final OverriddenDefineSearcher searcher = new OverriddenDefineSearcher(myDefine, localFile, result);
      for (XmlFile file : files) {
        final Grammar grammar = GrammarFactory.getGrammar(file);
        if (grammar == null) continue;
        grammar.acceptChildren(searcher);
      }

      if (result.size() > 0) {
        OverridingDefineRenderer.doClickAction(e, result, "Go to overriding define(s)");
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:OverriddenDefineRenderer.java

示例10: collectContextElements

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
private static boolean collectContextElements(
    DataContext dataContext,
    boolean checkAbstract,
    boolean checkIsTest,
    PsiElementProcessor.CollectElements<PsiElement> processor) {
  PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
  if (elements != null) {
    collectTestMembers(elements, checkAbstract, checkIsTest, processor);
    return true;
  } else {
    final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (files != null) {
      Project project = CommonDataKeys.PROJECT.getData(dataContext);
      if (project != null) {
        final PsiManager psiManager = PsiManager.getInstance(project);
        for (VirtualFile file : files) {
          final PsiFile psiFile = psiManager.findFile(file);
          if (psiFile instanceof PsiClassOwner) {
            collectTestMembers(
                ((PsiClassOwner) psiFile).getClasses(), checkAbstract, checkIsTest, processor);
          }
        }
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:29,代码来源:JUnitConfigurationUtil.java

示例11: visitXmlTag

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public void visitXmlTag(XmlTag tag) {
  final PsiFile file = tag.getContainingFile();
  if (file.getFileType() != StdFileTypes.XML) {
    return;
  }
  if (!tag.getLocalName().equals("define")) {
    return;
  }
  if (!tag.getNamespace().equals(ApplicationLoader.RNG_NAMESPACE)) {
    return;
  }
  if (tag.getAttribute("combine") != null) {
    return; // ?
  }

  final XmlAttribute attr = tag.getAttribute("name");
  if (attr == null) return;

  final XmlAttributeValue value = attr.getValueElement();
  if (value == null) return;

  final String s = value.getValue();
  if (s == null || s.length() == 0) {
    return;
  }
  final PsiElement parent = value.getParent();
  if (!(parent instanceof XmlAttribute)) {
    return;
  }
  if (!"name".equals(((XmlAttribute)parent).getName())) {
    return;
  }
  final PsiElement grandParent = parent.getParent();
  if (!(grandParent instanceof XmlTag)) {
    return;
  }

  final DomElement element = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
  if (element == null) {
    return;
  }

  final RngGrammar rngGrammar = element.getParentOfType(RngGrammar.class, true);
  if (rngGrammar != null) {
    if (processUsages(tag, value, new LocalSearchScope(rngGrammar.getXmlTag()))) return;
  } else {
    if (processUsages(tag, value, new LocalSearchScope(file))) return;
  }

  final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<XmlFile>();
  RelaxIncludeIndex.processBackwardDependencies((XmlFile)file, collector);

  if (processUsages(tag, value, new LocalSearchScope(collector.toArray()))) return;

  myHolder.registerProblem(value, "Unreferenced define", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new MyFix<XmlTag>(tag));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:UnusedDefineInspection.java

示例12: collectTestMembers

import com.intellij.psi.search.PsiElementProcessor; //导入方法依赖的package包/类
public static void collectTestMembers(
    PsiElement[] psiElements,
    boolean checkAbstract,
    boolean checkIsTest,
    PsiElementProcessor.CollectElements<PsiElement> collectingProcessor) {
  for (PsiElement psiElement : psiElements) {
    if (psiElement instanceof PsiClassOwner) {
      final PsiClass[] classes = ((PsiClassOwner) psiElement).getClasses();
      for (PsiClass aClass : classes) {
        if ((!checkIsTest && aClass.hasModifierProperty(PsiModifier.PUBLIC)
                || checkIsTest && JUnitUtil.isTestClass(aClass))
            && !collectingProcessor.execute(aClass)) {
          return;
        }
      }
    } else if (psiElement instanceof PsiClass) {
      if ((!checkIsTest && ((PsiClass) psiElement).hasModifierProperty(PsiModifier.PUBLIC)
              || checkIsTest && JUnitUtil.isTestClass((PsiClass) psiElement))
          && !collectingProcessor.execute(psiElement)) {
        return;
      }
    } else if (psiElement instanceof PsiMethod) {
      if (checkIsTest
          && isTestMethod(checkAbstract, psiElement)
          && !collectingProcessor.execute(psiElement)) {
        return;
      }
      if (!checkIsTest) {
        final PsiClass containingClass = ((PsiMethod) psiElement).getContainingClass();
        if (containingClass != null
            && containingClass.hasModifierProperty(PsiModifier.PUBLIC)
            && !collectingProcessor.execute(psiElement)) {
          return;
        }
      }
    } else if (psiElement instanceof PsiDirectory) {
      final PsiPackage aPackage =
          JavaDirectoryService.getInstance().getPackage((PsiDirectory) psiElement);
      if (aPackage != null && !collectingProcessor.execute(aPackage)) {
        return;
      }
    }
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:45,代码来源:JUnitConfigurationUtil.java


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