本文整理汇总了Java中com.android.tools.lint.detector.api.JavaContext.report方法的典型用法代码示例。如果您正苦于以下问题:Java JavaContext.report方法的具体用法?Java JavaContext.report怎么用?Java JavaContext.report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.tools.lint.detector.api.JavaContext
的用法示例。
在下文中一共展示了JavaContext.report方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethod
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public void visitMethod(@NonNull JavaContext context, AstVisitor visitor,
@NonNull MethodInvocation node) {
VariableReference ref = (VariableReference) node.astOperand();
if (!"QMUILog".equals(ref.astIdentifier().astValue())) {
return;
}
StrictListAccessor<Expression, MethodInvocation> args = node.astArguments();
if (args.isEmpty()) {
return;
}
for (Expression expression : args) {
String input = expression.toString();
if (input != null && input.contains("fuck")) {
context.report(
ISSUE_F_WORD, expression,
context.getLocation(expression), "\uD83D\uDD95");
}
}
}
示例2: checkElement
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
private static boolean checkElement(JavaContext context, UCallExpression call, UElement element) {
if (element instanceof UBinaryExpression) {
UBinaryExpression binaryExpression = (UBinaryExpression) element;
UastBinaryOperator operator = binaryExpression.getOperator();
if (operator == PLUS || operator == PLUS_ASSIGN) {
Class argumentType = getType(binaryExpression);
if (argumentType == String.class) {
LintFix fix = quickFixIssueBinary(binaryExpression);
context.report(ISSUE_BINARY, call, context.getLocation(element),
"Replace String concatenation with Timber's string formatting", fix);
return true;
}
}
} else if (element instanceof UIfExpression) {
return checkConditionalUsage(context, call, element);
}
return false;
}
示例3: checkClass
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());
}
}
示例4: checkClass
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()));
}
}
示例5: checkClass
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()));
}
}
示例6: checkClass
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()));
}
}
示例7: checkClass
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()));
}
}
示例8: checkClass
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()));
}
}
示例9: visitMethod
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable JavaElementVisitor visitor,
@NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {
boolean isLayoutInflaterCall = isLayoutInflaterCall(context, node, method);
boolean isViewInflateCall = isInViewCall(context, node, method);
String name = method.getName();
boolean fromMethod = LAYOUTINFLATER_FROM.equals(name);
boolean viewInflateMethod = VIEW_INFLATE.equals(name);
if (isLayoutInflaterCall && fromMethod) {
context.report(ISSUE_LAYOUTINFLATER, node, context.getLocation(node),
"error use system LayoutInflater,should use LayoutInflaterWrapper.");
return;
}
if (viewInflateMethod && isViewInflateCall) {
context.report(ISSUE_VIEW_INFLATE, node, context.getLocation(node),
"error use View.inflate(),should use LayoutInflaterWrapper.inflate.");
return;
}
}
示例10: checkClass
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());
}
}
示例11: visitMethod
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()");
}
}
}
}
示例12: visitMethod
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
super.visitMethod(context, visitor, call, method);
if (isRxSubscribeableClass(method.getContainingClass()) && !PsiType.VOID.equals(method.getReturnType())) {
PsiElement element = LintUtils.skipParentheses(call.getParent());
if (element instanceof PsiExpressionStatement) {
String message;
if (isRx2(method.getContainingClass())) {
message = "No reference to the disposable is kept";
} else {
message = "No reference to the subscription is kept";
}
context.report(ISSUE, call, context.getLocation(call), message);
}
}
}
示例13: checkClass
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public void checkClass(@NonNull JavaContext context, @Nullable ClassDeclaration node,
@NonNull Node declarationOrAnonymous, @NonNull ResolvedClass resolvedClass) {
if (!context.getProject().getReportIssues()) {
return;
}
String className = resolvedClass.getName();
if (resolvedClass.isSubclassOf(PREFERENCE_ACTIVITY, false)
&& mExportedActivities.containsKey(className)) {
// Ignore the issue if we target an API greater than 19 and the class in
// question specifically overrides isValidFragment() and thus knowingly white-lists
// valid fragments.
if (context.getMainProject().getTargetSdk() >= 19
&& overridesIsValidFragment(resolvedClass)) {
return;
}
String message = String.format(
"`PreferenceActivity` subclass `%1$s` should not be exported",
className);
context.report(ISSUE, mExportedActivities.get(className).resolve(), message);
}
}
示例14: visitResourceReference
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public void visitResourceReference(
@NonNull JavaContext context,
@Nullable AstVisitor visitor,
@NonNull Node node,
@NonNull String type,
@NonNull String name,
boolean isFramework) {
if (context.getProject().isGradleProject() && !isFramework) {
Project project = context.getProject();
if (project.getGradleProjectModel() != null && project.getCurrentVariant() != null) {
ResourceType resourceType = ResourceType.getEnum(type);
if (resourceType != null && isPrivate(context, resourceType, name)) {
String message = createUsageErrorMessage(context, resourceType, name);
context.report(ISSUE, node, context.getLocation(node), message);
}
}
}
}
示例15: createJavaVisitor
import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
@Override
public AstVisitor createJavaVisitor(final JavaContext context) {
return new ForwardingAstVisitor() {
@Override
public boolean visitMethodInvocation(MethodInvocation node) {
JavaParser.ResolvedNode resolve = context.resolve(node);
if (resolve instanceof JavaParser.ResolvedMethod) {
JavaParser.ResolvedMethod method = (JavaParser.ResolvedMethod) resolve;
// 方法所在的类校验
JavaParser.ResolvedClass containingClass = method.getContainingClass();
if (containingClass.matches("android.util.Log")) {
context.report(ISSUE, node, context.getLocation(node),
"请使用Ln,避免使用Log");
return true;
}
if (node.toString().startsWith("System.out.println")) {
context.report(ISSUE, node, context.getLocation(node),
"请使用Ln,避免使用System.out.println");
return true;
}
}
return super.visitMethodInvocation(node);
}
};
}