当前位置: 首页>>代码示例>>Java>>正文


Java JavaEvaluator类代码示例

本文整理汇总了Java中com.android.tools.lint.client.api.JavaEvaluator的典型用法代码示例。如果您正苦于以下问题:Java JavaEvaluator类的具体用法?Java JavaEvaluator怎么用?Java JavaEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaEvaluator类属于com.android.tools.lint.client.api包,在下文中一共展示了JavaEvaluator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNestedStringFormat

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
private static void checkNestedStringFormat(JavaContext context, UCallExpression call) {
  UElement current = call;
  while (true) {
    current = LintUtils.skipParentheses(current.getUastParent());
    if (current == null || current instanceof UMethod) {
      // Reached AST root or code block node; String.format not inside Timber.X(..).
      return;
    }
    if (current instanceof UCallExpression) {
      UCallExpression maybeTimberLogCall = (UCallExpression) current;
      JavaEvaluator evaluator = context.getEvaluator();
      PsiMethod psiMethod = maybeTimberLogCall.resolve();
      if (Pattern.matches(TIMBER_TREE_LOG_METHOD_REGEXP, psiMethod.getName())
          && evaluator.isMemberInClass(psiMethod, "timber.log.Timber")) {
        LintFix fix = quickFixIssueFormat(call);
        context.report(ISSUE_FORMAT, call, context.getLocation(call),
            "Using 'String#format' inside of 'Timber'", fix);
        return;
      }
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:WrongTimberUsageDetector.java

示例2: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean isFragmentPagerAdapter = evaluator.extendsClass(node, CLASS_FRAGMENT_PAGER_ADAPTER, false);
    if (isFragmentPagerAdapter) return;

    boolean isFragmentStatePagerAdapter = evaluator.extendsClass(node, CLASS_FRAGMENT_STATE_PAGER_ADAPTER, false);
    if (isFragmentStatePagerAdapter) return;

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTOPOINT_PAGER_ADAPTER, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_PAGER_ADAPTER, node, context.getLocation(node),
                "Pager Adapter 必须实现DDPagerAdapter,否则不支持自动打点 class:" + node.getName());
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:23,代码来源:AutoPointPagerAdapterDetector.java

示例3: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_ALERT_DIALOG, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_ALERT_DIALOG, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDV7AlertDialog", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointV7AlertDialogDetector.java

示例4: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_EXPANDABLE_LIST_VIEW, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_EXPANDABLE_LIST_VIEW, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDExpandableListView", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointExpandableListViewDetector.java

示例5: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_POP_WINDOW, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_POP_WINDOW, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDPopupWindow", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointPopWindowDetector.java

示例6: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_GRID_VIEW, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_GRID_VIEW, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDGridView", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointGridViewDetector.java

示例7: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_ALERT_DIALOG, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_ALERT_DIALOG, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDAlertDialog", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointAlertDialogDetector.java

示例8: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean autopoint_dialog = evaluator.extendsClass(node, CLASS_AUTO_POINT_DIALOG, false);
    boolean alert_dialog = evaluator.extendsClass(node, CLASS_ALERT_DIALOG, false);
    boolean alert_v7_dialog = evaluator.extendsClass(node, CLASS_ALERT_V7_DIALOG, false);

    if (!alert_v7_dialog && !alert_dialog && !autopoint_dialog) {
        context.report(ISSUE_DIALOG, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDDialog", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:19,代码来源:AutoPointDialogDetector.java

示例9: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean shouldIgnore = evaluator.extendsClass(node, CLASS_EXPANDABLE_LIST_VIEW, false);
    if (shouldIgnore) return;

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTO_POINT_LIST_VIEW, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_LIST_VIEW, node, context.getLocation(node),
                String.format("%s do not support auto point,should extends DDListView", node.toString()));
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:20,代码来源:AutoPointListViewDetector.java

示例10: checkClass

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void checkClass(JavaContext context, PsiClass node) {
    super.checkClass(context, node);

    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isAbstract(node)) {
        return;
    }

    boolean supportAutoPoint = evaluator.extendsClass(node, CLASS_AUTOPOINT_RECYCLERVIEW_ADAPTER, false);

    if (!supportAutoPoint) {
        context.report(ISSUE_RECYCLER_ADAPTER, node, context.getLocation(node),
                "Recycler Adapter 必须实现DDRecyclerAdapter,否则不支持自动打点 class:" + node.getName());
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointRecyclerAdapterDetector.java

示例11: visitMethod

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
    PsiMethodCallExpression call, PsiMethod method) {
  JavaEvaluator evaluator = context.getEvaluator();
  if (evaluator.getParameterCount(method) == 0) {
    PsiMethod parent = PsiTreeUtil.getParentOfType(call, PsiMethod.class);
    if (parent != null) {
      if (evaluator.isMemberInClass(method, CLASS_DIRECTOR) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_DIRECTOR_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Stage.handleBack() in Stage.BackHandler.handleBack()");
      } else if (evaluator.isMemberInClass(method, CLASS_STAGE) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_STAGE_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Director.handleBack() in Director.BackHandler.handleBack()");
      }
    }
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:20,代码来源:BackHandlerDetector.java

示例12: checkNestedStringFormat

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
private static void checkNestedStringFormat(JavaContext context, UCallExpression call) {
  UElement current = call;
  while (true) {
    current = LintUtils.skipParentheses(current.getUastParent());
    if (current == null || current instanceof UMethod) {
      // Reached AST root or code block node; String.format not inside Timber.X(..).
      return;
    }
    if (UastExpressionUtils.isMethodCall(current)) {
      UCallExpression maybeTimberLogCall = (UCallExpression) current;
      JavaEvaluator evaluator = context.getEvaluator();
      PsiMethod psiMethod = maybeTimberLogCall.resolve();
      if (Pattern.matches(TIMBER_TREE_LOG_METHOD_REGEXP, psiMethod.getName())
          && evaluator.isMemberInClass(psiMethod, "timber.log.Timber")) {
        LintFix fix = quickFixIssueFormat(call);
        context.report(ISSUE_FORMAT, call, context.getLocation(call),
            "Using 'String#format' inside of 'Timber'", fix);
        return;
      }
    }
  }
}
 
开发者ID:JakeWharton,项目名称:timber,代码行数:23,代码来源:WrongTimberUsageDetector.java

示例13: visitMethod

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
@Override public void visitMethod(JavaContext context, UCallExpression call, PsiMethod method) {
  String methodName = call.getMethodName();
  JavaEvaluator evaluator = context.getEvaluator();

  if ("format".equals(methodName) && evaluator.isMemberInClass(method, "java.lang.String")) {
    checkNestedStringFormat(context, call);
    return;
  }
  // As of API 24, Log tags are no longer limited to 23 chars.
  if ("tag".equals(methodName)
      && evaluator.isMemberInClass(method, "timber.log.Timber")
      && context.getMainProject().getMinSdk() <= 23) {
    checkTagLength(context, call);
    return;
  }
  if (evaluator.isMemberInClass(method, "android.util.Log")) {
    LintFix fix = quickFixIssueLog(call);
    context.report(ISSUE_LOG, call, context.getLocation(call), "Using 'Log' instead of 'Timber'",
        fix);
    return;
  }
  // Handles Timber.X(..) and Timber.tag(..).X(..) where X in (v|d|i|w|e|wtf).
  if (evaluator.isMemberInClass(method, "timber.log.Timber") //
      || evaluator.isMemberInClass(method, "timber.log.Timber.Tree")) {
    checkMethodArguments(context, call);
    checkFormatArguments(context, call);
    checkExceptionLogging(context, call);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:WrongTimberUsageDetector.java

示例14: isCallFromMethodInSubclassOf

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
private static boolean isCallFromMethodInSubclassOf(JavaContext context, UCallExpression call,
    String methodName, String className) {
  JavaEvaluator evaluator = context.getEvaluator();
  PsiMethod method = call.resolve();
  return method != null //
      && methodName.equals(call.getMethodName()) //
      && evaluator.isMemberInSubClassOf(method, className, false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:WrongTimberUsageDetector.java

示例15: visitMethod

import com.android.tools.lint.client.api.JavaEvaluator; //导入依赖的package包/类
public void visitMethod(JavaContext context, PsiMethod method) {

        boolean isPublicMethod = method.hasModifierProperty(PsiModifier.PUBLIC);
        if (!isPublicMethod) return;

        JavaEvaluator evaluator = context.getEvaluator();
        if (evaluator == null) return;

        PsiParameterList parameterList = method.getParameterList();
        PsiParameter[] psiParameters = parameterList.getParameters();

        boolean hasBeanParameter = false;
        for (PsiParameter p : psiParameters) {
            PsiType type = p.getType();

            if (!(type instanceof PsiClassType)) continue;

            PsiClassType classType = (PsiClassType) type;
            PsiClass psiCls = classType.resolve();
            if (psiCls == null) continue;

            hasBeanParameter = Utils.isCustomBean(context, psiCls);
            if (hasBeanParameter) break;
        }

        if (hasBeanParameter) {
            mMethods.add(method);
        }
    }
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:30,代码来源:AutoPointCustomViewGroupDetector.java


注:本文中的com.android.tools.lint.client.api.JavaEvaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。