private String createUniqueStrForReference(Object reference) { String uniqueStr = null; if (reference instanceof TypeReference) { TypeReference type = (TypeReference) reference; String pathAndTypeStr = getPathAndTypeStr(type); if (pathAndTypeStr != null) { uniqueStr = "type|" + pathAndTypeStr; } } else if (reference instanceof MethodReference) { MethodReference method = (MethodReference) reference; String pathAndTypeStr = getPathAndTypeStr(method.getDeclaringType()); if (pathAndTypeStr != null) { uniqueStr = "method|" + pathAndTypeStr + "|" + method.getName() + "|" + method.getErasedSignature(); } } else if (reference instanceof FieldReference) { FieldReference field = (FieldReference) reference; String pathAndTypeStr = getPathAndTypeStr(field.getDeclaringType()); if (pathAndTypeStr != null) { uniqueStr = "field|" + pathAndTypeStr + "|" + field.getName(); } } return uniqueStr; }
@Override public final String getName() { return _genericDefinition.getName(); } }
@Override public final String getName() { return _baseMethod.getName(); } }
public static RuntimeException notGenericMethodDefinition(final MethodReference method) { return new UnsupportedOperationException( format( "TypeReference '%s' is not a generic method definition.", method.getName() ) ); }
public static RuntimeException notGenericMethod(final MethodReference method) { return new UnsupportedOperationException( format( "TypeReference '%s' is not a generic method.", method.getName() ) ); }
public static RuntimeException notGenericMethod(final MethodReference method) { return new UnsupportedOperationException( format( "TypeReference '%s' is not a generic method.", method.getName() ) ); }
public static RuntimeException notGenericMethod(final MethodReference method) { return new UnsupportedOperationException( format( "TypeReference '%s' is not a generic method.", method.getName() ) ); }
public static RuntimeException notGenericMethodDefinition(final MethodReference method) { return new UnsupportedOperationException( format( "TypeReference '%s' is not a generic method definition.", method.getName() ) ); }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName) { final TypeReference declaringType = getDeclaringType(); if (declaringType != null) { return declaringType.appendName(sb, true, false).append('.').append(getName()); } } return sb.append(getName()); }
public static boolean knownToThrow(MethodReference mr) { if (mr.getName().startsWith("assert") || mr.getName().startsWith("require") || mr.getDeclaringType().getSimpleName().equals("Assert")) return true; if (Types.isBoxed(mr.getDeclaringType()) && mr.getName().startsWith("parse")) return true; return false; }
@Override public boolean test(final MethodReference reference) { return StringUtilities.equals(reference.getName(), method.getName()); } },
private boolean isStreamFilter(MethodReference mr) { if(!mr.getName().equals("filter") || mr.getParameters().size() != 1) return false; TypeReference type = mr.getParameters().get(0).getParameterType(); return type.getSimpleName().endsWith("Predicate") && type.getPackageName().equals("java.util.function") && Types.isBaseStream(mr.getDeclaringType()); } }
private static boolean isClassGetName(Expression expr) { if (expr.getCode() == AstCode.InvokeVirtual) { MethodReference mr = (MethodReference) expr.getOperand(); if (mr.getName().equals("getName") && Types.is(mr.getDeclaringType(), Class.class)) return true; } return false; }
private boolean isBoxedToString(Expression expr) { if (expr.getCode() == AstCode.InvokeVirtual) { MethodReference mr = (MethodReference) expr.getOperand(); if (mr.getName().equals("toString") && mr.getSignature().equals("()Ljava/lang/String;")) { TypeReference type = mr.getDeclaringType(); if (Types.isBoxed(type)) { return true; } } } return false; }
private static boolean isGetClassInvocation(final Instruction p) { return p != null && p.getOpCode() == OpCode.INVOKEVIRTUAL && p.<MethodReference>getOperand(0).getParameters().isEmpty() && StringUtilities.equals(p.<MethodReference>getOperand(0).getName(), "getClass"); }
@AstVisitor(nodes = AstNodes.EXPRESSIONS, methodName = "hasNext", methodSignature = "()Z") public void visitHasNext(Expression expr, MethodContext mc, TypeDefinition td) { if (expr.getCode() == AstCode.InvokeVirtual) { MethodReference mr = (MethodReference) expr.getOperand(); if (mr.getName().equals("next") && mr.getParameters().isEmpty() && Exprs.isThis(Exprs.getChild(expr, 0))) { mc.report("IteratorHasNextCallsNext", td.isPublic() ? 0 : 30, expr); } } }
public static void writeMethod(final ITextOutput writer, final MethodReference method) { VerifyArgument.notNull(method, "method"); VerifyArgument.notNull(writer, "writer"); final Stack<TypeReference> typeStack = new Stack<>(); formatType(writer, method.getDeclaringType(), NameSyntax.DESCRIPTOR, false, typeStack); writer.writeDelimiter("."); writer.writeReference(method.getName(), method); writer.writeDelimiter(":"); formatMethodSignature(writer, method, typeStack); }
public static void writeMethod(final ITextOutput writer, final MethodReference method) { VerifyArgument.notNull(method, "method"); VerifyArgument.notNull(writer, "writer"); final Stack<TypeReference> typeStack = new Stack<>(); formatType(writer, method.getDeclaringType(), NameSyntax.DESCRIPTOR, false, typeStack); writer.writeDelimiter("."); writer.writeReference(method.getName(), method); writer.writeDelimiter(":"); formatMethodSignature(writer, method, typeStack); }