@CopyMethod static String getDescription(TypeReference self) { try { return self.getTypeName(); } catch (Exception e) { return null; } }
@CopyMethod static String getDescription(TypeReference self) { try { return self.getTypeName(); } catch (Exception e) { return null; } }
@CopyMethod static String getDescription(TypeReference self) { try { return self.getTypeName(); } catch (Exception e) { return null; } }
case EXTENDS: out.append("? extends "); out.append(t.getTypeName()); break; case SUPER: out.append("? super "); out.append(t.getTypeName()); break; default: case NONE: out.append(t.getTypeName()); break; case UNBOUND:
case EXTENDS: out.append("? extends "); out.append(t.getTypeName()); break; case SUPER: out.append("? super "); out.append(t.getTypeName()); break; default: case NONE: out.append(t.getTypeName()); break; case UNBOUND:
case EXTENDS: out.append("? extends "); out.append(t.getTypeName()); break; case SUPER: out.append("? super "); out.append(t.getTypeName()); break; default: case NONE: out.append(t.getTypeName()); break; case UNBOUND:
/** * Returns the set of exception types handled by the given catch block. * <p> * This is a workaround for the fact that the Lombok AST API (and implementation) * doesn't support multi-catch statements. * @deprecated Use {@link JavaPsiScanner} APIs instead */ @Deprecated public List<TypeDescriptor> getCatchTypes(@NonNull JavaContext context, @NonNull Catch catchBlock) { TypeReference typeReference = catchBlock.astExceptionDeclaration().astTypeReference(); return Collections.singletonList(new DefaultTypeDescriptor( typeReference.getTypeName())); }
if (expectedType == Class.class) { if (val instanceof ClassLiteral) { String className = ((ClassLiteral)val).astTypeReference().getTypeName(); String cName = className; int dims = 0;
@Override public boolean visitClassDeclaration(ClassDeclaration node) { String name = node.astName().astValue(); if (mActivities != null && mActivities.contains(mClassFqn) || name.endsWith(ACTIVITY) || node.astExtending() != null && node.astExtending().getTypeName().endsWith(ACTIVITY)) { String packageName = ""; if (node.getParent() instanceof CompilationUnit) { CompilationUnit compilationUnit = (CompilationUnit) node.getParent(); PackageDeclaration packageDeclaration = compilationUnit.astPackageDeclaration(); if (packageDeclaration == null) { // No package declaration: ignore this one return true; } packageName = packageDeclaration.getPackageName(); } mClassFqn = (!packageName.isEmpty() ? (packageName + '.') : "") + name; return false; } return true; // Done: No need to look inside this class }
private void checkSparseArray(ConstructorInvocation node, TypeReference reference) { // reference.hasTypeArguments returns false where it should not StrictListAccessor<TypeReference, TypeReference> types = reference.getTypeArguments(); if (types != null && types.size() == 1) { TypeReference first = types.first(); String valueType = first.getTypeName(); if (valueType.equals(INTEGER)) { mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node), "Use `new SparseIntArray(...)` instead for better performance"); } else if (valueType.equals(BOOLEAN)) { mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node), "Use `new SparseBooleanArray(...)` instead for better performance"); } } } }
if (expectedType == Class.class) { if (val instanceof ClassLiteral) { String className = ((ClassLiteral)val).astTypeReference().getTypeName(); String cName = className; int dims = 0;
String name = stripGenerics(typeReference.getTypeName()); wanted = stripGenerics(wanted);
/** * @deprecated Use {@link #getMethodName(PsiElement)} instead */ @Deprecated @Nullable public static String getMethodName(@NonNull Node call) { if (call instanceof MethodInvocation) { return ((MethodInvocation)call).astName().astValue(); } else if (call instanceof ConstructorInvocation) { return ((ConstructorInvocation)call).astTypeReference().getTypeName(); } else if (call instanceof EnumConstant) { return ((EnumConstant)call).astName().astValue(); } else { return null; } }
if (types != null && types.size() == 2) { TypeReference first = types.first(); String typeName = first.getTypeName(); int minSdk = mContext.getMainProject().getMinSdk(); if (typeName.equals(INTEGER) || typeName.equals(BYTE)) { String valueType = types.last().getTypeName(); if (valueType.equals(INTEGER)) { mContext.report(USE_SPARSE_ARRAY, node, mContext.getLocation(node),
if (node.getParent() instanceof Cast) { Cast cast = (Cast) node.getParent(); String castType = cast.astTypeReference().getTypeName(); StrictListAccessor<Expression, MethodInvocation> args = node.astArguments(); if (args.size() == 1) {
@Override public boolean visitAnnotation(Annotation node) { String type = node.astAnnotationTypeReference().getTypeName(); if (SUPPRESS_LINT.equals(type) || FQCN_SUPPRESS_LINT.equals(type)) { Node parent = node.getParent();
if (resolved != null) { fqcn = resolved.getSignature(); } else if (typeReference.getTypeName().equals( "ReflectiveOperationException")) { fqcn = "java.lang.ReflectiveOperationException";
@Override public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, @NonNull MethodInvocation node) { if (node.getParent() instanceof Cast) { Cast cast = (Cast) node.getParent(); StrictListAccessor<Expression, MethodInvocation> args = node.astArguments(); if (args.size() == 1) { String name = stripPackage(args.first().toString()); String expectedClass = getExpectedType(name); if (expectedClass != null) { String castType = cast.astTypeReference().getTypeName(); if (castType.indexOf('.') == -1) { expectedClass = stripPackage(expectedClass); } if (!castType.equals(expectedClass)) { // It's okay to mix and match // android.content.ClipboardManager and android.text.ClipboardManager if (isClipboard(castType) && isClipboard(expectedClass)) { return; } String message = String.format( "Suspicious cast to `%1$s` for a `%2$s`: expected `%3$s`", stripPackage(castType), name, stripPackage(expectedClass)); context.report(ISSUE, node, context.getLocation(cast), message); } } } } }
String typeName = t.getTypeName(); if (typeName.endsWith(SUPPRESS_LINT) || typeName.endsWith("SuppressWarnings")) {
String typeName = t.getTypeName(); if (typeName.endsWith(TARGET_API)) { StrictListAccessor<AnnotationElement, Annotation> values =