diff options
author | C. Sean Young <csyoung@google.com> | 2015-05-08 15:35:06 -0500 |
---|---|---|
committer | C. Sean Young <csyoung@google.com> | 2015-05-14 10:02:40 -0500 |
commit | a7e5c7e9b5250e738ff36521c03f6a3b76bc1c08 (patch) | |
tree | c373938407c035f59eb7dc11f6296684d80f5faa | |
parent | d1ccc1c9cfc5d1e7f400fa5bba4c773af56acb0c (diff) | |
download | platform_external_doclava-a7e5c7e9b5250e738ff36521c03f6a3b76bc1c08.tar.gz platform_external_doclava-a7e5c7e9b5250e738ff36521c03f6a3b76bc1c08.tar.bz2 platform_external_doclava-a7e5c7e9b5250e738ff36521c03f6a3b76bc1c08.zip |
Make CheckApi error messages more consisent and informative.
Make CheckApi error messages involving methods print out signature rather than just qualified name.
Previously, only constructor related additions and removals did this.
This made it difficult to tell which overload of a method had an API change.
Updates constructor related messages to use the fully qualified name of the class.
Also makes deprecation status change messages consistent (fields and classes now show before and after,
in addition to methods).
Change-Id: I83f06e96bf20e234fcc432ebec8d0b8ae04a22d2
-rw-r--r-- | src/com/google/doclava/ClassInfo.java | 10 | ||||
-rw-r--r-- | src/com/google/doclava/FieldInfo.java | 4 | ||||
-rw-r--r-- | src/com/google/doclava/MethodInfo.java | 51 |
3 files changed, 38 insertions, 27 deletions
diff --git a/src/com/google/doclava/ClassInfo.java b/src/com/google/doclava/ClassInfo.java index a5ee7d4..616cf23 100644 --- a/src/com/google/doclava/ClassInfo.java +++ b/src/com/google/doclava/ClassInfo.java @@ -2082,7 +2082,7 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco } if (mi == null) { Errors.error(Errors.REMOVED_METHOD, mInfo.position(), "Removed public method " - + mInfo.qualifiedName()); + + mInfo.prettyQualifiedSignature()); consistent = false; } } @@ -2096,7 +2096,7 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco MethodInfo mi = ClassInfo.overriddenMethod(mInfo, this); if (mi == null) { Errors.error(Errors.ADDED_METHOD, mInfo.position(), "Added public method " - + mInfo.qualifiedName()); + + mInfo.prettyQualifiedSignature()); consistent = false; } } @@ -2109,14 +2109,14 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco } } else { Errors.error(Errors.REMOVED_METHOD, mInfo.position(), "Removed public constructor " - + mInfo.prettySignature()); + + mInfo.prettyQualifiedSignature()); consistent = false; } } for (MethodInfo mInfo : cl.mApiCheckConstructors.values()) { if (!mApiCheckConstructors.containsKey(mInfo.getHashableName())) { Errors.error(Errors.ADDED_METHOD, mInfo.position(), "Added public constructor " - + mInfo.prettySignature()); + + mInfo.prettyQualifiedSignature()); consistent = false; } } @@ -2201,7 +2201,7 @@ public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Sco if (!isDeprecated() == cl.isDeprecated()) { consistent = false; Errors.error(Errors.CHANGED_DEPRECATED, cl.position(), "Class " + cl.qualifiedName() - + " has changed deprecation state"); + + " has changed deprecation state " + isDeprecated() + " --> " + cl.isDeprecated()); } if (superclassName() != null) { // java.lang.Object can't have a superclass. diff --git a/src/com/google/doclava/FieldInfo.java b/src/com/google/doclava/FieldInfo.java index ce80e9e..83d748a 100644 --- a/src/com/google/doclava/FieldInfo.java +++ b/src/com/google/doclava/FieldInfo.java @@ -423,7 +423,7 @@ public class FieldInfo extends MemberInfo { boolean consistent = true; if (!mType.equals(fInfo.mType)) { Errors.error(Errors.CHANGED_TYPE, fInfo.position(), "Field " + fInfo.qualifiedName() - + " has changed type"); + + " has changed type from " + mType + " to " + fInfo.mType); consistent = false; } else if (!this.valueEquals(fInfo)) { Errors.error(Errors.CHANGED_VALUE, fInfo.position(), "Field " + fInfo.qualifiedName() @@ -467,7 +467,7 @@ public class FieldInfo extends MemberInfo { if (isDeprecated() != fInfo.isDeprecated()) { Errors.error(Errors.CHANGED_DEPRECATED, fInfo.position(), "Field " + fInfo.qualifiedName() - + " has changed deprecation state"); + + " has changed deprecation state " + isDeprecated() + " --> " + fInfo.isDeprecated()); consistent = false; } diff --git a/src/com/google/doclava/MethodInfo.java b/src/com/google/doclava/MethodInfo.java index f1659f3..d52dcd8 100644 --- a/src/com/google/doclava/MethodInfo.java +++ b/src/com/google/doclava/MethodInfo.java @@ -333,6 +333,10 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv public String prettySignature() { return name() + prettyParameters(); } + + public String prettyQualifiedSignature() { + return qualifiedName() + prettyParameters(); + } /** * Returns a printable version of the parameters of this method's signature. @@ -721,6 +725,8 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv public String qualifiedName() { String parentQName = (containingClass() != null) ? (containingClass().qualifiedName() + ".") : ""; + // TODO: This logic doesn't work well with constructors, as name() for constructors already + // contains the containingClass's name, leading to things like A.B.B() being rendered as A.B.A.B() return parentQName + name(); } @@ -769,21 +775,22 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } if (!consistent) { - Errors.error(Errors.CHANGED_TYPE, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has changed return type from " + mReturnType + " to " + mInfo.mReturnType); + Errors.error(Errors.CHANGED_TYPE, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has changed return type from " + mReturnType + + " to " + mInfo.mReturnType); } } if (mIsAbstract != mInfo.mIsAbstract) { consistent = false; - Errors.error(Errors.CHANGED_ABSTRACT, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has changed 'abstract' qualifier"); + Errors.error(Errors.CHANGED_ABSTRACT, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has changed 'abstract' qualifier"); } if (mIsNative != mInfo.mIsNative) { consistent = false; - Errors.error(Errors.CHANGED_NATIVE, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has changed 'native' qualifier"); + Errors.error(Errors.CHANGED_NATIVE, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has changed 'native' qualifier"); } if (!mIsStatic) { @@ -793,30 +800,32 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv // and (b) the method is not already inferred to be 'final' by virtue of its class. if (!isEffectivelyFinal() && mInfo.isEffectivelyFinal()) { consistent = false; - Errors.error(Errors.ADDED_FINAL, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has added 'final' qualifier"); + Errors.error(Errors.ADDED_FINAL, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has added 'final' qualifier"); } else if (isEffectivelyFinal() && !mInfo.isEffectivelyFinal()) { consistent = false; - Errors.error(Errors.REMOVED_FINAL, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has removed 'final' qualifier"); + Errors.error(Errors.REMOVED_FINAL, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has removed 'final' qualifier"); } } if (mIsStatic != mInfo.mIsStatic) { consistent = false; - Errors.error(Errors.CHANGED_STATIC, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has changed 'static' qualifier"); + Errors.error(Errors.CHANGED_STATIC, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has changed 'static' qualifier"); } if (!scope().equals(mInfo.scope())) { consistent = false; - Errors.error(Errors.CHANGED_SCOPE, mInfo.position(), "Method " + mInfo.qualifiedName() - + " changed scope from " + scope() + " to " + mInfo.scope()); + Errors.error(Errors.CHANGED_SCOPE, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " changed scope from " + scope() + + " to " + mInfo.scope()); } if (!isDeprecated() == mInfo.isDeprecated()) { - Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(), "Method " + mInfo.qualifiedName() - + " has changed deprecation state " + isDeprecated() + " --> " + mInfo.isDeprecated()); + Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " has changed deprecation state " + isDeprecated() + + " --> " + mInfo.isDeprecated()); consistent = false; } @@ -835,8 +844,9 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv if (!mInfo.throwsException(exception)) { // exclude 'throws' changes to finalize() overrides with no arguments if (!name().equals("finalize") || (!mParameters.isEmpty())) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), "Method " + mInfo.qualifiedName() - + " no longer throws exception " + exception.qualifiedName()); + Errors.error(Errors.CHANGED_THROWS, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " no longer throws exception " + + exception.qualifiedName()); consistent = false; } } @@ -846,8 +856,9 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv // exclude 'throws' changes to finalize() overrides with no arguments if (!throwsException(exec)) { if (!name().equals("finalize") || (!mParameters.isEmpty())) { - Errors.error(Errors.CHANGED_THROWS, mInfo.position(), "Method " + mInfo.qualifiedName() - + " added thrown exception " + exec.qualifiedName()); + Errors.error(Errors.CHANGED_THROWS, mInfo.position(), "Method " + + mInfo.prettyQualifiedSignature() + " added thrown exception " + + exec.qualifiedName()); consistent = false; } } |