com.intellij.psi.JavaElementVisitor Java Examples

The following examples show how to use com.intellij.psi.JavaElementVisitor. 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: PolygeneFacetType.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
public final boolean value( PsiFile psiFile )
{
    final boolean[] hasPolygeneImportPackage = new boolean[]{ false };

    psiFile.accept( new JavaElementVisitor()
    {
        @Override
        public final void visitImportStatement( PsiImportStatement statement )
        {
            String packageName = statement.getQualifiedName();
            if( packageName != null && packageName.startsWith( "org.apache.polygene" ) )
            {
                hasPolygeneImportPackage[ 0 ] = true;
            }
        }

        @Override
        public void visitReferenceExpression( PsiReferenceExpression expression )
        {
            // Ignore
        }
    } );
    return hasPolygeneImportPackage[ 0 ];
}
 
Example #2
Source File: ThinrDetector.java    From thinr with Apache License 2.0 5 votes vote down vote up
@Override
public JavaElementVisitor createPsiVisitor(@NonNull final JavaContext context) {
    return new JavaElementVisitor() {
        @Override
        public void visitLambdaExpression(PsiLambdaExpression expression) {

            if (!(expression.getParent() instanceof PsiExpressionList)) {
                return;
            }

            PsiExpressionList exprList = (PsiExpressionList) expression.getParent();
            if (!(exprList.getParent() instanceof PsiMethodCallExpression)) {
                return;
            }
            PsiMethodCallExpression call = (PsiMethodCallExpression) exprList.getParent();

            if (call.getType() == null) {
                return;
            }

            String callType = call.getType().getCanonicalText();

            if (!callType.startsWith("de.mobilej.thinr.Thinr")) {
                return;
            }

            markLeakSuspects(expression, expression, context);
        }
    };
}