Adds optional incremental compile to SuperDevMode.

Change-Id: Id85b6ef83864eb4d4d9b8fd2434ed3f4adf5c642
Review-Link: https://gwt-review.googlesource.com/#/c/7142/
diff --git a/user/BUILD b/user/BUILD
index 6d77783..1dd9061 100644
--- a/user/BUILD
+++ b/user/BUILD
@@ -144,6 +144,32 @@
     ],
 )
 
+# Packages just IncrementalBuilder test resource into a jar with correct java root.
+AugmentedJar(
+    name = "incremental-build-system-test-res",
+    srcs = [],
+    added_root_globs = {
+        "test": [
+            "test/com/google/gwt/dev/testdata/incrementalbuildsystem/*",
+        ],
+    },
+    # We only need the Java classes so don't wait for the rest of :gwt-dev.
+    build_deps = [
+        "//third_party/java_src/gwt:gwt-user-full",
+        "//third_party/java_src/gwt/svn/tools:dev_deps",
+        "//third_party/java_src/gwt/svn/trunk/dev:compiler.standalone.super",
+        "//third_party/java_src/gwt/svn/trunk/dev:gwt-dev-classes",
+    ],
+    constraints = [],
+    dojarjar = 1,
+    exclude_glob = [
+        "**/package.html",
+        "**/package-info.java",
+    ],
+    output_name = "incremental-build-system-test-res.jar",
+    wrap_javalibrary = 0,
+)
+
 # See //third_party/java/gwt:regexp
 java_library(
     name = "jvm_regexp",
diff --git a/user/src/com/google/gwt/safecss/shared/SafeStylesHostedModeUtils.java b/user/src/com/google/gwt/safecss/shared/SafeStylesHostedModeUtils.java
index 4aaadae..a9ddbbb 100644
--- a/user/src/com/google/gwt/safecss/shared/SafeStylesHostedModeUtils.java
+++ b/user/src/com/google/gwt/safecss/shared/SafeStylesHostedModeUtils.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2011 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,6 +16,7 @@
 package com.google.gwt.safecss.shared;
 
 import com.google.gwt.core.shared.GWT;
+import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
 import com.google.gwt.thirdparty.guava.common.base.Preconditions;
 
 import java.util.HashMap;
@@ -24,11 +25,11 @@
 /**
  * SafeStyles utilities whose implementation differs between Development and
  * Production Mode.
- * 
+ *
  * <p>
  * This class has a super-source peer that provides the Production Mode
  * implementation.
- * 
+ *
  * <p>
  * Do not use this class - it is used for implementation only, and its methods
  * may change in the future.
@@ -50,21 +51,21 @@
 
   /**
    * Check if the specified style property name is valid.
-   * 
+   *
    * <p>
    * NOTE: This method does <em>NOT</em> guarantee the safety of a style name.
    * It looks for common errors, but does not check for every possible error. It
    * is intended to help validate a string that the user has already asserted is
    * safe.
    * </p>
-   * 
+   *
    * @param name the name to check
    * @return null if valid, an error string if not
    * @see <a
    *      href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS
    *      2.1 identifiers</a>
    */
-  // VisibleForTesting.
+  @VisibleForTesting
   public static String isValidStyleName(String name) {
     // Empty name.
     if (name == null || name.isEmpty()) {
@@ -101,20 +102,20 @@
 
   /**
    * Check if the specified style property value is valid.
-   * 
+   *
    * <p>
    * NOTE: This method does <em>NOT</em> guarantee the safety of a style value.
    * It looks for common errors, but does not check for every possible error. It
    * is intended to help validate a string that the user has already asserted is
    * safe.
    * </p>
-   * 
+   *
    * @param value the value to check
    * @return null if valid, an error string if not
    * @see <a href="http://www.w3.org/TR/CSS21/syndata.html#declaration">CSS 2.1
    *      declarations and properties</a>
    */
-  // VisibleForTesting.
+  @VisibleForTesting
   public static String isValidStyleValue(String value) {
     // Empty value.
     if (value == null || value.length() == 0) {
@@ -166,8 +167,8 @@
 
         /*
          * Almost all tokens are valid within a URL.
-         * 
-         * 
+         *
+         *
          * TODO(jlabanca): Check for unescaped quotes and whitespace in URLs.
          * Quotes and whitespace (other than the optional ones that wrap the
          * URL) should be escaped.
@@ -243,7 +244,7 @@
 
   /**
    * Checks if the provided string is a valid style property name.
-   * 
+   *
    * @param name the style name
    * @see <a
    *      href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS
@@ -260,7 +261,7 @@
 
   /**
    * Checks if the provided string is a valid style property value.
-   * 
+   *
    * @param value the style value
    * @see <a href="http://www.w3.org/TR/CSS21/syndata.html#declaration">CSS 2.1
    *      declarations and properties</a>
@@ -279,7 +280,7 @@
    * {@link #maybeCheckValidStyleName(String)} and
    * {@link #maybeCheckValidStyleValue(String)} should perform their checks in a
    * server-side environment.
-   * 
+   *
    * @param check if true, perform server-side checks.
    */
   public static void setForceCheckValidStyle(boolean check) {
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularB.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularB.gwt.xml
new file mode 100644
index 0000000..f19c870
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularB.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.CircularC" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularC.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularC.gwt.xml
new file mode 100644
index 0000000..b5eae77
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularC.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.CircularFilesetD" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularFilesetD.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularFilesetD.gwt.xml
new file mode 100644
index 0000000..3e9a9e2
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularFilesetD.gwt.xml
@@ -0,0 +1,3 @@
+<module type="fileset">
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.CircularB" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularRoot.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularRoot.gwt.xml
new file mode 100644
index 0000000..402002f
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/CircularRoot.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.CircularB" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateLeft.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateLeft.gwt.xml
new file mode 100644
index 0000000..b115103
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateLeft.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <source path="" includes="Foo.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRight.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRight.gwt.xml
new file mode 100644
index 0000000..b115103
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRight.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <source path="" includes="Foo.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRoot.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRoot.gwt.xml
new file mode 100644
index 0000000..f94563c
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/DuplicateRoot.gwt.xml
@@ -0,0 +1,4 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.DuplicateLeft" />
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.DuplicateRight" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java
new file mode 100644
index 0000000..0d9d7c8
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.testdata.incrementalbuildsystem;
+
+/**
+ * A test class that exists only to be replaced during compilation.
+ */
+public class Foo {
+}
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/LeftFooCreator.java b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/LeftFooCreator.java
new file mode 100644
index 0000000..aed6caa
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/LeftFooCreator.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.testdata.incrementalbuildsystem;
+
+import com.google.gwt.core.client.GWT;
+
+/**
+ * A test class that exists only to trigger generation on Foo.
+ */
+public class LeftFooCreator {
+
+  private Object foo = GWT.create(Foo.class);
+}
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelLeft.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelLeft.gwt.xml
new file mode 100644
index 0000000..7a4d98b
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelLeft.gwt.xml
@@ -0,0 +1,4 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.ProvidesFoo" />
+  <source path="" includes="LeftFooCreator.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRight.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRight.gwt.xml
new file mode 100644
index 0000000..6dfff21
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRight.gwt.xml
@@ -0,0 +1,4 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.ProvidesFoo" />
+  <source path="" includes="RightFooCreator.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRoot.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRoot.gwt.xml
new file mode 100644
index 0000000..ed30116
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ParallelRoot.gwt.xml
@@ -0,0 +1,5 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.ParallelLeft" />
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.ParallelRight" />
+  <source path="" includes="SomeClass.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ProvidesFoo.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ProvidesFoo.gwt.xml
new file mode 100644
index 0000000..2f8caf4
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/ProvidesFoo.gwt.xml
@@ -0,0 +1,6 @@
+<module>
+  <source path="" includes="Foo.java" />
+  <generate-with class="com.google.gwt.dev.FooBarGenerator">
+    <when-type-is class="com.google.gwt.dev.testdata.incrementalbuildsystem.Foo"/>
+  </generate-with>
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/RightFooCreator.java b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/RightFooCreator.java
new file mode 100644
index 0000000..a78bbee
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/RightFooCreator.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.testdata.incrementalbuildsystem;
+
+import com.google.gwt.core.client.GWT;
+
+/**
+ * A test class that exists only to trigger generation on Foo.
+ */
+public class RightFooCreator {
+
+  private Object foo = GWT.create(Foo.class);
+}
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleBottom.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleBottom.gwt.xml
new file mode 100644
index 0000000..bcf06b3
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleBottom.gwt.xml
@@ -0,0 +1,2 @@
+<module>
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleMid.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleMid.gwt.xml
new file mode 100644
index 0000000..85c1023
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleMid.gwt.xml
@@ -0,0 +1,4 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleBottom" />
+  <source path="" includes="Foo.java" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleTop.gwt.xml b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleTop.gwt.xml
new file mode 100644
index 0000000..e752079
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SimpleTop.gwt.xml
@@ -0,0 +1,3 @@
+<module>
+  <inherits name="com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleMid" />
+</module>
diff --git a/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SomeClass.java b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SomeClass.java
new file mode 100644
index 0000000..082ca98
--- /dev/null
+++ b/user/test/com/google/gwt/dev/testdata/incrementalbuildsystem/SomeClass.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.testdata.incrementalbuildsystem;
+
+/**
+ * A test class that exists only to give a test module something to compile.
+ */
+public class SomeClass {
+}