Author: [EMAIL PROTECTED]
Date: Mon Dec  8 08:49:24 2008
New Revision: 4265

Modified:
     
trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
    trunk/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java

Log:
Modifies the IFrame linker so that any deferred-loaded JavaScript
files needed by runAsync are placed into subdirectories of the
main output directory.

Review by: bobv



Modified:  
trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
==============================================================================
---  
trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
        
(original)
+++  
trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
        
Mon Dec  8 08:49:24 2008
@@ -28,6 +28,7 @@
  import com.google.gwt.dev.util.Util;
  import com.google.gwt.util.tools.Utility;

+import java.io.File;
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
@@ -55,6 +56,11 @@
    protected static final String FRAGMENT_EXTENSION = ".cache.js";

    /**
+   * A subdirectory to hold all the generated fragments.
+   */
+  protected static final String FRAGMENT_SUBDIR = "deferredjs";
+
+  /**
     * Determines whether or not the URL is relative.
     *
     * @param src the test url
@@ -111,7 +117,8 @@
        throws UnableToCompleteException {
      String[] js = result.getJavaScript();
      byte[][] bytes = new byte[js.length][];
-    bytes[0] = generatePrimaryFragment(logger, context, js[0],  
result.getStrongName());
+    bytes[0] = generatePrimaryFragment(logger, context, js[0],
+        result.getStrongName());
      for (int i = 1; i < js.length; i++) {
        bytes[i] = Util.getBytes(js[i]);
      }
@@ -120,8 +127,8 @@
      toReturn.add(emitBytes(logger, bytes[0], result.getStrongName()
          + getCompilationExtension(logger, context)));
      for (int i = 1; i < js.length; i++) {
-      toReturn.add(emitBytes(logger, bytes[i], result.getStrongName()  
+ "-" + i
-          + FRAGMENT_EXTENSION));
+      toReturn.add(emitBytes(logger, bytes[i], FRAGMENT_SUBDIR +  
File.separator
+          + result.getStrongName() + File.separator + i +  
FRAGMENT_EXTENSION));
      }

      compilationStrongNames.put(result, result.getStrongName());
@@ -336,7 +343,8 @@
    }

    protected abstract String getModulePrefix(TreeLogger logger,
-      LinkerContext context, String strongName) throws  
UnableToCompleteException;
+      LinkerContext context, String strongName)
+      throws UnableToCompleteException;

    protected abstract String getModuleSuffix(TreeLogger logger,
        LinkerContext context) throws UnableToCompleteException;
@@ -345,7 +353,8 @@
        LinkerContext context) throws UnableToCompleteException;

    private byte[] generatePrimaryFragment(TreeLogger logger,
-      LinkerContext context, String js, String strongName) throws  
UnableToCompleteException {
+      LinkerContext context, String js, String strongName)
+      throws UnableToCompleteException {
      StringBuffer b = new StringBuffer();
      b.append(getModulePrefix(logger, context, strongName));
      b.append(js);

Modified: trunk/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java
==============================================================================
--- trunk/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java      
(original)
+++ trunk/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java     Mon  
Dec  8 08:49:24 2008
@@ -87,7 +87,7 @@
      out.indentIn();
      out.print("  var script = document.createElement('script');");
      out.newlineOpt();
-    out.print("  script.src = '" + strongName + "-' + frag + '" +  
FRAGMENT_EXTENSION + "';");
+    out.print("  script.src = '" + FRAGMENT_SUBDIR + "/" + strongName  
+ "/' + frag + '" + FRAGMENT_EXTENSION + "';");
      out.print("   
document.getElementsByTagName('head').item(0).appendChild(script);");
      out.indentOut();
      out.newlineOpt();

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

Reply via email to