示例#1
0
 private static void ensureAtLeast(
     @NonNull JavaContext context, @NonNull UCallExpression node, int parameter, long min) {
   UExpression argument = node.getValueArguments().get(parameter);
   long value = getLongValue(context, argument);
   if (value < min) {
     String message =
         String.format(
             "Value will be forced up to %1$d as of Android 5.1; "
                 + "don't rely on this to be exact",
             min);
     context.report(ISSUE, argument, context.getUastLocation(argument), message);
   }
 }
 @Override
 public void visitReference(
     @NonNull JavaContext context,
     @Nullable UastVisitor visitor,
     @NonNull UReferenceExpression reference,
     @NonNull PsiElement resolved) {
   if (resolved instanceof PsiField
       && JavaEvaluator.isMemberInClass((PsiField) resolved, "android.view.MenuItem")) {
     if ("SHOW_AS_ACTION_ALWAYS".equals(((PsiField) resolved).getName())) {
       if (context.getDriver().isSuppressed(context, ISSUE, reference)) {
         return;
       }
       if (mAlwaysFields == null) {
         mAlwaysFields = new ArrayList<Location>();
       }
       mAlwaysFields.add(context.getUastLocation(reference));
     } else {
       mHasIfRoomRefs = true;
     }
   }
 }