本文整理匯總了Java中com.android.tools.lint.detector.api.JavaContext.getEvaluator方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaContext.getEvaluator方法的具體用法?Java JavaContext.getEvaluator怎麽用?Java JavaContext.getEvaluator使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.android.tools.lint.detector.api.JavaContext的用法示例。
在下文中一共展示了JavaContext.getEvaluator方法的18個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: checkNestedStringFormat
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例2: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例3: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例4: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例5: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例6: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例7: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例8: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例9: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例10: checkClass
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例11: visitMethod
點讚 3
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例12: visitMethod
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例13: isCallFromMethodInSubclassOf
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例14: visitMethod
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的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,
示例15: afterCheckClass
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的package包/類
public void afterCheckClass(Context context) {
if (mMethods.size() == 0) return;
JavaContext javaContext = (JavaContext) context;
JavaEvaluator evaluator = javaContext.getEvaluator();
if (evaluator == null) return;
StringBuilder sb = new StringBuilder();
boolean methodInDataAdapter = false;
for (PsiMethod method : mMethods) {
PsiClass pc = method.getContainingClass();
boolean isSubclass = evaluator.implementsInterface(pc, CLASS_DATA_ADAPTER, false);
methodInDataAdapter = methodInDataAdapter || isSubclass;
if (!isSubclass) {
sb.append(method.getName())
.append(",");
}
}
if (!methodInDataAdapter) {
context.report(ISSUE_VIEW_GROUP, Location.create(context.file), "the Custom ViewGroup with data bind should extend DataAdapter,method names:" + sb.toString());
}
}
開發者ID:jessie345,項目名稱:CustomLintRules,代碼行數:28,
示例16: checkClass
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的package包/類
@Override
public void checkClass(JavaContext context, PsiClass declaration) {
final JavaEvaluator evaluator = context.getEvaluator();
if (evaluator.isAbstract(declaration)) {
return;
}
if (!evaluator.isPublic(declaration)) {
context.report(ISSUE, declaration, context.getLocation(declaration),
"Non-abstract Scene class must be public");
return;
}
if (declaration.getContainingClass() != null && !evaluator.isStatic(declaration)) {
context.report(ISSUE, declaration, context.getLocation(declaration),
"Inner Scene class must be static");
return;
}
PsiMethod[] constructors = declaration.getConstructors();
// No constructor means it has default constructor
boolean hasNoParametersConstructor = constructors.length == 0;
if (!hasNoParametersConstructor) {
// Find no-parameter constructor
for (PsiMethod constructor : constructors) {
if (evaluator.isPublic(constructor)) {
PsiParameter[] parameters = constructor.getParameterList().getParameters();
if (parameters.length == 0) {
hasNoParametersConstructor = true;
break;
}
}
}
}
if (!hasNoParametersConstructor) {
context.report(ISSUE, declaration, context.getLocation(declaration),
"Scene class must have a no-parameter constructor");
}
}
開發者ID:seven332,項目名稱:Stage,代碼行數:41,
示例17: isLayoutInflaterCall
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的package包/類
private static boolean isLayoutInflaterCall(@NonNull JavaContext context,
@NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {
JavaEvaluator evaluator = context.getEvaluator();
return evaluator.isMemberInClass(method, CLASS_LAYOUT_INFLATER);
}
開發者ID:jessie345,項目名稱:CustomLintRules,代碼行數:6,
示例18: isInViewCall
點讚 2
import com.android.tools.lint.detector.api.JavaContext; //導入方法依賴的package包/類
private static boolean isInViewCall(@NonNull JavaContext context,
@NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {
JavaEvaluator evaluator = context.getEvaluator();
return evaluator.isMemberInClass(method, CLASS_VIEW);
}
開發者ID:jessie345,項目名稱:CustomLintRules,代碼行數:6,
注:本文中的com.android.tools.lint.detector.api.JavaContext.getEvaluator方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。