containingClass.isSubclassOf(RESOURCES_CLS, false))) { TypeDescriptor returnType = method.getReturnType(); if (returnType != null && returnType.matchesSignature(TYPED_ARRAY_CLS)) { checkRecycled(context, node, TYPED_ARRAY_CLS, RECYCLE);
int tagArgumentIndex = PRINTLN.equals(name) ? 1 : 0; if (method.getArgumentCount() > tagArgumentIndex && method.getArgumentType(tagArgumentIndex).matchesSignature(TYPE_STRING) && node.astArguments().size() == method.getArgumentCount()) { Iterator<Expression> iterator = node.astArguments().iterator();
&& method.getArgumentType(0).matchesSignature(TYPE_STRING) && node.astArguments().size() == method.getArgumentCount()) { Iterator<Expression> iterator = node.astArguments().iterator();
private static boolean isJavaScriptAnnotated(ResolvedClass clz) { while (clz != null) { for (ResolvedAnnotation annotation : clz.getAnnotations()) { if (annotation.getType().matchesSignature(JAVASCRIPT_INTERFACE_CLS)) { return true; } } for (ResolvedMethod method : clz.getMethods(false)) { for (ResolvedAnnotation annotation : method.getAnnotations()) { if (annotation.getType().matchesSignature(JAVASCRIPT_INTERFACE_CLS)) { return true; } } } clz = clz.getSuperClass(); } return false; }
@Override public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, @NonNull MethodInvocation node) { ResolvedNode resolved = context.resolve(node); if (!(resolved instanceof ResolvedMethod) || !((ResolvedMethod) resolved).getContainingClass() .isSubclassOf(PACKAGE_MANAGER_CLASS, false)) { return; } StrictListAccessor<Expression, MethodInvocation> argumentList = node.astArguments(); // Ignore if the method doesn't fit our description. if (argumentList != null && argumentList.size() == 2) { TypeDescriptor firstParameterType = context.getType(argumentList.first()); if (firstParameterType != null && firstParameterType.matchesSignature(JavaParser.TYPE_STRING)) { maybeReportIssue(calculateValue(context, argumentList.last()), context, node); } } }
/** * Searches for the annotation of the given type on the method * * @param type the fully qualified name of the annotation to check * @param parameterIndex the index of the parameter to look up * @return the annotation, or null if not found */ @Nullable public ResolvedAnnotation getParameterAnnotation(@NonNull String type, int parameterIndex) { for (ResolvedAnnotation annotation : getParameterAnnotations(parameterIndex)) { if (annotation.getType().matchesSignature(type)) { return annotation; } } return null; }
/** * Searches for the annotation of the given type on this node * * @param type the fully qualified name of the annotation to check * @return the annotation, or null if not found */ @Nullable public ResolvedAnnotation getAnnotation(@NonNull String type) { for (ResolvedAnnotation annotation : getAnnotations()) { if (annotation.getType().matchesSignature(type)) { return annotation; } } return null; }
private static boolean specifiesLocale(@NonNull ResolvedMethod method) { for (int i = 0, n = method.getArgumentCount(); i < n; i++) { TypeDescriptor argumentType = method.getArgumentType(i); if (argumentType.matchesSignature(LOCALE_CLS)) { return true; } } return false; } }
private static boolean isSecurityException( @NonNull JavaContext context, @NonNull TypeReference typeReference) { TypeDescriptor type = context.getType(typeReference); return type != null && (type.matchesSignature("java.lang.SecurityException") || type.matchesSignature("java.lang.RuntimeException") || type.matchesSignature("java.lang.Exception") || type.matchesSignature("java.lang.Throwable")); }
/** Returns true if the parameter at the given index matches the given type signature */ public boolean argumentMatchesType(int index, @NonNull String signature) { return getArgumentType(index).matchesSignature(signature); }
private static boolean hasLooperConstructorParameter(@NonNull ResolvedClass cls) { for (ResolvedMethod constructor : cls.getConstructors()) { for (int i = 0, n = constructor.getArgumentCount(); i < n; i++) { TypeDescriptor type = constructor.getArgumentType(i); if (type.matchesSignature(LOOPER_CLS)) { return true; } } } return false; } }