Java Code Examples for com.intellij.psi.PsiElement#accept()
The following examples show how to use
com.intellij.psi.PsiElement#accept() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaImportsUtil.java From KodeBeagle with Apache License 2.0 | 6 votes |
public final Map<String, Set<String>> getImportInLines(final Editor projectEditor, final Pair<Integer, Integer> pair) { PsiDocumentManager psiInstance = PsiDocumentManager.getInstance(windowObjects.getProject()); PsiJavaFile psiJavaFile = (PsiJavaFile) psiInstance.getPsiFile(projectEditor.getDocument()); PsiJavaElementVisitor psiJavaElementVisitor = new PsiJavaElementVisitor(pair.getFirst(), pair.getSecond()); Map<String, Set<String>> finalImports = new HashMap<>(); if (psiJavaFile != null && psiJavaFile.findElementAt(pair.getFirst()) != null) { PsiElement psiElement = psiJavaFile.findElementAt(pair.getFirst()); final PsiElement psiMethod = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class); if (psiMethod != null) { psiMethod.accept(psiJavaElementVisitor); } else { final PsiClass psiClass = PsiTreeUtil.getParentOfType(psiElement, PsiClass.class); if (psiClass != null) { psiClass.accept(psiJavaElementVisitor); } } Map<String, Set<String>> importVsMethods = psiJavaElementVisitor.getImportVsMethods(); finalImports = getImportsAndMethodsAfterValidation(psiJavaFile, importVsMethods); } return removeImplicitImports(finalImports); }
Example 2
Source File: ShaderLabFoldingBuilder.java From consulo-unity3d with Apache License 2.0 | 6 votes |
@Override protected void buildLanguageFoldRegions(@Nonnull final List<FoldingDescriptor> descriptors, @Nonnull PsiElement root, @Nonnull Document document, boolean quick) { root.accept(new SharpLabElementVisitor() { @Override public void visitElement(PsiElement element) { if(element instanceof ShaderBraceOwner) { descriptors.add(new FoldingDescriptor(element, element.getTextRange())); } element.acceptChildren(this); } }); }
Example 3
Source File: CSharpStoppableRecursiveElementVisitor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Override @RequiredReadAction public void visitElement(PsiElement element) { ProgressManager.checkCanceled(); if(myValue != null) { return; } PsiElement child = element.getFirstChild(); while(child != null) { if(myValue != null) { return; } child.accept(this); child = child.getNextSibling(); } }
Example 4
Source File: UnusedUsingVisitor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nonnull public static UnusedUsingVisitor accept(@Nonnull PsiFile file) { final UnusedUsingVisitor unusedUsingVisitor = new UnusedUsingVisitor(); PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() { @Override public void visitElement(PsiElement element) { element.accept(unusedUsingVisitor); super.visitElement(element); } }; file.accept(visitor); return unusedUsingVisitor; }
Example 5
Source File: CSharpDebuggerSourceLineResolver.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nonnull @Override public Set<PsiElement> getAllExecutableChildren(@Nonnull PsiElement root) { final Set<PsiElement> lambdas = new LinkedHashSet<>(); root.accept(new CSharpRecursiveElementVisitor() { @Override public void visitAnonymMethodExpression(CSharpDelegateExpressionImpl method) { lambdas.add(method); } @Override public void visitLambdaExpression(CSharpLambdaExpressionImpl expression) { lambdas.add(expression); } }); return lambdas; }
Example 6
Source File: SimpleDuplicatesFinder.java From consulo with Apache License 2.0 | 5 votes |
private void annotatePattern() { for (final PsiElement patternComponent : myPattern) { patternComponent.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { super.visitElement(element); if (myParameters.contains(element.getText())) { element.putUserData(PARAMETER, element); } } }); } }
Example 7
Source File: BuildAnnotator.java From intellij with Apache License 2.0 | 5 votes |
@Override public synchronized void annotate(PsiElement element, AnnotationHolder holder) { this.holder = holder; try { element.accept(this); } finally { this.holder = null; } }
Example 8
Source File: SimpleDuplicatesFinder.java From consulo with Apache License 2.0 | 5 votes |
private void deannotatePattern() { for (final PsiElement patternComponent : myPattern) { patternComponent.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { if (element.getUserData(PARAMETER) != null) { element.putUserData(PARAMETER, null); } } }); } }
Example 9
Source File: CSharpStubBuilderVisitor.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction public static List<StubBlock> buildBlocks(PsiElement qualifiedElement, boolean compiled) { CSharpStubBuilderVisitor visitor = new CSharpStubBuilderVisitor(compiled); qualifiedElement.accept(visitor); return visitor.getBlocks(); }
Example 10
Source File: ExpectedTypeVisitor.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull public static List<ExpectedTypeInfo> findExpectedTypeRefs(@Nonnull PsiElement psiElement) { PsiElement parent = psiElement.getParent(); if(parent == null) { return Collections.emptyList(); } ExpectedTypeVisitor expectedTypeVisitor = new ExpectedTypeVisitor(psiElement); parent.accept(expectedTypeVisitor); return ContainerUtil.filter(expectedTypeVisitor.getExpectedTypeInfos(), it -> it.getTypeRef() != DotNetTypeRef.ERROR_TYPE); }
Example 11
Source File: CSharpAllTypesSearchExecutor.java From consulo-csharp with Apache License 2.0 | 5 votes |
private static boolean processScopeRootForAllClasses(PsiElement scopeRoot, final Processor<? super DotNetTypeDeclaration> processor) { if(scopeRoot == null) { return true; } final boolean[] stopped = new boolean[]{false}; scopeRoot.accept(new CSharpRecursiveElementVisitor() { @Override public void visitElement(PsiElement element) { if(!stopped[0]) { super.visitElement(element); } } @Override public void visitTypeDeclaration(CSharpTypeDeclaration aClass) { stopped[0] = !processor.process(aClass); super.visitTypeDeclaration(aClass); } }); return !stopped[0]; }
Example 12
Source File: GoogleTestLocation.java From intellij with Apache License 2.0 | 5 votes |
private void visitRecursively(PsiElement element) { PsiElement child = element.getFirstChild(); while (child != null && !foundGtestMacroCall) { child.accept(this); child = child.getNextSibling(); } }
Example 13
Source File: CSharpExpressionEvaluator.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override @RequiredReadAction public void visitMethodCallExpression(CSharpMethodCallExpressionImpl expression) { DotNetExpression callExpression = expression.getCallExpression(); ResolveResult resolveResult = CSharpResolveUtil.findFirstValidResult(expression.multiResolve(false)); if(resolveResult == null || !(resolveResult instanceof MethodResolveResult) || !(resolveResult.getElement() instanceof CSharpMethodDeclaration)) { cantEvaluateExpression(); } CSharpMethodDeclaration methodDeclaration = (CSharpMethodDeclaration) resolveResult.getElement(); if(callExpression instanceof CSharpReferenceExpression) { CSharpTypeDeclaration typeDeclaration = null; PsiElement qualifier = ((CSharpReferenceExpression) callExpression).getQualifier(); if(qualifier != null) { qualifier.accept(this); } else { if(methodDeclaration.hasModifier(DotNetModifier.STATIC)) { typeDeclaration = (CSharpTypeDeclaration) methodDeclaration.getParent(); myEvaluators.add(StaticObjectEvaluator.INSTANCE); } else { myEvaluators.add(ThisObjectEvaluator.INSTANCE); } } String referenceName = ((CSharpReferenceExpression) callExpression).getReferenceName(); if(referenceName == null) { cantEvaluateExpression(); } pushNArguments((MethodResolveResult) resolveResult); pushMethodEvaluator(expression, methodDeclaration, typeDeclaration, referenceName); } }
Example 14
Source File: CSharpCompilerCheckVisitor.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override public void visit(@Nonnull PsiElement element) { element.accept(this); }
Example 15
Source File: CS0136.java From consulo-csharp with Apache License 2.0 | 4 votes |
private AnalyzeContext(PsiElement e) { e.accept(this); }
Example 16
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 4 votes |
@Override public void visit(@Nonnull PsiElement element) { element.accept(this); }
Example 17
Source File: PhpMethodVariableResolveUtil.java From idea-php-symfony2-plugin with MIT License | 4 votes |
/** * Visit all possible elements for render clements, scope shop be the class or a file itself */ public static void visitRenderTemplateFunctions(@NotNull PsiElement context, @NotNull Consumer<Triple<String, PhpNamedElement, FunctionReference>> consumer) { context.accept(new TemplateRenderPsiRecursiveElementWalkingVisitor(context, consumer)); }
Example 18
Source File: BladeTemplateUtil.java From idea-php-laravel-plugin with MIT License | 3 votes |
public static Collection<Pair<String, PsiElement>> getViewTemplatesPairScope(@NotNull PsiElement psiElement) { Collection<Pair<String, PsiElement>> views = new ArrayList<>(); psiElement.accept(new MyViewRecursiveElementWalkingVisitor(views)); return views; }