Author: [email protected]
Date: Tue Apr 28 12:50:46 2009
New Revision: 5297

Modified:
    trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
    trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
    trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java

Log:
Fixes http://code.google.com/p/google-web-toolkit/issues/detail?id=3611 --  
refresh did not work correctly when -gen was used.

Patch by: amitmanjhi
Review by: robertvawter (desk review)



Modified: trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java    
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java   Tue  
Apr 28 12:50:46 2009
@@ -294,7 +294,7 @@
        CompilationUnit graveyardUnit = graveyardUnits.remove(typeName);
        if (graveyardUnit != null) {
          assert graveyardUnit.getState() == State.GRAVEYARD;
-        if (unit.getSource().equals(graveyardUnit.getSource())) {
+        if (unit.getStrongHash().equals(graveyardUnit.getStrongHash())) {
            usefulGraveyardUnits.put(typeName, graveyardUnit);
          } else {
            // The old unit is invalidated.

Modified: trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java     
(original)
+++ trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java    Tue  
Apr 28 12:50:46 2009
@@ -378,6 +378,15 @@
    public abstract String getSource();

    /**
+   * Returns the strong hash of the source. The default implementation  
simply
+   * returns the source. Subclasses can override this implementation if  
source
+   * might be overwritten.
+   */
+  public String getStrongHash() {
+    return getSource();
+  }
+
+  /**
     * Returns the fully-qualified name of the top level public type.
     */
    public abstract String getTypeName();

Modified:  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
==============================================================================
---  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java       
 
(original)
+++  
trunk/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java       
 
Tue Apr 28 12:50:46 2009
@@ -148,6 +148,7 @@
        implements Generated {

      private PrintWriter pw;
+    private String strongHash; // cache so that refreshes work correctly

      public GeneratedUnitWithFile(File file, PrintWriter pw, String  
packageName) {
        super(file, packageName);
@@ -162,6 +163,7 @@
      public void commit() {
        pw.close();
        pw = null;
+      strongHash = Util.computeStrongName(getSource().getBytes());
      }

      @Override
@@ -170,6 +172,15 @@
          throw new IllegalStateException("source not committed");
        }
        return super.getSource();
+    }
+
+    /**
+     * The old source is not preserved across refreshes. We use a  
strongHash to
+     * avoid the memory overhead of storing the source.
+     */
+    @Override
+    public String getStrongHash() {
+      return strongHash;
      }

      @Override

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

Reply via email to