org.jetbrains.uast.UQualifiedReferenceExpression Java Examples

The following examples show how to use org.jetbrains.uast.UQualifiedReferenceExpression. 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: AirConUsageDetector.java    From aircon with MIT License 5 votes vote down vote up
@Override
public boolean visitQualifiedReferenceExpression(@NotNull final UQualifiedReferenceExpression node) {
	for (IssueDetector issueDetector : mIssueDetectors) {
		issueDetector.visit(node);
	}
	return super.visitQualifiedReferenceExpression(node);
}
 
Example #2
Source File: ConfigFieldReferenceDetector.java    From aircon with MIT License 5 votes vote down vote up
@Override
public void visit(final UQualifiedReferenceExpression node) {
	final PsiField referencedField = ElementUtils.getReferencedField(node.getJavaPsi());
	if (referencedField != null) {
		visitFieldReference(node, referencedField);
	}
}
 
Example #3
Source File: ConfigFieldReferenceDetector.java    From aircon with MIT License 5 votes vote down vote up
private void visitFieldReference(final @NotNull UQualifiedReferenceExpression node, final PsiField field) {
	final PsiClass containingClass = ElementUtils.getContainingClass(node);
	if (!ConfigElementsUtils.hasFeatureRemoteConfigAnnotation(containingClass)) {
		final boolean remoteConfigField = ConfigElementsUtils.hasConfigAnnotation(field);
		if (remoteConfigField) {
			report(node, ISSUE.getExplanation(TextFormat.TEXT) + " **" + CommonNamingUtils.getProviderClassName(field.getContainingClass()
			                                                                                                         .getName()) + "**");
		}
	}
}
 
Example #4
Source File: IssueDetector.java    From aircon with MIT License 4 votes vote down vote up
public void visit(final UQualifiedReferenceExpression node) {
	// No-op, to be overridden
}
 
Example #5
Source File: CallOnRequestPermissionsResultDetector.java    From PermissionsDispatcher with Apache License 2.0 4 votes vote down vote up
private static boolean isGeneratedMethodCalled(UMethod method, String className, boolean isKotlin) {
    UExpression methodBody = method.getUastBody();
    if (methodBody == null) {
        return false;
    }
    if (methodBody instanceof UBlockExpression) {
        UBlockExpression methodBodyExpression = (UBlockExpression) methodBody;
        List<UExpression> expressions = methodBodyExpression.getExpressions();
        for (UExpression expression : expressions) {
            if (isKotlin && expression instanceof KotlinUFunctionCallExpression) {
                KotlinUFunctionCallExpression functionalExpression = (KotlinUFunctionCallExpression) expression;
                if ("onRequestPermissionsResult".equals(functionalExpression.getMethodName())) {
                    return true;
                }
            }

            if (!(expression instanceof UQualifiedReferenceExpression)) {
                continue;
            }

            UQualifiedReferenceExpression referenceExpression = (UQualifiedReferenceExpression) expression;
            UExpression receiverExpression = referenceExpression.getReceiver();
            PsiElement receiverPsi = receiverExpression.getPsi();
            if (receiverPsi == null) {
                continue; // can this case be happened?
            }
            String receiverName = receiverPsi.getText();
            if ("super".equals(receiverName)) {
                // skip super method call
                continue;
            }

            if (isKotlin && referenceExpression instanceof KotlinUQualifiedReferenceExpression) {
                if ("onRequestPermissionsResult".equals(referenceExpression.getResolvedName())) {
                    return true;
                }
            } else {
                String targetClassName = className + "PermissionsDispatcher";
                if (targetClassName.equals(receiverName) && "onRequestPermissionsResult".equals(referenceExpression.getResolvedName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #6
Source File: InvalidR2UsageDetector.java    From butterknife with Apache License 2.0 4 votes vote down vote up
@Override public boolean visitQualifiedReferenceExpression(UQualifiedReferenceExpression node) {
  detectR2(context, node);
  return super.visitQualifiedReferenceExpression(node);
}