本文整理汇总了Java中com.intellij.psi.search.PsiElementProcessor类的典型用法代码示例。如果您正苦于以下问题:Java PsiElementProcessor类的具体用法?Java PsiElementProcessor怎么用?Java PsiElementProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiElementProcessor类属于com.intellij.psi.search包,在下文中一共展示了PsiElementProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processImplementations
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
public static boolean processImplementations(final PsiClass psiClass, final Processor<PsiElement> processor, SearchScope scope) {
if (!FunctionalExpressionSearch.search(psiClass, scope).forEach(new Processor<PsiFunctionalExpression>() {
@Override
public boolean process(PsiFunctionalExpression expression) {
return processor.process(expression);
}
})) {
return false;
}
final boolean showInterfaces = Registry.is("ide.goto.implementation.show.interfaces");
return ClassInheritorsSearch.search(psiClass, scope, true).forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
public boolean execute(@NotNull PsiClass element) {
if (!showInterfaces && element.isInterface()) {
return true;
}
return processor.process(element);
}
}));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ClassImplementationsSearch.java
示例2: addExprTypesByDerivedClasses
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
private void addExprTypesByDerivedClasses(LinkedHashSet<PsiType> set, PsiExpression expr) {
PsiType type = expr.getType();
if (!(type instanceof PsiClassType)) return;
PsiClass refClass = PsiUtil.resolveClassInType(type);
if (refClass == null) return;
PsiManager manager = PsiManager.getInstance(myProject);
PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5);
ClassInheritorsSearch.search(refClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
if (processor.isOverflow()) return;
for (PsiClass derivedClass : processor.getCollection()) {
if (derivedClass instanceof PsiAnonymousClass) continue;
PsiType derivedType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(derivedClass);
set.add(derivedType);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GuessManagerImpl.java
示例3: 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
示例4: update
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
final Presentation presentation = e.getPresentation();
presentation.setVisible(false);
final DataContext dataContext = e.getDataContext();
final PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
if (psiElements != null) {
PsiElementProcessor.CollectElementsWithLimit<PsiElement> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiElement>(2);
getPatternBasedProducer().collectTestMembers(psiElements, false, false, processor);
Collection<PsiElement> collection = processor.getCollection();
if (collection.isEmpty()) return;
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
final List<T> foundConfigurations = collectPatternConfigurations(collection, project);
if (!foundConfigurations.isEmpty()) {
presentation.setVisible(true);
if (foundConfigurations.size() == 1) {
presentation.setText("Add to temp suite: " + foundConfigurations.get(0).getName());
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AbstractAddToTestsPatternAction.java
示例5: getOverriddenMethodTooltip
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
private static String getOverriddenMethodTooltip(@NotNull PsiMethod method) {
PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(5);
OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(processor));
boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
if (processor.isOverflow()){
return isAbstract ? DaemonBundle.message("method.is.implemented.too.many") : DaemonBundle.message("method.is.overridden.too.many");
}
PsiMethod[] overridings = processor.toArray(PsiMethod.EMPTY_ARRAY);
if (overridings.length == 0) {
final PsiClass aClass = method.getContainingClass();
if (aClass != null && FunctionalExpressionSearch.search(aClass).findFirst() != null) {
return "Has functional implementations";
}
return null;
}
Comparator<PsiMethod> comparator = new MethodCellRenderer(false).getComparator();
Arrays.sort(overridings, comparator);
String start = isAbstract ? DaemonBundle.message("method.is.implemented.header") : DaemonBundle.message("method.is.overriden.header");
@NonNls String pattern = " <a href=\"#javaClass/{1}\">{1}</a>";
return composeText(overridings, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MarkerType.java
示例6: findChildOfType
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Nullable
private static <T extends PsiElement> T findChildOfType(@Nullable final PsiElement element,
@NotNull final Class<T> aClass,
@Nullable final Class<? extends PsiElement> stopAt) {
final PsiElementProcessor.FindElement<PsiElement> processor = new PsiElementProcessor.FindElement<PsiElement>() {
@Override
public boolean execute(@NotNull PsiElement each) {
if (each == element) return true; // strict
if (aClass.isInstance(each)) {
return setFound(each);
}
return stopAt == null || !stopAt.isInstance(each);
}
};
PsiTreeUtil.processElements(element, processor);
//noinspection unchecked
return (T)processor.getFoundElement();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StatementMover.java
示例7: _findImplementingClasses
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
private static void _findImplementingClasses(PsiClass anInterface, final Set<PsiClass> visited, final Collection<PsiClass> result) {
LOG.assertTrue(anInterface.isInterface());
visited.add(anInterface);
ClassInheritorsSearch.search(anInterface, false).forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
public boolean execute(@NotNull PsiClass aClass) {
if (!aClass.isInterface()) {
result.add(aClass);
}
else if (!visited.contains(aClass)){
_findImplementingClasses(aClass, visited, result);
}
return true;
}
}));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RefactoringHierarchyUtil.java
示例8: findChildOfAnyType
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
/**
* Recursive (depth first) search for first element of any of given {@code classes}.
*
* @param element a PSI element to start search from.
* @param strict if false the {@code element} is also included in the search.
* @param classes element types to search for.
* @param <T> type to cast found element to.
* @return first found element, or null if nothing found.
*/
@Nullable
@Contract("null, _, _ -> null")
public static <T extends PsiElement> T findChildOfAnyType(@Nullable final PsiElement element,
final boolean strict,
@NotNull final Class<? extends T>... classes) {
PsiElementProcessor.FindElement<PsiElement> processor = new PsiElementProcessor.FindElement<PsiElement>() {
@Override
public boolean execute(@NotNull PsiElement each) {
if (strict && each == element) return true;
if (instanceOf(each, classes)) {
return setFound(each);
}
return true;
}
};
processElements(element, processor);
//noinspection unchecked
return (T)processor.getFoundElement();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PsiTreeUtil.java
示例9: 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
示例10: processChildren
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
checkValid();
ProgressIndicatorProvider.checkCanceled();
for (VirtualFile vFile : myFile.getChildren()) {
boolean isDir = vFile.isDirectory();
if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
continue;
}
PsiFileSystemItem item = isDir ? myManager.findDirectory(vFile) : myManager.findFile(vFile);
if (item != null && !processor.execute(item)) {
return false;
}
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PsiDirectoryImpl.java
示例11: getChildren
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
@NotNull
public PsiElement[] getChildren() {
checkValid();
VirtualFile[] files = myFile.getChildren();
final ArrayList<PsiElement> children = new ArrayList<PsiElement>(files.length);
processChildren(new PsiElementProcessor<PsiFileSystemItem>() {
@Override
public boolean execute(@NotNull final PsiFileSystemItem element) {
children.add(element);
return true;
}
});
return PsiUtilCore.toPsiElementArray(children);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiDirectoryImpl.java
示例12: chooseAmbiguousTargetAndPerform
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
static void chooseAmbiguousTargetAndPerform(@NotNull final Project project,
final Editor editor,
@NotNull PsiElementProcessor<PsiElement> processor) {
if (editor == null) {
Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"), CommonBundle.getErrorTitle(),
Messages.getErrorIcon());
}
else {
int offset = editor.getCaretModel().getOffset();
boolean chosen = GotoDeclarationAction.chooseAmbiguousTarget(editor, offset, processor, FindBundle.message("find.usages.ambiguous.title"), null);
if (!chosen) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (editor.isDisposed() || !editor.getComponent().isShowing()) return;
HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error"));
}
}, project.getDisposed());
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FindUsagesAction.java
示例13: getChildrenImpl
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Nullable
@Override
protected Collection<AbstractTreeNode> getChildrenImpl() {
if (isAlwaysLeaf()) return Collections.emptyList();
return ApplicationManager.getApplication().runReadAction(new Computable<Collection<AbstractTreeNode>>() {
@Override
public Collection<AbstractTreeNode> compute() {
final PsiFileSystemItem value = getValue();
if (value == null || !value.isValid()) return Collections.emptyList();
final List<AbstractTreeNode> list = ContainerUtil.newArrayList();
value.processChildren(new PsiElementProcessor<PsiFileSystemItem>() {
@Override
public boolean execute(@NotNull PsiFileSystemItem element) {
if (!myRootType.isIgnored(value.getProject(), element.getVirtualFile())) {
list.add(new MyPsiNode(value.getProject(), myRootType, element));
}
return true;
}
});
return list;
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ScratchProjectViewPane.java
示例14: findFirstDocString
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Nullable
private String findFirstDocString() {
final PsiElementProcessor.FindElement<PsiElement> processor = new PsiElementProcessor.FindElement<PsiElement>() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof PyStringLiteralExpression && element.getFirstChild().getNode().getElementType() == PyTokenTypes.DOCSTRING) {
return setFound(element);
}
return true;
}
};
PsiTreeUtil.processElements(myFixture.getFile(), processor);
if (!processor.isFound()) {
return null;
}
final PsiElement foundElement = processor.getFoundElement();
assertNotNull(foundElement);
return ((PyStringLiteralExpression)foundElement).getStringValue();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PySectionBasedDocStringTest.java
示例15: resolve
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
public RegExpGroup resolve() {
final int index = getIndex();
final PsiElementProcessor.FindFilteredElement<RegExpElement> processor = new PsiElementProcessor.FindFilteredElement<RegExpElement>(new PsiElementFilter() {
int groupCount;
public boolean isAccepted(PsiElement element) {
if (element instanceof RegExpGroup) {
if (((RegExpGroup)element).isCapturing() && ++groupCount == index) {
return true;
}
}
return element == RegExpBackrefImpl.this;
}
});
PsiTreeUtil.processElements(getContainingFile(), processor);
if (processor.getFoundElement() instanceof RegExpGroup) {
return (RegExpGroup)processor.getFoundElement();
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RegExpBackrefImpl.java
示例16: resolve
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Nullable
public RegExpGroup resolve() {
final PsiElementProcessor.FindFilteredElement<RegExpGroup> processor = new PsiElementProcessor.FindFilteredElement<RegExpGroup>(
new PsiElementFilter() {
public boolean isAccepted(PsiElement element) {
if (!(element instanceof RegExpGroup)) {
return false;
}
final RegExpGroup regExpGroup = (RegExpGroup)element;
return (regExpGroup.isPythonNamedGroup() || regExpGroup.isRubyNamedGroup()) &&
Comparing.equal(getGroupName(), regExpGroup.getGroupName());
}
}
);
PsiTreeUtil.processElements(getContainingFile(), processor);
return processor.getFoundElement();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RegExpNamedGroupRefImpl.java
示例17: resolve
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
@Nullable
public PsiElement resolve() {
final PsiElement[] result = new PsiElement[1];
process(new PsiElementProcessor<PsiElement>() {
final String canonicalText = getCanonicalText();
@Override
public boolean execute(@NotNull final PsiElement element) {
final String idValue = getIdValue(element);
if (idValue != null && idValue.equals(canonicalText)) {
result[0] = getIdValueElement(element);
return false;
}
return true;
}
});
return result[0];
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:IdRefReference.java
示例18: getVariants
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
final List<String> result = new LinkedList<String>();
process(new PsiElementProcessor<PsiElement>() {
@Override
public boolean execute(@NotNull final PsiElement element) {
String value = getIdValue(element);
if (value != null) {
result.add(value);
}
return true;
}
});
return ArrayUtil.toObjectArray(result);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IdRefReference.java
示例19: implementersHaveOnlyPrivateConstructors
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
private boolean implementersHaveOnlyPrivateConstructors(final PsiClass aClass) {
final GlobalSearchScope scope = GlobalSearchScope.allScope(aClass.getProject());
final PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit(6);
final ProgressManager progressManager = ProgressManager.getInstance();
progressManager.runProcess(new Runnable() {
@Override
public void run() {
ClassInheritorsSearch.search(aClass, scope, true, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
}
}, null);
if (processor.isOverflow()) {
return false;
}
final Collection<PsiClass> implementers = processor.getCollection();
for (PsiClass implementer : implementers) {
if (!implementer.isInterface() && !implementer.hasModifierProperty(PsiModifier.ABSTRACT)) {
if (!hasOnlyPrivateConstructors(implementer)) {
return false;
}
}
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ObjectEqualityInspection.java
示例20: validate
import com.intellij.psi.search.PsiElementProcessor; //导入依赖的package包/类
@Override
public void validate(@NotNull XmlDocument document, @NotNull ValidationHost host) {
if (document.getLanguage() == DTDLanguage.INSTANCE) {
final List<XmlElementDecl> decls = new ArrayList<XmlElementDecl>(3);
XmlUtil.processXmlElements(document, new PsiElementProcessor() {
@Override
public boolean execute(@NotNull final PsiElement element) {
if (element instanceof XmlElementDecl) decls.add((XmlElementDecl)element);
return true;
}
}, false);
XmlUtil.doDuplicationCheckForElements(
decls.toArray(new XmlElementDecl[decls.size()]),
new HashMap<String, XmlElementDecl>(decls.size()),
XML_ELEMENT_DECL_PROVIDER,
host
);
return;
}
ExternalDocumentValidator.doValidation(document,host);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XmlNSDescriptorImpl.java
注:本文中的com.intellij.psi.search.PsiElementProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论