/** * Returns true if this method looks like it's overriding android.widget.Adapter's getView * method: getView(int position, View convertView, ViewGroup parent) */ private static boolean isViewAdapterMethod(JavaContext context, PsiMethod node) { JavaEvaluator evaluator = context.getEvaluator(); return GET_VIEW.equals(node.getName()) && evaluator.parametersMatch(node, TYPE_INT, CLASS_VIEW, CLASS_VIEWGROUP); } }
/** * Returns true if this method looks like it's overriding * android.view.View's * {@code protected void onLayout(boolean changed, int left, int top, * int right, int bottom)} */ private static boolean isOnLayoutMethod( @NonNull JavaEvaluator evaluator, @NonNull PsiMethod node) { return ON_LAYOUT.equals(node.getName()) && evaluator.parametersMatch(node, TYPE_BOOLEAN, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT); }
/** * Returns true if this method looks like it's overriding android.view.View's * {@code public void layout(int l, int t, int r, int b)} */ private static boolean isLayoutMethod( @NonNull JavaEvaluator evaluator, @NonNull PsiMethod node) { return LAYOUT.equals(node.getName()) && evaluator.parametersMatch(node, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT); }
/** * Returns true if this method looks like it's overriding android.view.View's * {@code protected void onDraw(Canvas canvas)} */ private static boolean isOnDrawMethod( @NonNull JavaEvaluator evaluator, @NonNull PsiMethod node) { return ON_DRAW.equals(node.getName()) && evaluator.parametersMatch(node, CLASS_CANVAS); }
/** * Returns true if this method looks like it's overriding android.view.View's * {@code protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)} */ private static boolean isOnMeasureMethod( @NonNull JavaEvaluator evaluator, @NonNull PsiMethod node) { return ON_MEASURE.equals(node.getName()) && evaluator.parametersMatch(node, TYPE_INT, TYPE_INT); }
@Override public void visitMethod(PsiMethod method) { super.visitMethod(method); if (METHOD_MEDIA_SESSION_PLAY_FROM_SEARCH.equals(method.getName()) && mContext.getEvaluator().parametersMatch(method, TYPE_STRING, BUNDLE_ARG)) { mOnPlayFromSearchFound = true; } } }
private static boolean overridesIsValidFragment( @NonNull JavaEvaluator evaluator, @NonNull PsiClass resolvedClass) { for (PsiMethod method : resolvedClass.findMethodsByName(IS_VALID_FRAGMENT, false)) { if (evaluator.parametersMatch(method, TYPE_STRING)) { return true; } } return false; } }
/** * Returns true if the given method (which is typically looked up by resolving a method call) is * either a method in the exact given class, or if {@code allowInherit} is true, a method in a * class possibly extending the given class, and if the parameter types are the exact types * specified. * * @param method the method in question * @param className the class name the method should be defined in or inherit from (or * if null, allow any class) * @param allowInherit whether we allow checking for inheritance * @param argumentTypes the names of the types of the parameters * @return true if this method is defined in the given class and with the given parameters */ public boolean methodMatches( @NonNull PsiMethod method, @Nullable String className, boolean allowInherit, @NonNull String... argumentTypes) { if (className != null && allowInherit) { if (!isMemberInSubClassOf(method, className, false)) { return false; } } return parametersMatch(method, argumentTypes); }
@Override public void checkClass(@NonNull JavaContext context, @NonNull PsiClass declaration) { String name = declaration.getName(); if (name == null) { // anonymous classes can't be the ones referenced in the manifest return; } String qualifiedName = declaration.getQualifiedName(); if (qualifiedName == null) { return; } if (!mReceiversWithProtectedBroadcastIntentFilter.contains(qualifiedName)) { return; } JavaEvaluator evaluator = context.getEvaluator(); for (PsiMethod method : declaration.findMethodsByName("onReceive", false)) { if (evaluator.parametersMatch(method, CLASS_CONTEXT, CLASS_INTENT)) { checkOnReceive(context, method); } } }
bestMethod = m; if (context.getEvaluator().parametersMatch(m, expectedType)) { bestMethod = m; isExactMatch = true;