Reviewers: mdempsky,

Description:
Minor cleanup in SerializableTypeOracleBuilder:
- remove unused fields
- TypeInfoComputed can be static
- tighten visibility
- remove some indirection
- fix some warnings

Review by: mdemp...@google.com

Please review this at http://gwt-code-reviews.appspot.com/1869803/

Affected files:
M user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java


Index: user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
===================================================================
--- user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java (revision 11375) +++ user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java (working copy)
@@ -114,18 +114,7 @@
  */
 public class SerializableTypeOracleBuilder {

-  class TypeInfoComputed {
-    /**
- * <code>true</code> if the type is assignable to {@link IsSerializable} or
-     * {@link java.io.Serializable Serializable}.
-     */
-    private final boolean autoSerializable;
-
-    /**
- * <code>true</code> if the this type directly implements one of the marker
-     * interfaces.
-     */
-    private final boolean directlyImplementsMarker;
+  static class TypeInfoComputed {

     /**
* <code>true</code> if the type is automatically or manually serializable
@@ -176,19 +165,15 @@
      */
     private final JType type;

-    public TypeInfoComputed(JType type, TypePath path) {
+ private TypeInfoComputed(JType type, TypePath path, TypeOracle typeOracle) {
       this.type = type;
       this.path = path;
       if (type instanceof JClassType) {
         JClassType typeClass = (JClassType) type;
- autoSerializable = SerializableTypeOracleBuilder.isAutoSerializable(typeClass); manualSerializer = findCustomFieldSerializer(typeOracle, typeClass); - directlyImplementsMarker = directlyImplementsMarkerInterface(typeClass); maybeEnhanced = hasJdoAnnotation(typeClass) || hasJpaAnnotation(typeClass);
       } else {
-        autoSerializable = false;
         manualSerializer = null;
-        directlyImplementsMarker = false;
         maybeEnhanced = false;
       }
     }
@@ -204,10 +189,6 @@
       return instantiableTypes;
     }

-    public JClassType getManualSerializer() {
-      return manualSerializer;
-    }
-
     public TypePath getPath() {
       return path;
     }
@@ -217,19 +198,7 @@
     }

     public boolean hasInstantiableSubtypes() {
- return isInstantiable() || instantiableSubtypes || isPendingInstantiable();
-    }
-
-    public boolean isAutoSerializable() {
-      return autoSerializable;
-    }
-
-    public boolean isDeclaredSerializable() {
-      return autoSerializable || isManuallySerializable();
-    }
-
-    public boolean isDirectlySerializable() {
-      return directlyImplementsMarker || isManuallySerializable();
+ return instantiable || instantiableSubtypes || state == TypeState.CHECK_IN_PROGRESS;
     }

     public boolean isDone() {
@@ -1054,8 +1023,6 @@

   /**
* Consider any subtype of java.lang.Object which qualifies for serialization.
-   *
-   * @param logger
    */
private void checkAllSubtypesOfObject(TreeLogger logger, TypePath parent, ProblemReport problems) {
     if (alreadyCheckedObject) {
@@ -1329,7 +1296,7 @@
// Note we are leaving hasInstantiableSubtypes() as false which might be // wrong but it is only used by arrays and thus it will never be looked at
       // for this tic.
-      if (instantiable && instSubtypes != null) {
+      if (instantiable) {
         instSubtypes.add(candidate);
       }
     }
@@ -1342,8 +1309,7 @@
    * it is applied to be serializable. As a side effect, populates
    * {@link #typeToTypeInfoComputed} in the same way as
    * {@link #computeTypeInstantiability}.
-   *
-   * @param logger
+   *
    * @param baseType - The generic type the parameter is on
    * @param paramIndex - The index of the parameter in the generic type
* @param typeArg - An upper bound on the actual argument being applied to the
@@ -1490,7 +1456,7 @@
private TypeInfoComputed getTypeInfoComputed(JType type, TypePath path, boolean createIfNeeded) {
     TypeInfoComputed tic = typeToTypeInfoComputed.get(type);
     if (tic == null && createIfNeeded) {
-      tic = new TypeInfoComputed(type, path);
+      tic = new TypeInfoComputed(type, path, typeOracle);
       typeToTypeInfoComputed.put(type, tic);
     }
     return tic;
@@ -1619,8 +1585,7 @@
     Set<JType> supersOfInstantiableTypes = new LinkedHashSet<JType>();
     for (TypeInfoComputed tic : typeToTypeInfoComputed.values()) {
       if (tic.isInstantiable() && tic.getType() instanceof JClassType) {
-        JClassType type = (JClassType) tic.getType().getErasedType();
-        JClassType sup = type;
+        JClassType sup = (JClassType) tic.getType().getErasedType();
         while (sup != null) {
           supersOfInstantiableTypes.add(sup.getErasedType());
           sup = sup.getErasedType().getSuperclass();


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to