Deletes library compilation support.
Incremental monolithic compiles replace this functionality.
Change-Id: I351ed910a10df38ebcb2146d5cebcd83e8493746
Review-Link: https://gwt-review.googlesource.com/#/c/11150/
diff --git a/dev/BUILD b/dev/BUILD
index 3c325e4..33e8828 100644
--- a/dev/BUILD
+++ b/dev/BUILD
@@ -303,24 +303,6 @@
],
)
-gwt_test(
- name = "tests_dev.IncrementalBuilderTest",
- data = [
- "//third_party/java_src/gwt:gwt-dev-full.jar",
- "//third_party/java_src/gwt:gwt-user-full",
- "//third_party/java_src/gwt/svn/trunk/user:incremental-build-system-test-res.jar",
- ],
- jvm_flags = [
- "-Dgwt.cp=third_party/java_src/gwt/svn/trunk/user/incremental-build-system-test-res.jar\;third_party/java_src/gwt/gwt-dev-full.jar\;third_party/java_src/gwt/gwt-user-full.jar",
- "-ea",
- ],
- main_class = "com.google.gwt.dev.IncrementalBuilderTest",
- deps = [
- ":dev-test-code",
- "//third_party/java_src/gwt/svn/trunk/user:incremental-build-system-test-res",
- ],
-)
-
# The "dev" directory is tested by loose tests. Some of them fail because of
# classpath expectations that are invalid in Google's distributed build
# environment.
@@ -333,11 +315,6 @@
exclude = [
"core/test/**/ClassPathEntryTest.java",
"core/test/**/ResourceOracleImplTest.java",
- ] +
- # Handled separately because it needs a custom test target with
- # custom classpath.
- [
- "core/test/**/IncrementalBuilderTest.java",
],
)
diff --git a/dev/build.xml b/dev/build.xml
index 948831b..c3af1e5 100755
--- a/dev/build.xml
+++ b/dev/build.xml
@@ -8,12 +8,9 @@
<property name="alldeps.jar" location="${project.build}/alldeps.jar"/>
<property name="gwt.junit.testcase.dev.core.includes" value="**/com/google/**/*Test.class"/>
- <!-- BrowserManagerTest is brought in from user and is not instantiable.
- IncrementalBuilderTest needs a special setup.
- TODO(stalcup): Add the correct setup for IncrementalBuilderTest and reenable.
- -->
+ <!-- BrowserManagerTest is brought in from user and is not instantiable. -->
<property name="gwt.junit.testcase.dev.core.excludes"
- value="**/BrowserManagerTest.class **/IncrementalBuilderTest.class"/>
+ value="**/BrowserManagerTest.class"/>
<target name="clean" description="Cleans this project's intermediate and output files">
<delete dir="${project.build}" failonerror="false"/>
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
index 66bf6cb..9a8077a 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/CompilerOptionsImpl.java
@@ -111,6 +111,7 @@
}
@Override
+ @Deprecated
public List<String> getLibraryPaths() {
return ImmutableList.of();
}
@@ -139,6 +140,7 @@
}
@Override
+ @Deprecated
public File getMissingDepsFile() {
return null; // Don't record and save missing dependency information to a file.
}
@@ -164,6 +166,7 @@
}
@Override
+ @Deprecated
public String getOutputLibraryPath() {
return null;
}
diff --git a/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java b/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
index 54240b4..41d0352 100644
--- a/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
+++ b/dev/codeserver/java/com/google/gwt/dev/codeserver/UnmodifiableCompilerOptions.java
@@ -146,6 +146,7 @@
}
@Override
+ @Deprecated
public void setLibraryPaths(List<String> libraryPaths) {
throw new UnsupportedOperationException();
}
@@ -171,6 +172,7 @@
}
@Override
+ @Deprecated
public final void setMissingDepsFile(File file) {
throw new UnsupportedOperationException();
}
@@ -211,6 +213,7 @@
}
@Override
+ @Deprecated
public void setOutputLibraryPath(String outputLibraryPath) {
throw new UnsupportedOperationException();
}
@@ -281,11 +284,13 @@
}
@Override
+ @Deprecated
public final void setWarnOverlappingSource(boolean warnOverlappingSource) {
throw new UnsupportedOperationException();
}
@Override
+ @Deprecated
public final void setWarnMissingDeps(boolean warnMissingDeps) {
throw new UnsupportedOperationException();
}
diff --git a/dev/core/src/com/google/gwt/dev/BuildTarget.java b/dev/core/src/com/google/gwt/dev/BuildTarget.java
deleted file mode 100644
index d3a12f7..0000000
--- a/dev/core/src/com/google/gwt/dev/BuildTarget.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.cfg.RuntimeRebindRuleGenerator;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.base.Function;
-import com.google.gwt.thirdparty.guava.common.collect.Iterables;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-
-/**
- * Represents a module in a module tree, knows how to build that module into an output library and
- * checks output library freshness.
- * <p>
- * Build requests will first build all dependency libraries (even if some fail). But the current
- * target will only be built if all dependency library builds were successful.
- */
-class BuildTarget {
-
- /**
- * Represents a combination of whether output is current and whether output is good. For example
- * if a build is run and it fails, then output is fresh and does not need to be rebuilt but it is
- * also known to be bad.
- */
- public enum OutputFreshness {
- FRESH_KNOWN_BAD, FRESH_KNOWN_GOOD, STALE, UNKNOWN
- }
-
- public static final Function<BuildTarget, String> LIBRARY_PATH_FUNCTION =
- new Function<BuildTarget, String>() {
- @Override
- public String apply(@Nullable BuildTarget buildTarget) {
- return buildTarget.computeLibraryPath();
- }
- };
-
- @VisibleForTesting
- public static String formatCompilingModuleMessage(String canonicalModuleName) {
- return "\n" + "Compiling module " + canonicalModuleName;
- }
-
- @VisibleForTesting
- public static String formatReusingCachedLibraryMessage(String canonicalModuleName) {
- return "Reusing cached library for " + canonicalModuleName;
- }
-
- private final BuildTargetOptions buildTargetOptions;
- private final String canonicalModuleName;
- private final List<BuildTarget> dependencyBuildTargets;
- private ModuleDef module;
- private OutputFreshness outputFreshness = OutputFreshness.UNKNOWN;
- private Set<BuildTarget> transitiveDependencyBuildTargets;
-
- BuildTarget(String canonicalModuleName, BuildTargetOptions buildTargetOptions,
- BuildTarget... dependencyBuildTargets) {
- this.canonicalModuleName = canonicalModuleName;
- this.buildTargetOptions = buildTargetOptions;
- this.dependencyBuildTargets = Arrays.asList(dependencyBuildTargets);
- }
-
- public boolean build(TreeLogger logger) {
- return build(logger, false);
- }
-
- public boolean build(TreeLogger logger, boolean link) {
- if (outputFreshness == OutputFreshness.FRESH_KNOWN_GOOD
- || outputFreshness == OutputFreshness.FRESH_KNOWN_BAD) {
- logger.log(TreeLogger.SPAM, formatReusingCachedLibraryMessage(canonicalModuleName));
- return outputFreshness == OutputFreshness.FRESH_KNOWN_GOOD;
- }
-
- boolean dependencyBuildsSucceeded = true;
- // Build all my dependencies before myself.
- for (BuildTarget dependencyBuildTarget : dependencyBuildTargets) {
- // If any dependency fails to build then I have failed to build as well.
- dependencyBuildsSucceeded &= dependencyBuildTarget.build(logger);
- }
- if (!dependencyBuildsSucceeded) {
- outputFreshness = OutputFreshness.FRESH_KNOWN_BAD;
- return false; // Build failed.
- }
-
- TreeLogger branch =
- logger.branch(TreeLogger.INFO, formatCompilingModuleMessage(canonicalModuleName));
- boolean thisBuildSucceeded;
- try {
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME.clear();
- LibraryCompiler libraryCompiler = new LibraryCompiler(computeCompileOptions(link));
- libraryCompiler.setResourceLoader(buildTargetOptions.getResourceLoader());
- thisBuildSucceeded = libraryCompiler.run(branch);
- module = libraryCompiler.getModule();
- } catch (Throwable t) {
- logger.log(TreeLogger.ERROR, t.getMessage());
- outputFreshness = OutputFreshness.FRESH_KNOWN_BAD;
- return false;
- }
- outputFreshness =
- thisBuildSucceeded ? OutputFreshness.FRESH_KNOWN_GOOD : OutputFreshness.FRESH_KNOWN_BAD;
- return thisBuildSucceeded;
- }
-
- public CompilerOptions computeCompileOptions(boolean link) {
- CompilerOptions compilerOptions = new CompilerOptionsImpl();
- // Must compile the canonical name, not name, since after module-renames there may be more
- // than one module in the classpath with the same name and we don't want to find and recompile
- // the same one over and over.
- compilerOptions.setModuleNames(Lists.newArrayList(canonicalModuleName));
- compilerOptions.setLink(link);
- compilerOptions.setLogLevel(TreeLogger.ERROR);
- compilerOptions.setGenDir(new File(buildTargetOptions.getGenDir()));
- compilerOptions.setWorkDir(new File(buildTargetOptions.getOutputDir()));
- compilerOptions.setLibraryPaths(Lists.newArrayList(
- Iterables.transform(getTransitiveDependencyBuildTargets(), LIBRARY_PATH_FUNCTION)));
- compilerOptions.setFinalProperties(buildTargetOptions.getFinalProperties());
-
- if (!link) {
- compilerOptions.setOutputLibraryPath(computeLibraryPath());
- } else {
- compilerOptions.setWarDir(new File(buildTargetOptions.getWarDir()));
- }
- return compilerOptions;
- }
-
- public String computeLibraryPath() {
- return buildTargetOptions.getOutputDir() + "/" + canonicalModuleName + ".gwtlib";
- }
-
- public void computeOutputFreshness(TreeLogger logger) {
- if (outputFreshness != OutputFreshness.UNKNOWN) {
- return;
- }
-
- for (BuildTarget dependencyBuildTarget : dependencyBuildTargets) {
- dependencyBuildTarget.computeOutputFreshness(logger);
- }
-
- if (module == null) {
- logger.log(TreeLogger.SPAM,
- "Library " + canonicalModuleName + " is stale: the module hasn't been loaded yet");
- outputFreshness = OutputFreshness.STALE;
- return;
- }
-
- for (BuildTarget dependencyBuildTarget : dependencyBuildTargets) {
- if (dependencyBuildTarget.outputFreshness == OutputFreshness.STALE) {
- logger.log(TreeLogger.SPAM,
- "Library " + canonicalModuleName + " is stale: has a stale dependency");
- outputFreshness = OutputFreshness.STALE;
- return;
- }
- }
-
- File libraryFile = new File(computeLibraryPath());
- if (!libraryFile.exists()) {
- logger.log(TreeLogger.SPAM,
- "Library " + canonicalModuleName + " is stale: the library file is missing");
- outputFreshness = OutputFreshness.STALE;
- return;
- }
- long libraryFileLastModified = libraryFile.lastModified();
- module.refresh();
- if (libraryFileLastModified < module.getResourceLastModified()) {
- Set<Resource> newerResources = module.getResourcesNewerThan(libraryFileLastModified);
- TreeLogger branch = logger.branch(TreeLogger.SPAM,
- "Library " + canonicalModuleName + " is stale: library is older than some resource(s)");
- for (Resource newerResource : newerResources) {
- branch.log(TreeLogger.SPAM, newerResource.getPath() + " has changed");
- }
- outputFreshness = OutputFreshness.STALE;
- return;
- }
-
- logger.log(TreeLogger.SPAM, "Library " + canonicalModuleName + " is fresh");
- outputFreshness = OutputFreshness.FRESH_KNOWN_GOOD;
- }
-
- public String getCanonicalModuleName() {
- return canonicalModuleName;
- }
-
- public List<BuildTarget> getDependencyBuildTargets() {
- return dependencyBuildTargets;
- }
-
- public Set<BuildTarget> getTransitiveDependencyBuildTargets() {
- if (transitiveDependencyBuildTargets == null) {
- transitiveDependencyBuildTargets = Sets.newHashSet();
- transitiveDependencyBuildTargets.addAll(dependencyBuildTargets);
- for (BuildTarget buildTarget : dependencyBuildTargets) {
- transitiveDependencyBuildTargets.addAll(buildTarget.getTransitiveDependencyBuildTargets());
- }
- }
- return transitiveDependencyBuildTargets;
- }
-
- public boolean isOutputFreshAndGood() {
- return outputFreshness == OutputFreshness.FRESH_KNOWN_GOOD;
- }
-
- public boolean link(TreeLogger logger) {
- return build(logger, true);
- }
-
- public void setModule(ModuleDef module) {
- this.module = module;
- }
-
- public void setOutputFreshness(OutputFreshness outputFreshness) {
- this.outputFreshness = outputFreshness;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/BuildTargetOptions.java b/dev/core/src/com/google/gwt/dev/BuildTargetOptions.java
deleted file mode 100644
index 210557a..0000000
--- a/dev/core/src/com/google/gwt/dev/BuildTargetOptions.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-import com.google.gwt.dev.cfg.Properties;
-import com.google.gwt.dev.cfg.ResourceLoader;
-
-/**
- * An interface for classes that can answer build target option questions.
- */
-public interface BuildTargetOptions {
-
- /**
- * Returns the property object whose values should be considered "final" when deciding which
- * generators to run during library compilation.
- */
- Properties getFinalProperties();
-
- /**
- * Returns the directory path into which to dump a copy of any generated source.
- */
- String getGenDir();
-
- /**
- * Returns the directory path the compiler is free to use to write temporary files which are not
- * part of final link output.
- */
- String getOutputDir();
-
- /**
- * Returns the resource loader to use when finding and loading compilable source, build resources
- * such as PNG and CSS files and public resources such as HTML files.
- */
- ResourceLoader getResourceLoader();
-
- /**
- * Returns the directory path into which the compiler should write linked output.
- */
- String getWarDir();
-}
diff --git a/dev/core/src/com/google/gwt/dev/CompilePerms.java b/dev/core/src/com/google/gwt/dev/CompilePerms.java
index 7a27b99..fad0dc0 100644
--- a/dev/core/src/com/google/gwt/dev/CompilePerms.java
+++ b/dev/core/src/com/google/gwt/dev/CompilePerms.java
@@ -204,15 +204,11 @@
Precompilation precompilation, Permutation[] perms, int localWorkers,
List<PersistenceBackedObject<PermutationResult>> resultFiles)
throws UnableToCompleteException {
- boolean shouldCompileMonolithic = compilerContext.shouldCompileMonolithic();
- final TreeLogger branch = shouldCompileMonolithic ? (logger.branch(
- TreeLogger.INFO,
- "Compiling " + perms.length + " permutation" + (perms.length > 1 ? "s" : ""))) : logger;
+ final TreeLogger branch = logger.branch(TreeLogger.INFO,
+ "Compiling " + perms.length + " permutation" + (perms.length > 1 ? "s" : ""));
PermutationWorkerFactory.compilePermutations(
branch, compilerContext, precompilation, perms, localWorkers, resultFiles);
- if (shouldCompileMonolithic) {
- logger.log(TreeLogger.INFO, "Compile of permutations succeeded");
- }
+ logger.log(TreeLogger.INFO, "Compile of permutations succeeded");
}
public static void main(String[] args) {
diff --git a/dev/core/src/com/google/gwt/dev/CompilerContext.java b/dev/core/src/com/google/gwt/dev/CompilerContext.java
index 96e9733..d3941a1 100644
--- a/dev/core/src/com/google/gwt/dev/CompilerContext.java
+++ b/dev/core/src/com/google/gwt/dev/CompilerContext.java
@@ -13,24 +13,12 @@
*/
package com.google.gwt.dev;
-import com.google.gwt.dev.cfg.CombinedResourceOracle;
-import com.google.gwt.dev.cfg.ImmutableLibraryGroup;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.LibraryGroupBuildResourceOracle;
-import com.google.gwt.dev.cfg.LibraryGroupPublicResourceOracle;
-import com.google.gwt.dev.cfg.LibraryWriter;
import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.cfg.NullLibraryWriter;
-import com.google.gwt.dev.javac.CombinedCompilationErrorsIndex;
import com.google.gwt.dev.javac.CompilationErrorsIndex;
import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
import com.google.gwt.dev.javac.MemoryUnitCache;
import com.google.gwt.dev.javac.UnitCache;
import com.google.gwt.dev.resource.ResourceOracle;
-import com.google.gwt.dev.util.TinyCompileSummary;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.util.Set;
/**
* Contains most global read-only compiler state and makes it easily accessible to the far flung
@@ -45,13 +33,8 @@
public static class Builder {
private ResourceOracle buildResourceOracle;
- private boolean compileMonolithic = true;
+ private CompilationErrorsIndex compilationErrorsIndex;
private MinimalRebuildCache minimalRebuildCache = new MinimalRebuildCache();
- private CompilationErrorsIndex globalCompilationErrorsIndex;
- private CompilationErrorsIndex libraryCompilationErrorsIndex;
- private LibraryGroup libraryGroup = new ImmutableLibraryGroup();
- private LibraryWriter libraryWriter = new NullLibraryWriter();
- private CompilationErrorsIndex localCompilationErrorsIndex;
private ModuleDef module;
private PrecompileTaskOptions options = new PrecompileTaskOptionsImpl();
private ResourceOracle publicResourceOracle;
@@ -65,37 +48,18 @@
CompilerContext compilerContext = new CompilerContext();
compilerContext.buildResourceOracle = buildResourceOracle;
compilerContext.minimalRebuildCache = minimalRebuildCache;
- compilerContext.libraryWriter = libraryWriter;
- compilerContext.libraryGroup = libraryGroup;
compilerContext.module = module;
- compilerContext.compileMonolithic = compileMonolithic;
compilerContext.options = options;
compilerContext.publicResourceOracle = publicResourceOracle;
compilerContext.sourceResourceOracle = sourceResourceOracle;
- compilerContext.localCompilationErrorsIndex = localCompilationErrorsIndex;
- compilerContext.globalCompilationErrorsIndex = globalCompilationErrorsIndex;
+ compilerContext.compilationErrorsIndex = compilationErrorsIndex;
compilerContext.unitCache = unitCache;
return compilerContext;
}
- /**
- * Sets whether compilation should proceed monolithically or separately.
- */
- public Builder compileMonolithic(boolean compileMonolithic) {
- this.compileMonolithic = compileMonolithic;
- return this;
- }
-
- /**
- * Sets the libraryGroup and uses it to set resource oracles as well.
- */
- public Builder libraryGroup(LibraryGroup libraryGroup) {
- this.libraryGroup = libraryGroup;
- return this;
- }
-
- public Builder libraryWriter(LibraryWriter libraryWriter) {
- this.libraryWriter = libraryWriter;
+ public Builder minimalRebuildCache(MinimalRebuildCache minimalRebuildCache) {
+ assert minimalRebuildCache != null;
+ this.minimalRebuildCache = minimalRebuildCache;
return this;
}
@@ -112,78 +76,38 @@
return this;
}
- public Builder minimalRebuildCache(MinimalRebuildCache minimalRebuildCache) {
- assert minimalRebuildCache != null;
- this.minimalRebuildCache = minimalRebuildCache;
- return this;
- }
-
public Builder unitCache(UnitCache unitCache) {
this.unitCache = unitCache;
return this;
}
private void initializeCompilationErrorIndexes() {
- localCompilationErrorsIndex = new CompilationErrorsIndexImpl();
- libraryCompilationErrorsIndex = libraryGroup != null
- ? libraryGroup.getCompilationErrorsIndex() : new CompilationErrorsIndexImpl();
- globalCompilationErrorsIndex = new CombinedCompilationErrorsIndex(localCompilationErrorsIndex,
- libraryCompilationErrorsIndex);
+ compilationErrorsIndex = new CompilationErrorsIndexImpl();
}
/**
* Initialize source, build, and public resource oracles using the most complete currently
- * available combination of moduleDef and libraryGroup.<br />
+ * available moduleDef.<br />
*
- * When executing as part of a monolithic compilation there will likely only be a moduleDef
- * available. That will result in sourcing resource oracles only from it, which is what
- * monolithic compilation expects.<br />
- *
- * When executing as part of a separate compilation there will likely be both a moduleDef and
- * libraryGroup available. That will result in sourcing resource oracles from a mixed
- * combination, which is what separate compilation expects.
+ * There will likely only be a moduleDef available. That will result in sourcing resource
+ * oracles only from it, which is what monolithic compilation expects.
*/
private void initializeResourceOracles() {
- if (libraryGroup != null) {
- if (module != null) {
- sourceResourceOracle = module.getSourceResourceOracle();
- buildResourceOracle = new CombinedResourceOracle(
- module.getBuildResourceOracle(), new LibraryGroupBuildResourceOracle(libraryGroup));
- publicResourceOracle = new CombinedResourceOracle(
- module.getPublicResourceOracle(), new LibraryGroupPublicResourceOracle(libraryGroup));
- } else {
- sourceResourceOracle = null;
- buildResourceOracle = new LibraryGroupBuildResourceOracle(libraryGroup);
- publicResourceOracle = new LibraryGroupPublicResourceOracle(libraryGroup);
- }
+ if (module != null) {
+ sourceResourceOracle = module.getSourceResourceOracle();
+ buildResourceOracle = module.getBuildResourceOracle();
+ publicResourceOracle = module.getPublicResourceOracle();
} else {
- if (module != null) {
- sourceResourceOracle = module.getSourceResourceOracle();
- buildResourceOracle = module.getBuildResourceOracle();
- publicResourceOracle = module.getPublicResourceOracle();
- } else {
- sourceResourceOracle = null;
- buildResourceOracle = null;
- publicResourceOracle = null;
- }
+ sourceResourceOracle = null;
+ buildResourceOracle = null;
+ publicResourceOracle = null;
}
}
}
private ResourceOracle buildResourceOracle;
- /**
- * Whether compilation should proceed monolithically or separately. It is an example of a
- * configuration property that is not assignable by command line args. If more of these accumulate
- * they should be grouped together instead of floating free here.
- */
- private boolean compileMonolithic = true;
-
+ private CompilationErrorsIndex compilationErrorsIndex = new CompilationErrorsIndexImpl();
private MinimalRebuildCache minimalRebuildCache = new MinimalRebuildCache();
- private LibraryGroup libraryGroup = new ImmutableLibraryGroup();
- private LibraryWriter libraryWriter = new NullLibraryWriter();
- private CompilationErrorsIndex localCompilationErrorsIndex = new CompilationErrorsIndexImpl();
- private CompilationErrorsIndex globalCompilationErrorsIndex = new CombinedCompilationErrorsIndex(
- localCompilationErrorsIndex, new CompilationErrorsIndexImpl());
private ModuleDef module;
// TODO(stalcup): split this into module parsing, precompilation, compilation, and linking option
// sets.
@@ -191,37 +115,20 @@
private ResourceOracle publicResourceOracle;
private ResourceOracle sourceResourceOracle;
- private TinyCompileSummary tinyCompileSummary = new TinyCompileSummary();
private UnitCache unitCache = new MemoryUnitCache();
public ResourceOracle getBuildResourceOracle() {
return buildResourceOracle;
}
- public MinimalRebuildCache getMinimalRebuildCache() {
- return minimalRebuildCache;
- }
-
- /**
- * Returns the immutable compilation errors index that provides a combined view of compilation
- * errors for both the current compile as well as previously compiled libraries.
- */
- public CompilationErrorsIndex getGlobalCompilationErrorsIndex() {
- return globalCompilationErrorsIndex;
- }
-
- public LibraryGroup getLibraryGroup() {
- return libraryGroup;
- }
-
- public LibraryWriter getLibraryWriter() {
- return libraryWriter;
- }
-
/**
* Returns the mutable index of compilation errors for the current compile.
*/
- public CompilationErrorsIndex getLocalCompilationErrorsIndex() {
- return localCompilationErrorsIndex;
+ public CompilationErrorsIndex getCompilationErrorsIndex() {
+ return compilationErrorsIndex;
+ }
+
+ public MinimalRebuildCache getMinimalRebuildCache() {
+ return minimalRebuildCache;
}
public ModuleDef getModule() {
@@ -232,47 +139,15 @@
return options;
}
- /**
- * Returns the set of source names of rebound types that have been processed by the given
- * Generator.
- */
- public Set<String> getProcessedReboundTypeSourceNames(String generatorName) {
- Set<String> processedReboundTypeSourceNames = Sets.newHashSet();
- processedReboundTypeSourceNames.addAll(
- getLibraryWriter().getProcessedReboundTypeSourceNames(generatorName));
- processedReboundTypeSourceNames.addAll(
- getLibraryGroup().getProcessedReboundTypeSourceNames(generatorName));
- return processedReboundTypeSourceNames;
- }
-
public ResourceOracle getPublicResourceOracle() {
return publicResourceOracle;
}
- /**
- * Returns the set of source names of types for which GWT.create() rebind has been requested. The
- * types may or may not yet have been processed by some Generators.
- */
- public Set<String> getReboundTypeSourceNames() {
- Set<String> reboundTypeSourceNames = Sets.newHashSet();
- reboundTypeSourceNames.addAll(getLibraryWriter().getReboundTypeSourceNames());
- reboundTypeSourceNames.addAll(getLibraryGroup().getReboundTypeSourceNames());
- return reboundTypeSourceNames;
- }
-
public ResourceOracle getSourceResourceOracle() {
return sourceResourceOracle;
}
- public TinyCompileSummary getTinyCompileSummary() {
- return tinyCompileSummary;
- }
-
public UnitCache getUnitCache() {
return unitCache;
}
-
- public boolean shouldCompileMonolithic() {
- return compileMonolithic;
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/IncrementalBuilder.java b/dev/core/src/com/google/gwt/dev/IncrementalBuilder.java
deleted file mode 100644
index d09fde2..0000000
--- a/dev/core/src/com/google/gwt/dev/IncrementalBuilder.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * 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;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.impl.ResourceGeneratorUtilImpl;
-import com.google.gwt.dev.BuildTarget.OutputFreshness;
-import com.google.gwt.dev.cfg.Library;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.cfg.ModuleDefLoader;
-import com.google.gwt.dev.cfg.Properties;
-import com.google.gwt.dev.cfg.ResourceLoader;
-import com.google.gwt.dev.resource.impl.ResourceOracleImpl;
-import com.google.gwt.dev.resource.impl.ZipFileClassPathEntry;
-import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.base.Joiner;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Incrementally builds, links, and rebuilds module trees.
- */
-public class IncrementalBuilder {
-
- /**
- * Represents a combination of whether a build succeeded and whether output changed.
- */
- public static enum BuildResultStatus {
- FAILED(false), SUCCESS_NO_CHANGES(true), SUCCESS_WITH_CHANGES(true);
-
- private static BuildResultStatus get(boolean success) {
- return success ? SUCCESS_WITH_CHANGES : FAILED;
- }
-
- private boolean success;
-
- private BuildResultStatus(boolean success) {
- this.success = success;
- }
-
- public boolean isSuccess() {
- return success;
- }
- }
-
- @VisibleForTesting
- static final String NO_FILES_HAVE_CHANGED = "No files have changed; all output is still fresh.";
-
- @VisibleForTesting
- protected static String formatCircularModulePathMessage(List<String> circularModulePath) {
- return "Can't compile because of a module circular reference:\n "
- + Joiner.on("\n ").join(circularModulePath);
- }
-
- private Map<String, BuildTarget> buildTargetsByCanonicalModuleName = Maps.newLinkedHashMap();
- private List<List<String>> circularReferenceModuleNameLoops = Lists.newArrayList();
- private Properties finalProperties;
- private String genDir;
- private Set<String> knownCircularlyReferentModuleNames = Sets.newHashSet();
- private Set<String> moduleReferencePath = Sets.newLinkedHashSet();
- private String outputDir;
- private final ResourceLoader resourceLoader;
- private BuildTarget rootBuildTarget;
- private ModuleDef rootModule;
- private final String rootModuleName;
- private String warDir;
- private BuildTargetOptions buildTargetOptions = new BuildTargetOptions() {
-
- @Override
- public Properties getFinalProperties() {
- return IncrementalBuilder.this.finalProperties;
- }
-
- @Override
- public String getGenDir() {
- return IncrementalBuilder.this.genDir;
- }
-
- @Override
- public String getOutputDir() {
- return IncrementalBuilder.this.outputDir;
- }
-
- @Override
- public ResourceLoader getResourceLoader() {
- return IncrementalBuilder.this.resourceLoader;
- }
-
- @Override
- public String getWarDir() {
- return IncrementalBuilder.this.warDir;
- }
- };
-
- public IncrementalBuilder(String rootModuleName, String warDir, String libDir, String genDir,
- ResourceLoader resourceLoader) {
- this.rootModuleName = rootModuleName;
- this.warDir = warDir;
- this.outputDir = libDir;
- this.genDir = genDir;
- this.resourceLoader = resourceLoader;
- }
-
- public BuildResultStatus build(TreeLogger logger) {
- try {
- logger = logger.branch(TreeLogger.INFO, "Performing an incremental build");
-
- CompilerContext compilerContext = new CompilerContext.Builder().compileMonolithic(false)
- .libraryGroup(LibraryGroup.fromLibraries(Lists.<Library> newArrayList(), false)).build();
- long beforeLoadRootModuleMs = System.currentTimeMillis();
- rootModule = ModuleDefLoader.loadFromResources(logger, compilerContext, rootModuleName,
- resourceLoader, false);
- finalProperties = rootModule.getProperties();
- long loadRootModuleDurationMs = System.currentTimeMillis() - beforeLoadRootModuleMs;
- logger.log(TreeLogger.INFO, String.format(
- "%.3fs -- Parsing and loading root module definition in %s",
- loadRootModuleDurationMs / 1000d, rootModuleName));
-
- long beforeCreateTargetGraphMs = System.currentTimeMillis();
- rootBuildTarget = createBuildTarget(logger, rootModuleName);
- rootBuildTarget.setModule(rootModule);
- long createdTargetGraphDurationMs = System.currentTimeMillis() - beforeCreateTargetGraphMs;
- logger.log(TreeLogger.INFO, String.format("%.3fs -- Creating target graph (%s targets)",
- createdTargetGraphDurationMs / 1000d, buildTargetsByCanonicalModuleName.size()));
-
- if (!circularReferenceModuleNameLoops.isEmpty()) {
- for (List<String> circularReferenceModuleNameLoop : circularReferenceModuleNameLoops) {
- logger.log(TreeLogger.ERROR,
- formatCircularModulePathMessage(circularReferenceModuleNameLoop));
- }
- throw new UnableToCompleteException();
- }
- logLoadedBuildTargetGraph(logger, buildTargetsByCanonicalModuleName);
-
- long beforeComputeOutputFreshnessMs = System.currentTimeMillis();
- ModuleDefLoader.clearModuleCache();
- rootBuildTarget.computeOutputFreshness(logger);
- long computeOutputFreshnessDurationMs =
- System.currentTimeMillis() - beforeComputeOutputFreshnessMs;
- logger.log(TreeLogger.INFO, String.format("%.3fs -- Computing per-target output freshness",
- computeOutputFreshnessDurationMs / 1000d));
-
- TreeLogger branch = logger.branch(TreeLogger.INFO, "Compiling target graph");
- boolean success = rootBuildTarget.link(branch);
- return BuildResultStatus.get(success);
- } catch (UnableToCompleteException e) {
- // The real cause has been logged.
- return BuildResultStatus.FAILED;
- }
- }
-
- public String getRootModuleName() {
- if (rootModule == null) {
- return "UNKNOWN";
- }
- return rootModule.getName();
- }
-
- public boolean isRootModuleKnown() {
- return rootModule != null;
- }
-
- public BuildResultStatus rebuild(TreeLogger logger) {
- logger = logger.branch(TreeLogger.INFO, "Performing an incremental rebuild");
-
- ResourceOracleImpl.clearCache();
- ZipFileClassPathEntry.clearCache();
- ModuleDefLoader.clearModuleCache();
- ResourceGeneratorUtilImpl.clearGeneratedFilesByName();
-
- long beforeComputeOutputFreshnessMs = System.currentTimeMillis();
- forgetAllOutputFreshness();
- rootBuildTarget.computeOutputFreshness(logger);
- long computeOutputFreshnessDurationMs =
- System.currentTimeMillis() - beforeComputeOutputFreshnessMs;
- logger.log(TreeLogger.INFO, String.format("%.3fs -- Computing per-target output freshness",
- computeOutputFreshnessDurationMs / 1000d));
-
- if (rootBuildTarget.isOutputFreshAndGood()) {
- logger.log(TreeLogger.INFO, NO_FILES_HAVE_CHANGED);
- return BuildResultStatus.SUCCESS_NO_CHANGES;
- }
-
- TreeLogger branch = logger.branch(TreeLogger.INFO, "Compiling target graph");
- boolean success = rootBuildTarget.link(branch);
- return BuildResultStatus.get(success);
- }
-
- public void setWarDir(String warDir) {
- this.warDir = warDir;
- }
-
- @VisibleForTesting
- void clean() {
- File[] files = new File(outputDir).listFiles();
- if (files == null) {
- // nothing to delete
- return;
- }
- for (File file : files) {
- file.delete();
- }
- }
-
- private BuildTarget createBuildTarget(String canonicalModuleName, BuildTarget... buildTargets) {
- if (!buildTargetsByCanonicalModuleName.containsKey(canonicalModuleName)) {
- buildTargetsByCanonicalModuleName.put(canonicalModuleName,
- new BuildTarget(canonicalModuleName, buildTargetOptions, buildTargets));
- }
- return buildTargetsByCanonicalModuleName.get(canonicalModuleName);
- }
-
- private BuildTarget createBuildTarget(TreeLogger logger, String moduleName)
- throws UnableToCompleteException {
- if (isCircularlyReferent(moduleName)) {
- // Allow the target graph creation to continue so that all of the circular reference loops can
- // be gathered.
- return null;
- }
- if (buildTargetsByCanonicalModuleName.containsKey(moduleName)) {
- return buildTargetsByCanonicalModuleName.get(moduleName);
- }
-
- logger.log(TreeLogger.SPAM, String.format("Adding target %s to build graph.", moduleName));
- moduleReferencePath.add(moduleName);
-
- List<BuildTarget> dependencyBuildTargets = Lists.newArrayList();
- for (String dependencyModuleName : rootModule.getDirectDependencies(moduleName)) {
- dependencyBuildTargets.add(createBuildTarget(logger, dependencyModuleName));
- }
- moduleReferencePath.remove(moduleName);
-
- return createBuildTarget(moduleName, dependencyBuildTargets.toArray(new BuildTarget[0]));
- }
-
- private void forgetAllOutputFreshness() {
- for (BuildTarget buildTarget : buildTargetsByCanonicalModuleName.values()) {
- buildTarget.setOutputFreshness(OutputFreshness.UNKNOWN);
- }
- }
-
- private boolean isCircularlyReferent(String potentialDuplicateModuleName) {
- if (knownCircularlyReferentModuleNames.contains(potentialDuplicateModuleName)) {
- return true;
- }
- if (!moduleReferencePath.contains(potentialDuplicateModuleName)) {
- return false;
- }
-
- List<String> circularModuleReferencePath = Lists.newArrayList(moduleReferencePath);
-
- // Attach the duplicate module name to the end of the loop.
- circularModuleReferencePath.add(potentialDuplicateModuleName);
-
- List<String> annotatedCircularModuleReferencePath = Lists.newArrayList();
- // The current module path only includes libraries but the connections between libraries might
- // be silently flowing through filesets. Add filesets to the path so that the output is more
- // readable.
- for (int moduleNameIndex = 0; moduleNameIndex < circularModuleReferencePath.size() - 1;
- moduleNameIndex++) {
- String thisModuleName = circularModuleReferencePath.get(moduleNameIndex);
- String nextModuleName = circularModuleReferencePath.get(moduleNameIndex + 1);
-
- annotatedCircularModuleReferencePath.add(
- thisModuleName + (thisModuleName.equals(potentialDuplicateModuleName) ? " <loop>" : ""));
-
- List<String> fileSetPath = rootModule.getFileSetPathBetween(thisModuleName, nextModuleName);
- if (fileSetPath != null) {
- for (String fileSetModuleName : fileSetPath) {
- annotatedCircularModuleReferencePath.add(fileSetModuleName + " <fileset>");
- }
- }
- }
-
- // Attach the duplicate module name to the end of the loop.
- annotatedCircularModuleReferencePath.add(potentialDuplicateModuleName + " <loop>");
-
- knownCircularlyReferentModuleNames.addAll(annotatedCircularModuleReferencePath);
- circularReferenceModuleNameLoops.add(annotatedCircularModuleReferencePath);
- return true;
- }
-
- private void logLoadedBuildTargetGraph(TreeLogger logger,
- Map<String, BuildTarget> buildTargetsByCanonicalModuleName) {
- logger.log(TreeLogger.SPAM, "Loaded build target graph:");
- for (String canonicalModuleName : buildTargetsByCanonicalModuleName.keySet()) {
- logger.log(TreeLogger.SPAM, "\t" + canonicalModuleName);
- BuildTarget gwtTarget = buildTargetsByCanonicalModuleName.get(canonicalModuleName);
- for (BuildTarget dependencyBuildTarget : gwtTarget.getDependencyBuildTargets()) {
- logger.log(TreeLogger.SPAM, "\t\t" + dependencyBuildTarget.getCanonicalModuleName());
- }
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/LibraryCompiler.java b/dev/core/src/com/google/gwt/dev/LibraryCompiler.java
deleted file mode 100644
index 1b5b607..0000000
--- a/dev/core/src/com/google/gwt/dev/LibraryCompiler.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * 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;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.CompileTaskRunner.CompileTask;
-import com.google.gwt.dev.cfg.Libraries.IncompatibleLibraryVersionException;
-import com.google.gwt.dev.cfg.Library;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.LibraryWriter;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.dev.cfg.ModuleDefLoader;
-import com.google.gwt.dev.cfg.ResourceLoader;
-import com.google.gwt.dev.cfg.ResourceLoaders;
-import com.google.gwt.dev.cfg.ZipLibrary;
-import com.google.gwt.dev.cfg.ZipLibraryWriter;
-import com.google.gwt.dev.javac.UnitCacheSingleton;
-import com.google.gwt.dev.jjs.JsOutputOption;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.url.CloseableJarHandlerFactory;
-import com.google.gwt.dev.util.Memory;
-import com.google.gwt.dev.util.PersistenceBackedObject;
-import com.google.gwt.dev.util.TinyCompileSummary;
-import com.google.gwt.dev.util.Util;
-import com.google.gwt.dev.util.arg.ArgHandlerDeployDir;
-import com.google.gwt.dev.util.arg.ArgHandlerExtraDir;
-import com.google.gwt.dev.util.arg.ArgHandlerLibraries;
-import com.google.gwt.dev.util.arg.ArgHandlerLink;
-import com.google.gwt.dev.util.arg.ArgHandlerLocalWorkers;
-import com.google.gwt.dev.util.arg.ArgHandlerOutputLibrary;
-import com.google.gwt.dev.util.arg.ArgHandlerSaveSourceOutput;
-import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
-import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
-import com.google.gwt.dev.util.arg.OptionOptimize;
-import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
-import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
-import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
-import com.google.gwt.thirdparty.guava.common.base.Preconditions;
-import com.google.gwt.thirdparty.guava.common.base.Strings;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.util.tools.Utility;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Executable compiler entry point that constructs a library from an input module and its library
- * dependencies.
- * <p>
- * When compiling the top-level module, you should also pass the -link and -war flags to create the
- * GWT application.
- * <p>
- * This is an alternative to Compiler.java which does a full world compile that neither reads nor
- * writes libraries.
- */
-public class LibraryCompiler {
-
- private static class ArgProcessor extends PrecompileTaskArgProcessor {
- public ArgProcessor(CompilerOptions options) {
- super(options);
-
- registerHandler(new ArgHandlerLocalWorkers(options));
-
- // Override the ArgHandlerWorkDirRequired in the super class.
- registerHandler(new ArgHandlerWorkDirOptional(options));
- registerHandler(new ArgHandlerWarDir(options));
- registerHandler(new ArgHandlerDeployDir(options));
- registerHandler(new ArgHandlerExtraDir(options));
-
- registerHandler(new ArgHandlerLink(options));
- registerHandler(new ArgHandlerOutputLibrary(options));
- registerHandler(new ArgHandlerLibraries(options));
-
- registerHandler(new ArgHandlerSaveSourceOutput(options));
- }
-
- @Override
- protected String getName() {
- return LibraryCompiler.class.getName();
- }
- }
-
- public static void main(String[] args) {
- Memory.initialize();
- SpeedTracerLogger.init();
- final CompilerOptions compilerOptions = new CompilerOptionsImpl();
- ArgProcessor argProcessor = new ArgProcessor(compilerOptions);
-
- if (argProcessor.processArgs(args)) {
- CompileTask compileTask = new CompileTask() {
- @Override
- public boolean run(TreeLogger logger) throws UnableToCompleteException {
- return new LibraryCompiler(compilerOptions).run(logger);
- }
- };
- boolean success = CompileTaskRunner.runWithAppropriateLogger(compilerOptions, compileTask);
- System.exit(success ? 0 : 1);
- }
- }
-
- private CompilerContext compilerContext;
- private final CompilerContext.Builder compilerContextBuilder = new CompilerContext.Builder();
- private final CompilerOptionsImpl compilerOptions;
- private ArtifactSet generatedArtifacts;
- private LibraryGroup libraryGroup;
- private ModuleDef module;
- private Permutation[] permutations;
- private ResourceLoader resourceLoader = ResourceLoaders.forClassLoader(Thread.currentThread());
- private Library resultLibrary;
-
- public LibraryCompiler(CompilerOptions compilerOptions) {
- this.compilerOptions = new CompilerOptionsImpl(compilerOptions);
- this.compilerContext =
- compilerContextBuilder.options(this.compilerOptions).compileMonolithic(false).build();
- CloseableJarHandlerFactory.installOverride();
- }
-
- ModuleDef getModule() {
- return module;
- }
-
- boolean run(TreeLogger logger) {
- try {
- normalizeOptions(logger);
- loadLibraries(logger);
- loadModule(logger);
- compileModule(logger);
- if (compilerOptions.shouldLink()) {
- linkLibraries(logger);
- }
- return true;
- } catch (UnableToCompleteException e) {
- // The real cause has been logged.
- return false;
- } finally {
- // Close all zip files, otherwise the JVM may crash on linux.
- compilerContext.getLibraryGroup().close();
- if (resultLibrary != null) {
- resultLibrary.close();
- }
- }
- }
-
- void setResourceLoader(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-
- private void compileModule(TreeLogger logger) throws UnableToCompleteException {
- long beforeCompileMs = System.currentTimeMillis();
- LibraryWriter libraryWriter = compilerContext.getLibraryWriter();
-
- try {
- if (compilerOptions.isValidateOnly()) {
- boolean valid = Precompile.validate(logger, compilerContext);
- if (!valid) {
- // The real cause has been logged.
- throw new UnableToCompleteException();
- }
- }
-
- Precompilation precompilation = Precompile.precompile(logger, compilerContext);
- if (precompilation == null) {
- // The real cause has been logged.
- throw new UnableToCompleteException();
- }
- // TODO(stalcup): move to precompile() after params are refactored
- if (!compilerOptions.shouldSaveSource()) {
- precompilation.removeSourceArtifacts(logger);
- }
-
- Event compilePermutationsEvent =
- SpeedTracerLogger.start(CompilerEventType.COMPILE_PERMUTATIONS);
- permutations = new Permutation[] {precompilation.getPermutations()[0]};
- List<PersistenceBackedObject<PermutationResult>> permutationResultFiles =
- new ArrayList<PersistenceBackedObject<PermutationResult>>();
- permutationResultFiles.add(libraryWriter.getPermutationResultHandle());
- CompilePerms.compile(logger, compilerContext, precompilation, permutations,
- compilerOptions.getLocalWorkers(), permutationResultFiles);
- compilePermutationsEvent.end();
-
- generatedArtifacts = precompilation.getGeneratedArtifacts();
- libraryWriter.addGeneratedArtifacts(generatedArtifacts);
- libraryWriter.setCompilationErrorsIndex(compilerContext.getLocalCompilationErrorsIndex());
- } finally {
- // Even if a compile problem occurs, close the library cleanly so that it can be examined.
- libraryWriter.write();
- }
-
- long durationMs = System.currentTimeMillis() - beforeCompileMs;
- TreeLogger detailBranch = logger.branch(TreeLogger.INFO,
- String.format("%.3fs -- Translating Java to Javascript", durationMs / 1000d));
-
- TinyCompileSummary tinyCompileSummary = compilerContext.getTinyCompileSummary();
- boolean shouldWarn =
- tinyCompileSummary.getTypesForGeneratorsCount() + tinyCompileSummary.getTypesForAstCount()
- > 1500;
- String recommendation = shouldWarn ? " This module should probably be split into smaller "
- + "modules or should trigger fewer generators since its current size hurts "
- + "incremental compiles." : "";
- detailBranch.log(shouldWarn ? TreeLogger.WARN : TreeLogger.INFO, String.format(
- "There were %s static source files, %s generated source files, %s types loaded for "
- + "generators and %s types loaded for AST construction. %s",
- tinyCompileSummary.getStaticSourceFilesCount(),
- tinyCompileSummary.getGeneratedSourceFilesCount(),
- tinyCompileSummary.getTypesForGeneratorsCount(), tinyCompileSummary.getTypesForAstCount(),
- recommendation));
- }
-
- private void linkLibraries(TreeLogger logger) throws UnableToCompleteException {
- long beforeLinkMs = System.currentTimeMillis();
- Event linkEvent = SpeedTracerLogger.start(CompilerEventType.LINK);
-
- // Load up the library that was just created so that it's possible to get a read-reference to
- // its contained PermutationResult.
- try {
- resultLibrary = new ZipLibrary(compilerOptions.getOutputLibraryPath());
- } catch (IncompatibleLibraryVersionException e) {
- logger.log(TreeLogger.ERROR, e.getMessage());
- throw new UnableToCompleteException();
- }
- generatedArtifacts.addAll(libraryGroup.getGeneratedArtifacts());
-
- Set<PermutationResult> libraryPermutationResults = Sets.newLinkedHashSet();
- List<PersistenceBackedObject<PermutationResult>> resultFiles = Lists.newArrayList();
- resultFiles.add(resultLibrary.getPermutationResultHandle());
- List<PersistenceBackedObject<PermutationResult>> permutationResultHandles =
- libraryGroup.getPermutationResultHandlesInLinkOrder();
- for (PersistenceBackedObject<PermutationResult> permutationResultHandle :
- permutationResultHandles) {
- libraryPermutationResults.add(permutationResultHandle.newInstance(logger));
- }
-
- try {
- Link.link(TreeLogger.NULL, module, compilerContext.getPublicResourceOracle(),
- generatedArtifacts, permutations, resultFiles, libraryPermutationResults, compilerOptions,
- compilerOptions);
- long durationMs = System.currentTimeMillis() - beforeLinkMs;
- logger.log(TreeLogger.INFO,
- String.format("%.3fs -- Successfully linking application", durationMs / 1000d));
- } catch (IOException e) {
- long durationMs = System.currentTimeMillis() - beforeLinkMs;
- logger.log(TreeLogger.INFO,
- String.format("%.3fs -- Failing to link application", durationMs / 1000d));
- throw new UnableToCompleteException();
- }
- linkEvent.end();
- }
-
- private void loadLibraries(TreeLogger logger) throws UnableToCompleteException {
- try {
- libraryGroup = LibraryGroup.fromZipPaths(compilerOptions.getLibraryPaths());
- } catch (IncompatibleLibraryVersionException e) {
- logger.log(TreeLogger.ERROR, e.getMessage());
- throw new UnableToCompleteException();
- }
- libraryGroup.verify(logger);
-
- try {
- CloseableJarHandlerFactory.closeStreams(compilerOptions.getOutputLibraryPath());
- } catch (IOException e) {
- logger.log(TreeLogger.WARN, String.format("Failed to close old connections to %s. "
- + "Repeated incremental compiles in the same JVM process may fail.",
- compilerOptions.getOutputLibraryPath()));
- }
-
- ZipLibraryWriter zipLibraryWriter =
- new ZipLibraryWriter(compilerOptions.getOutputLibraryPath());
- compilerContext = compilerContextBuilder.libraryGroup(libraryGroup).libraryWriter(
- zipLibraryWriter).unitCache(UnitCacheSingleton.get(logger, compilerOptions.getWorkDir()))
- .build();
- }
-
- private void loadModule(TreeLogger logger) throws UnableToCompleteException {
- long beforeLoadModuleMs = System.currentTimeMillis();
- module = ModuleDefLoader.loadFromResources(logger, compilerContext,
- compilerOptions.getModuleNames().get(0), resourceLoader, false);
- compilerContext = compilerContextBuilder.module(module).build();
- long durationMs = System.currentTimeMillis() - beforeLoadModuleMs;
- logger.log(TreeLogger.INFO,
- String.format("%.3fs -- Parsing and loading module definition", durationMs / 1000d));
- }
-
- private void normalizeOptions(TreeLogger logger) throws UnableToCompleteException {
- Preconditions.checkArgument(compilerOptions.getModuleNames().size() == 1);
-
- // Current optimization passes are not safe with only partial data.
- compilerOptions.setOptimizationLevel(OptionOptimize.OPTIMIZE_LEVEL_DRAFT);
- // Protects against rampant overlapping source inclusion.
- compilerOptions.setEnforceStrictSourceResources(true);
- // Ensures that output JS identifiers are named consistently in all modules.
- compilerOptions.setOutput(JsOutputOption.DETAILED);
- // Code splitting isn't possible when you can't trace the entire control flow.
- compilerOptions.setRunAsyncEnabled(false);
- compilerOptions.setClosureCompilerEnabled(false);
- if (compilerOptions.getWorkDir() == null) {
- try {
- compilerOptions.setWorkDir(Utility.makeTemporaryDirectory(null, "gwtc"));
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- Util.recursiveDelete(compilerOptions.getWorkDir(), false);
- }
- });
- } catch (IOException e) {
- logger.log(TreeLogger.ERROR, e.getMessage());
- throw new UnableToCompleteException();
- }
- }
- if ((compilerOptions.isSoycEnabled() || compilerOptions.isJsonSoycEnabled())
- && compilerOptions.getExtraDir() == null) {
- compilerOptions.setExtraDir(new File("extras"));
- }
- if (Strings.isNullOrEmpty(compilerOptions.getOutputLibraryPath())) {
- compilerOptions.setOutputLibraryPath(compilerOptions.getWorkDir().getPath() + "/"
- + compilerOptions.getModuleNames().get(0) + ".gwtlib");
- }
- // Optimize early since permutation compiles will run in process.
- compilerOptions.setOptimizePrecompile(true);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/Precompile.java b/dev/core/src/com/google/gwt/dev/Precompile.java
index 30d490a..bc06603 100644
--- a/dev/core/src/com/google/gwt/dev/Precompile.java
+++ b/dev/core/src/com/google/gwt/dev/Precompile.java
@@ -226,12 +226,8 @@
static Precompilation precompile(TreeLogger logger, CompilerContext compilerContext,
int permutationBase, PropertyPermutations allPermutations) {
- Precompilation precompile = precompile(logger, compilerContext, permutationBase,
+ return precompile(logger, compilerContext, permutationBase,
allPermutations, ManagementFactory.getRuntimeMXBean().getStartTime());
- if (compilerContext.getOptions().warnOverlappingSource()) {
- compilerContext.getModule().printOverlappingSourceWarnings(logger);
- }
- return precompile;
}
static Precompilation precompile(TreeLogger logger, CompilerContext compilerContext,
@@ -267,8 +263,7 @@
long moduleLoadFinished = System.currentTimeMillis();
String[] declEntryPts = module.getEntryPointTypeNames();
- boolean compileMonolithic = compilerContext.shouldCompileMonolithic();
- if (compileMonolithic && declEntryPts.length == 0) {
+ if (declEntryPts.length == 0) {
logger.log(TreeLogger.ERROR, "Module has no entry points defined", null);
throw new UnableToCompleteException();
}
@@ -301,32 +296,27 @@
List<Permutation> permutations =
new ArrayList<Permutation>(Arrays.asList(rpo.getPermutations()));
- // Monolithic compiles have multiple permutations but library compiles do not (since the
- // library output contains runtime rebind logic that will find implementations for any
- // supported browser).
- if (compileMonolithic) {
- mergeCollapsedPermutations(permutations);
+ mergeCollapsedPermutations(permutations);
- // Sort the permutations by an ordered key to ensure determinism.
- SortedMap<RebindAnswersPermutationKey, Permutation> merged =
- new TreeMap<RebindAnswersPermutationKey, Permutation>();
- SortedSet<String> liveRebindRequests = unifiedAst.getRebindRequests();
- for (Permutation permutation : permutations) {
- // Construct a key for the live rebind answers.
- RebindAnswersPermutationKey key =
- new RebindAnswersPermutationKey(permutation, liveRebindRequests);
- if (merged.containsKey(key)) {
- Permutation existing = merged.get(key);
- existing.mergeFrom(permutation, liveRebindRequests);
- } else {
- merged.put(key, permutation);
- }
+ // Sort the permutations by an ordered key to ensure determinism.
+ SortedMap<RebindAnswersPermutationKey, Permutation> merged =
+ new TreeMap<RebindAnswersPermutationKey, Permutation>();
+ SortedSet<String> liveRebindRequests = unifiedAst.getRebindRequests();
+ for (Permutation permutation : permutations) {
+ // Construct a key for the live rebind answers.
+ RebindAnswersPermutationKey key =
+ new RebindAnswersPermutationKey(permutation, liveRebindRequests);
+ if (merged.containsKey(key)) {
+ Permutation existing = merged.get(key);
+ existing.mergeFrom(permutation, liveRebindRequests);
+ } else {
+ merged.put(key, permutation);
}
-
- permutations.clear();
- permutations.addAll(merged.values());
}
+ permutations.clear();
+ permutations.addAll(merged.values());
+
if (jjsOptions.isCompilerMetricsEnabled()) {
int[] ids = new int[allPermutations.size()];
for (int i = 0; i < allPermutations.size(); i++) {
diff --git a/dev/core/src/com/google/gwt/dev/cfg/CombinedResourceOracle.java b/dev/core/src/com/google/gwt/dev/cfg/CombinedResourceOracle.java
deleted file mode 100644
index 5054e75..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/CombinedResourceOracle.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.resource.ResourceOracle;
-import com.google.gwt.dev.resource.impl.AbstractResourceOracle;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.io.Files;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Combines multiple resource oracles into a single queryable oracle.<br />
- *
- * Useful when the resource oracles being combined are very different in nature. For example one
- * that surfaces resources on disk and one that surfaces resources in a set of precompiled
- * libraries.
- */
-public class CombinedResourceOracle extends AbstractResourceOracle {
-
- private Set<Resource> buildResources;
- private Set<String> pathNames;
- private List<ResourceOracle> resourceOracles;
-
- public CombinedResourceOracle(ResourceOracle... resourceOracles) {
- this.resourceOracles = Arrays.asList(resourceOracles);
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException("A clear/refresh life cycle is not supported.");
- }
-
- @Override
- public Set<String> getPathNames() {
- if (pathNames == null) {
- pathNames = Sets.newHashSet();
- for (ResourceOracle resourceOracle : resourceOracles) {
- pathNames.addAll(resourceOracle.getPathNames());
- }
- pathNames = Collections.unmodifiableSet(pathNames);
- }
- return pathNames;
- }
-
- @Override
- public Set<Resource> getResources() {
- if (buildResources == null) {
- buildResources = Sets.newHashSet();
- for (ResourceOracle resourceOracle : resourceOracles) {
- buildResources.addAll(resourceOracle.getResources());
- }
- buildResources = Collections.unmodifiableSet(buildResources);
- }
- return buildResources;
- }
-
- @Override
- public Resource getResource(String pathName) {
- pathName = Files.simplifyPath(pathName);
- for (ResourceOracle resourceOracle : resourceOracles) {
- Resource resource = resourceOracle.getResource(pathName);
- if (resource != null) {
- return resource;
- }
- }
- return null;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperty.java b/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperty.java
index e01257a..6df1037 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperty.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperty.java
@@ -16,7 +16,6 @@
package com.google.gwt.dev.cfg;
import com.google.gwt.thirdparty.guava.common.base.Objects;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,7 +27,6 @@
*/
public class ConfigurationProperty extends Property {
private final boolean allowMultipleValues;
- private List<String> targetLibraryValues = new ArrayList<String>();
private List<String> values = new ArrayList<String>();
public ConfigurationProperty(String name) {
@@ -43,11 +41,6 @@
}
}
- public void addTargetLibraryValue(String value) {
- addValue(value);
- targetLibraryValues.add(value);
- }
-
public void addValue(String value) {
if (!allowMultipleValues) {
throw new IllegalStateException(
@@ -75,10 +68,6 @@
return false;
}
- public List<String> getTargetLibraryValues() {
- return ImmutableList.copyOf(targetLibraryValues);
- }
-
public String getValue() {
if (values.size() != 1) {
throw new IllegalStateException("size != 1");
@@ -95,23 +84,10 @@
return Objects.hashCode(name, allowMultipleValues, values);
}
- public boolean hasTargetLibraryValues() {
- return !targetLibraryValues.isEmpty();
- }
-
public boolean isMultiValued() {
return values.size() > 1;
}
- public void setTargetLibraryValue(String value) {
- if (targetLibraryValues.size() == 0) {
- targetLibraryValues.add(value);
- } else {
- targetLibraryValues.set(0, value);
- }
- setValue(value);
- }
-
public void setValue(String value) {
if (values.size() == 0) {
values.add(value);
diff --git a/dev/core/src/com/google/gwt/dev/cfg/DepsInfoProvider.java b/dev/core/src/com/google/gwt/dev/cfg/DepsInfoProvider.java
index 0802e18..c91c600 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/DepsInfoProvider.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/DepsInfoProvider.java
@@ -29,10 +29,4 @@
* Returns a set of the names of modules that source included the given type referenced by name.
*/
Set<String> getSourceModuleNames(String typeSourceName);
-
- /**
- * Returns a set of the names of modules in the transitive dependency tree for the given module
- * referenced by name.
- */
- Set<String> getTransitiveDepModuleNames(String targetModuleName);
}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ImmutableLibraryGroup.java b/dev/core/src/com/google/gwt/dev/cfg/ImmutableLibraryGroup.java
deleted file mode 100644
index 113105c..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/ImmutableLibraryGroup.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.cfg;
-
-import java.util.List;
-
-/**
- * An immutable library group.<br>
- *
- * Makes a good starter value for libraryGroup variables in that it allows read calling code without
- * having to check for a null but will force write calling code to be guarded a condition that
- * verifies that values even should be inserted.
- */
-public class ImmutableLibraryGroup extends LibraryGroup {
-
- @Override
- public LibraryGroup createSubgroup(List<String> libraryNames) {
- throw new UnsupportedOperationException("ImmutableLibraryGroup does not support modification.");
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/Libraries.java b/dev/core/src/com/google/gwt/dev/cfg/Libraries.java
deleted file mode 100644
index 7ab8582..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/Libraries.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.util.Name;
-
-/**
- * Utility functions and constants for reading and writing library files.
- */
-public class Libraries {
-
- /**
- * Indicates that an attempt to load a library failed because the version in the provided data did
- * not match the version required by current code.
- */
- public static class IncompatibleLibraryVersionException extends Exception {
-
- private int actualVersionNumber;
- private int requiredVersionNumber;
-
- public IncompatibleLibraryVersionException(int requiredVersionNumber, int actualVersionNumber) {
- this.requiredVersionNumber = requiredVersionNumber;
- this.actualVersionNumber = actualVersionNumber;
- }
-
- @Override
- public String getMessage() {
- return "An attempt to load a library failed because the version in the provided data ("
- + actualVersionNumber + ") did" + " not match the version required by current code ("
- + requiredVersionNumber + ".";
- }
- }
-
- public static final String BUILD_RESOURCE_PATHS_ENTRY_NAME = "buildResourcePaths.txt";
- public static final String COMPILATION_ERRORS_INDEX_ENTRY_NAME = "compilationErrorsIndex.ser";
- public static final String DEPENDENCY_LIBRARY_NAMES_ENTRY_NAME = "dependencyLibraryNames.txt";
- public static final String DIRECTORY_BUILD_RESOURCES = "buildResources/";
- public static final String DIRECTORY_BYTECODE = "bytecode/";
- public static final String DIRECTORY_COMPILATION_UNITS = "compilationUnits/";
- public static final String DIRECTORY_GENERATED_ARTIFACTS = "generatedArtifacts/";
- public static final String DIRECTORY_PUBLIC_RESOURCES = "publicResources/";
- public static final char ENCODE_PREFIX = '%';
- public static final String EXTENSION_CLASS_FILE = ".class";
- public static final String EXTENSION_COMPILATION_UNITS = ".compilationUnit";
- public static final String GENERATED_ARTIFACT_NAMES_ENTRY_NAME = "generatedArtifactNames.txt";
- public static final char KEY_VALUE_SEPARATOR = ':';
- public static final String LIBRARY_NAME_ENTRY_NAME = "libraryName.txt";
- public static final char LINE_SEPARATOR = '\n';
- public static final String NESTED_BINARY_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME =
- "nestedBinaryNamesByEnclosingName.txt";
- public static final String NESTED_SOURCE_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME =
- "nestedSourceNamesByEnclosingName.txt";
- public static final String PERMUTATION_RESULT_ENTRY_NAME = "permutationResult.ser";
- public static final String PROCESSED_REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME =
- "processedReboundTypeSourceNames.txt";
- public static final String PUBLIC_RESOURCE_PATHS_ENTRY_NAME = "publicResourcePaths.txt";
- public static final String REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME = "reboundTypeSourceNames.txt";
- public static final String REGULAR_CLASS_FILE_PATHS_ENTRY_NAME = "regularClassFilePaths.txt";
- public static final String REGULAR_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME =
- "regularCompilationUnitTypeSourceNames.txt";
- public static final String SUPER_SOURCE_CLASS_FILE_PATHS_ENTRY_NAME =
- "superSourceClassFilePaths.txt";
- public static final String SUPER_SOURCE_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME =
- "superSourceCompilationUnitTypeSourceNames.txt";
- public static final char VALUE_SEPARATOR = ',';
- public static final String VERSION_NUMBER_ENTRY_NAME = "versionNumber.txt";
-
- /**
- * Computes a consistent full path with extension at which to store a given class file path.
- */
- public static String computeClassFileEntryName(String classFilePath) {
- return DIRECTORY_BYTECODE + classFilePath + EXTENSION_CLASS_FILE;
- }
-
- /**
- * Adds class file extension to provided class file path in a consistent way.
- */
- public static String computeClassFileName(String classFilePath) {
- return classFilePath + EXTENSION_CLASS_FILE;
- }
-
- /**
- * Computes a consistent full path, escaped and with extension at which to store a given
- * compilation unit path.
- */
- public static String computeCompilationUnitEntryName(String compilationUnitTypeSourceName) {
- assert Name.isSourceName(compilationUnitTypeSourceName);
- return DIRECTORY_COMPILATION_UNITS + compilationUnitTypeSourceName.replace(".", "/")
- + EXTENSION_COMPILATION_UNITS;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/Library.java b/dev/core/src/com/google/gwt/dev/cfg/Library.java
deleted file mode 100644
index 4f4a991..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/Library.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.PersistenceBackedObject;
-import com.google.gwt.thirdparty.guava.common.collect.Multimap;
-
-import java.io.InputStream;
-import java.util.Set;
-
-/**
- * Encapsulates the data resulting from compilation of a single module, with the intention of
- * facilitating efficient separate compilation.<br />
- *
- * The contained data is a combination of raw output as well as indexes that represent compiler
- * state which would be expensive to recalculate.<br />
- *
- * Implementers are encouraged to load their contents lazily to minimize work.
- */
-// TODO(stalcup): refactor UnifyAst to only perform binary name based lookups so that libraries
-// don't need to index compilation units by both source and binary name
-public interface Library {
-
- /**
- * Closes all read streams.
- */
- void close();
-
- /**
- * Returns a resource handle or null for the provided path.
- */
- Resource getBuildResourceByPath(String buildResourcePath);
-
- /**
- * Returns the set of paths of build resources. Facilitates LibraryGroup's fast single resource
- * retrieval across large groups of provided libraries.
- */
- Set<String> getBuildResourcePaths();
-
- /**
- * Returns a class file input stream or null for the provided path.
- */
- InputStream getClassFileStream(String classFilePath);
-
- /**
- * Returns the compilation unit containing the type with the given binary name. The returned
- * compilation unit might be regular or might be super sourced depending on which was stored
- * during library construction.
- */
- CompilationUnit getCompilationUnitByTypeBinaryName(String typeBinaryName);
-
- /**
- * Returns the compilation unit containing the type with the given source name. The returned
- * compilation unit might be regular or might be super sourced depending on which was stored
- * during library construction.
- */
- CompilationUnit getCompilationUnitByTypeSourceName(String typeSourceName);
-
- /**
- * Returns the set of names of dependency libraries. Facilitates LibraryGroup's library tree
- * analysis for link ordering and partial generator execution.
- */
- Set<String> getDependencyLibraryNames();
-
- /**
- * Returns the set of artifacts that were created by generators when compiling this library.
- */
- ArtifactSet getGeneratedArtifacts();
-
- /**
- * Returns the name of the library. Should be unique within the library dependency tree.
- */
- String getLibraryName();
-
- /**
- * Returns a mapping from compilation unit type source name to a list of nested type binary names.
- */
- Multimap<String, String> getNestedBinaryNamesByCompilationUnitName();
-
- /**
- * Returns a mapping from compilation unit type source name to a list of nested type source names.
- */
- Multimap<String, String> getNestedSourceNamesByCompilationUnitName();
-
- /**
- * Returns a handle to the serialized permutation result of this library. Final linking relies on
- * the permutation result contents.
- */
- // TODO(stalcup): refactor PersistenceBackedObject name to PersistedObjectHandle or remove it
- // completely
- PersistenceBackedObject<PermutationResult> getPermutationResultHandle();
-
- /**
- * Returns a mapping from generator name to the set of source names of types that have been
- * processed by that generator in this library.
- */
- Multimap<String, String> getProcessedReboundTypeSourceNamesByGenerator();
-
- /**
- * Returns a source of compilation error information to support detailed logging.
- */
- CompilationErrorsIndexImpl getCompilationErrorsIndex();
-
- /**
- * Returns a resource handle or null for the provided path.
- */
- Resource getPublicResourceByPath(String path);
-
- /**
- * Returns the set of paths of public resources. Facilitates LibraryGroup's fast single resource
- * retrieval across large groups of provided libraries.
- */
- Set<String> getPublicResourcePaths();
-
- /**
- * Returns the set of source names of types which are the subject of GWT.create() calls in source
- * code for this library. This list of types is needed for generator execution and reconstructing
- * this list from source would be very costly.
- */
- Set<String> getReboundTypeSourceNames();
-
- /**
- * Returns the set of regular (non-super-source) class file paths. Facilitates LibraryGroup's fast
- * single class file retrieval across large groups of provided libraries.
- */
- Set<String> getRegularClassFilePaths();
-
- /**
- * Returns the set of regular (non-super-source) compilation unit type source names. Facilitates
- * LibraryGroup's fast single compilation unit retrieval across large groups of provided
- * libraries.
- */
- Set<String> getRegularCompilationUnitTypeSourceNames();
-
- /**
- * Returns the set of super source class file paths. Facilitates LibraryGroup's fast single class
- * file retrieval across large groups of provided libraries and makes possible the prioritization
- * of super source over regular class files.
- */
- Set<String> getSuperSourceClassFilePaths();
-
- /**
- * Returns the set of super source compilation unit type source names. Facilitates LibraryGroup's
- * fast compilation unit retrieval across large groups of provided libraries and makes possible
- * the prioritization of super source over regular compilation units.
- */
- Set<String> getSuperSourceCompilationUnitTypeSourceNames();
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroup.java b/dev/core/src/com/google/gwt/dev/cfg/LibraryGroup.java
deleted file mode 100644
index 04ab5d2..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroup.java
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.cfg.Libraries.IncompatibleLibraryVersionException;
-import com.google.gwt.dev.javac.CompilationErrorsIndex;
-import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.InternalCompilerException;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.PersistenceBackedObject;
-import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.base.Predicates;
-import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Multimap;
-import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A convenience wrapper around a set of libraries.<br />
- *
- * Indexes library contents to enable single step retrieval of resources by name.<br />
- *
- * Analyzes the library dependency tree to provide link ordering and property and rebound type
- * change analysis for partial generator execution.<br />
- *
- * Combines library resource lists for easy iteration over the complete set.<br />
- *
- * Is mostly immutable, its contained set of libraries can only be set at time of construction.
- */
-public class LibraryGroup {
-
- /**
- * An exception that indicates that a single Compilation Unit is being provided by more than one
- * library.
- */
- public static class CollidingCompilationUnitException extends InternalCompilerException {
-
- public CollidingCompilationUnitException(String message) {
- super(message);
- }
- }
-
- /**
- * An exception that indicates that more than one library has the same name, thus making name
- * based references ambiguous.
- */
- public static class DuplicateLibraryNameException extends InternalCompilerException {
-
- public DuplicateLibraryNameException(String message) {
- super(message);
- }
- }
-
- /**
- * An exception that indicates that some library was referenced as a dependency but was not
- * provided to the compiler.
- */
- public static class UnresolvedLibraryException extends InternalCompilerException {
-
- public UnresolvedLibraryException(String message) {
- super(message);
- }
- }
-
- private static final Comparator<Library> LIBRARY_NAME_COMPARATOR = new Comparator<Library>() {
- @Override
- public int compare(Library thisLibrary, Library thatLibrary) {
- return thisLibrary.getLibraryName().compareTo(thatLibrary.getLibraryName());
- }
- };
-
- @VisibleForTesting
- public static String formatDuplicateCompilationUnitMessage(String compilationUnitTypeSourceName,
- String oldLibraryName, String newLibraryName) {
- return String.format("Compilation units must be unique but '%s' is being "
- + "provided by both the '%s' and '%s' library.", compilationUnitTypeSourceName,
- oldLibraryName, newLibraryName);
- }
-
- /**
- * Factory function that constructs and returns a library group from a list of libraries.
- */
- public static LibraryGroup fromLibraries(
- List<? extends Library> libraries, boolean verifyLibraryReferences) {
- LibraryGroup libraryGroup = new LibraryGroup();
- for (Library library : libraries) {
- libraryGroup.libraries.add(library);
- }
- libraryGroup.buildLibraryIndexes(verifyLibraryReferences);
- return libraryGroup;
- }
- /**
- * Factory function that constructs and returns a library group from a list of zip library paths.
- */
- public static LibraryGroup fromZipPaths(List<String> zipLibraryPaths)
- throws IncompatibleLibraryVersionException {
- List<Library> zipLibraries = Lists.newArrayList();
- for (String zipLibraryPath : zipLibraryPaths) {
- zipLibraries.add(new ZipLibrary(zipLibraryPath));
- }
- return fromLibraries(zipLibraries, true);
- }
-
- private SetMultimap<String, String> compilationErrorsByTypeSourceName;
- private CompilationErrorsIndexImpl compilationErrorsIndex;
- private Set<String> compilationUnitTypeSourceNames;
- private ArtifactSet generatedArtifacts;
- private List<Library> libraries = Lists.newArrayList();
- private Map<String, Library> librariesByBuildResourcePath;
- private Map<String, Library> librariesByClassFilePath;
- private Map<String, Library> librariesByCompilationUnitTypeBinaryName;
- private Map<String, Library> librariesByCompilationUnitTypeSourceName;
- private Map<String, Library> librariesByName;
- private Map<String, Library> librariesByPublicResourcePath;
- private List<PersistenceBackedObject<PermutationResult>> permutationResultHandles;
- private SetMultimap<String, String> processedReboundTypeSourceNamesByGenerator =
- HashMultimap.create();
- private Set<String> reboundTypeSourceNames;
- private SetMultimap<String, String> referencesByTypeSourceName;
- private List<Library> rootLibraries;
- private Set<String> superSourceCompilationUnitTypeSourceNames;
-
- protected LibraryGroup() {
- // Private to force class construction via one of the public factory functions.
- }
-
- /**
- * Closes all read streams.
- */
- public void close() {
- for (Library library : libraries) {
- library.close();
- }
- }
-
- /**
- * Returns whether a build resource is is available at the given path.
- */
- public boolean containsBuildResource(String buildResourcePath) {
- return getLibrariesByBuildResourcePath().containsKey(buildResourcePath);
- }
-
- /**
- * Create and return a library group of just the given libraries referenced by name. Useful for
- * taking an overly broad library group of all libraries in a dependency tree and trimming it down
- * to a restricted set of strict top level dependencies.
- */
- public LibraryGroup createSubgroup(List<String> libraryNames) {
- return fromLibraries(getLibraries(libraryNames), false);
- }
-
- /**
- * Returns the resource referenced by name if present or null;
- */
- public Resource getBuildResourceByPath(String buildResourcePath) {
- if (!getLibrariesByBuildResourcePath().containsKey(buildResourcePath)) {
- return null;
- }
- Library library = getLibrariesByBuildResourcePath().get(buildResourcePath);
- return library.getBuildResourceByPath(buildResourcePath);
- }
-
- /**
- * Returns the set of all build resource paths.
- */
- public Set<String> getBuildResourcePaths() {
- return getLibrariesByBuildResourcePath().keySet();
- }
-
- /**
- * Opens and returns an input stream for the given class file path if present or null.
- */
- public InputStream getClassFileStream(String classFilePath) {
- if (!getLibrariesByClassFilePath().containsKey(Libraries.computeClassFileName(classFilePath))) {
- return null;
- }
- Library library =
- getLibrariesByClassFilePath().get(Libraries.computeClassFileName(classFilePath));
- return library.getClassFileStream(classFilePath);
- }
-
- public CompilationErrorsIndex getCompilationErrorsIndex() {
- if (compilationErrorsIndex == null) {
- compilationErrorsIndex = new CompilationErrorsIndexImpl();
- for (Library library : libraries) {
- compilationErrorsIndex.merge(library.getCompilationErrorsIndex());
- }
- }
- return compilationErrorsIndex;
- }
-
- /**
- * Returns the compilation unit for the given compilation unit type name if present or null.
- */
- public CompilationUnit getCompilationUnitByTypeBinaryName(String typeBinaryName) {
- if (!getLibrariesByCompilationUnitTypeBinaryName().containsKey(typeBinaryName)) {
- return null;
- }
- Library library = getLibrariesByCompilationUnitTypeBinaryName().get(typeBinaryName);
- return library.getCompilationUnitByTypeBinaryName(typeBinaryName);
- }
-
- /**
- * Returns the compilation unit for the given compilation unit type name if present or null.
- */
- public CompilationUnit getCompilationUnitByTypeSourceName(String typeSourceName) {
- if (!getLibrariesByCompilationUnitTypeSourceName().containsKey(typeSourceName)) {
- return null;
- }
- Library library = getLibrariesByCompilationUnitTypeSourceName().get(typeSourceName);
- return library.getCompilationUnitByTypeSourceName(typeSourceName);
- }
-
- /**
- * Returns the set of all compilation unit type source names (both regular and super sourced).
- * Useful to be able to force loading of all known types to make subtype queries accurate for
- * example when doing global generator execution.
- */
- public Set<String> getCompilationUnitTypeSourceNames() {
- if (compilationUnitTypeSourceNames == null) {
- compilationUnitTypeSourceNames = Sets.newLinkedHashSet();
- for (Library library : libraries) {
- compilationUnitTypeSourceNames.addAll(library.getRegularCompilationUnitTypeSourceNames());
- compilationUnitTypeSourceNames.addAll(
- library.getSuperSourceCompilationUnitTypeSourceNames());
- }
- compilationUnitTypeSourceNames = Collections.unmodifiableSet(compilationUnitTypeSourceNames);
- }
- return compilationUnitTypeSourceNames;
- }
-
- public ArtifactSet getGeneratedArtifacts() {
- if (generatedArtifacts == null) {
- generatedArtifacts = new ArtifactSet();
- for (Library library : libraries) {
- generatedArtifacts.addAll(library.getGeneratedArtifacts());
- }
- }
- return generatedArtifacts;
- }
-
- /**
- * Returns the list of all permutation result handles (one per library) in library link order.
- */
- public List<PersistenceBackedObject<PermutationResult>> getPermutationResultHandlesInLinkOrder() {
- if (permutationResultHandles == null) {
- permutationResultHandles = Lists.newArrayList();
- for (Library library : libraries) {
- permutationResultHandles.add(library.getPermutationResultHandle());
- }
- permutationResultHandles = Collections.unmodifiableList(permutationResultHandles);
- }
- return permutationResultHandles;
- }
-
- /**
- * Returns a list of source names of types which have already been rebound by the given generator.
- */
- public Set<String> getProcessedReboundTypeSourceNames(String generatorName) {
- if (!processedReboundTypeSourceNamesByGenerator.containsKey(generatorName)) {
- Set<String> processedReboundTypeSourceNames = Sets.newHashSet();
- for (Library library : libraries) {
- processedReboundTypeSourceNames.addAll(
- library.getProcessedReboundTypeSourceNamesByGenerator().get(generatorName));
- }
- processedReboundTypeSourceNamesByGenerator.putAll(generatorName,
- Collections.unmodifiableSet(processedReboundTypeSourceNames));
- }
- return processedReboundTypeSourceNamesByGenerator.get(generatorName);
- }
-
- /**
- * Returns the resource referenced by name if present or null.
- */
- public Resource getPublicResourceByPath(String path) {
- if (!getLibrariesByPublicResourcePath().containsKey(path)) {
- return null;
- }
- Library library = getLibrariesByPublicResourcePath().get(path);
- return library.getPublicResourceByPath(path);
- }
-
- /**
- * Returns the set of all public resource paths.
- */
- public Set<String> getPublicResourcePaths() {
- return getLibrariesByPublicResourcePath().keySet();
- }
-
- /**
- * Returns the set of names of types which are the subject of GWT.create() calls in source code in
- * any of the contained libraries.
- */
- public Set<String> getReboundTypeSourceNames() {
- if (reboundTypeSourceNames == null) {
- reboundTypeSourceNames = Sets.newLinkedHashSet();
- for (Library library : libraries) {
- reboundTypeSourceNames.addAll(library.getReboundTypeSourceNames());
- }
- reboundTypeSourceNames =
- Collections.unmodifiableSet(reboundTypeSourceNames);
- }
- return reboundTypeSourceNames;
- }
-
- /**
- * Returns the set of compilation unit type source names for all contained super source
- * compilation units.
- */
- public Set<String> getSuperSourceCompilationUnitTypeSourceNames() {
- if (superSourceCompilationUnitTypeSourceNames == null) {
- superSourceCompilationUnitTypeSourceNames = Sets.newLinkedHashSet();
- for (Library library : libraries) {
- superSourceCompilationUnitTypeSourceNames.addAll(
- library.getSuperSourceCompilationUnitTypeSourceNames());
- }
- superSourceCompilationUnitTypeSourceNames =
- Collections.unmodifiableSet(superSourceCompilationUnitTypeSourceNames);
- }
- return superSourceCompilationUnitTypeSourceNames;
- }
-
- public void verify(TreeLogger logger) throws UnableToCompleteException {
- try {
- // Forces the building of the mapping from source names of compilation unit types to the
- // library that provides them, so that there is an opportunity to notice and reject duplicate
- // providing libraries.
- getLibrariesByCompilationUnitTypeSourceName();
- } catch (CollidingCompilationUnitException e) {
- logger.log(TreeLogger.ERROR, e.getMessage());
- throw new UnableToCompleteException();
- }
- }
-
- @VisibleForTesting
- List<Library> getLibraries() {
- return libraries;
- }
-
- @VisibleForTesting
- List<Library> getLibraries(Collection<String> libraryNames) {
- return Lists.newArrayList(
- Maps.filterKeys(librariesByName, Predicates.in(libraryNames)).values());
- }
-
- /**
- * Throws an exception if the referenced compilation unit (which is being provided by the
- * referenced new library) is already being provided by some older library.
- */
- private void assertUniquelyProvided(Library newLibrary, String compilationUnitTypeSourceName) {
- if (librariesByCompilationUnitTypeSourceName.containsKey(compilationUnitTypeSourceName)) {
- Library oldLibrary =
- librariesByCompilationUnitTypeSourceName.get(compilationUnitTypeSourceName);
- throw new CollidingCompilationUnitException(formatDuplicateCompilationUnitMessage(
- compilationUnitTypeSourceName, oldLibrary.getLibraryName(), newLibrary.getLibraryName()));
- }
- }
-
- private void buildLibraryIndexes(boolean verifyLibraryReferences) {
- // Start processing with a consistent library order to ensure consistently ordered output.
- Collections.sort(libraries, LIBRARY_NAME_COMPARATOR);
-
- librariesByName = Maps.newLinkedHashMap();
- for (Library library : libraries) {
- if (librariesByName.containsKey(library.getLibraryName())) {
- throw new DuplicateLibraryNameException("More than one library is claiming the name \""
- + library.getLibraryName() + "\", thus making library references ambiguous. "
- + "Compilation can not proceed.");
- }
- librariesByName.put(library.getLibraryName(), library);
- }
-
- Multimap<Library, Library> parentLibrariesByChildLibrary = LinkedHashMultimap.create();
- Multimap<Library, Library> childLibrariesByParentLibrary = LinkedHashMultimap.create();
- for (Library parentLibrary : libraries) {
- for (String childLibraryName : parentLibrary.getDependencyLibraryNames()) {
- Library childLibrary = librariesByName.get(childLibraryName);
- boolean libraryIsMissing = childLibrary == null;
- if (libraryIsMissing && verifyLibraryReferences) {
- throw new UnresolvedLibraryException("Library " + parentLibrary.getLibraryName()
- + " references library " + childLibraryName + " but it is not available.");
- }
- parentLibrariesByChildLibrary.put(childLibrary, parentLibrary);
- childLibrariesByParentLibrary.put(parentLibrary, childLibrary);
- }
- }
-
- rootLibraries = Lists.newArrayList();
- for (Library library : libraries) {
- boolean libraryHasParents = parentLibrariesByChildLibrary.containsKey(library);
- if (libraryHasParents) {
- continue;
- }
- rootLibraries.add(library);
- }
-
- List<Library> librariesInLinkOrder = Lists.newArrayList();
- Set<Library> maybeLeafLibraries = Sets.newLinkedHashSet(libraries);
- while (!maybeLeafLibraries.isEmpty()) {
- List<Library> leafLibraries = Lists.newArrayList();
- for (Library maybeLeafLibrary : maybeLeafLibraries) {
- if (childLibrariesByParentLibrary.get(maybeLeafLibrary).isEmpty()) {
- leafLibraries.add(maybeLeafLibrary);
- }
- }
- librariesInLinkOrder.addAll(leafLibraries);
-
- maybeLeafLibraries.clear();
- for (Library leafLibrary : leafLibraries) {
- Collection<Library> parentLibraries = parentLibrariesByChildLibrary.removeAll(leafLibrary);
- maybeLeafLibraries.addAll(parentLibraries);
- for (Library parentLibrary : parentLibraries) {
- childLibrariesByParentLibrary.remove(parentLibrary, leafLibrary);
- }
- }
- }
-
- libraries = librariesInLinkOrder;
- }
-
- private Map<String, Library> getLibrariesByBuildResourcePath() {
- if (librariesByBuildResourcePath == null) {
- librariesByBuildResourcePath = Maps.newLinkedHashMap();
- for (Library library : libraries) {
- Set<String> buildResourcePaths = library.getBuildResourcePaths();
- for (String buildResourcePath : buildResourcePaths) {
- librariesByBuildResourcePath.put(buildResourcePath, library);
- }
- }
- librariesByBuildResourcePath = Collections.unmodifiableMap(librariesByBuildResourcePath);
- }
- return librariesByBuildResourcePath;
- }
-
- // TODO(stalcup): throw an error if more than one version of a type is provided.
- private Map<String, Library> getLibrariesByClassFilePath() {
- if (librariesByClassFilePath == null) {
- librariesByClassFilePath = Maps.newLinkedHashMap();
-
- // Record regular class files first.
- for (Library library : libraries) {
- Set<String> classFilePaths = library.getRegularClassFilePaths();
- for (String classFilePath : classFilePaths) {
- librariesByClassFilePath.put(classFilePath, library);
- }
- }
-
- // Overwrite with superSource class files, so they have higher priority.
- for (Library library : libraries) {
- Set<String> superSourceClassFilePaths = library.getSuperSourceClassFilePaths();
- for (String superSourceClassFilePath : superSourceClassFilePaths) {
- librariesByClassFilePath.put(superSourceClassFilePath, library);
- }
- }
-
- librariesByClassFilePath = Collections.unmodifiableMap(librariesByClassFilePath);
- }
- return librariesByClassFilePath;
- }
-
- // TODO(stalcup): throw an error if more than one version of a type is provided.
- private Map<String, Library> getLibrariesByCompilationUnitTypeBinaryName() {
- if (librariesByCompilationUnitTypeBinaryName == null) {
- librariesByCompilationUnitTypeBinaryName = Maps.newLinkedHashMap();
-
- // Record regular compilation units first.
- for (Library library : libraries) {
- for (String compilationUnitTypeSourceName :
- library.getRegularCompilationUnitTypeSourceNames()) {
- librariesByCompilationUnitTypeSourceName.put(compilationUnitTypeSourceName, library);
-
- Collection<String> nestedTypeBinaryNames = library
- .getNestedBinaryNamesByCompilationUnitName().get(compilationUnitTypeSourceName);
- for (String nestedTypeBinaryName : nestedTypeBinaryNames) {
- librariesByCompilationUnitTypeBinaryName.put(nestedTypeBinaryName, library);
- }
- }
- }
-
- // Overwrite with superSource compilation units, so they have higher priority.
- for (Library library : libraries) {
- for (String superSourceCompilationUnitTypeSourceName :
- library.getSuperSourceCompilationUnitTypeSourceNames()) {
- librariesByCompilationUnitTypeSourceName.put(superSourceCompilationUnitTypeSourceName,
- library);
-
- Collection<String> nestedTypeBinaryNames = library
- .getNestedBinaryNamesByCompilationUnitName().get(
- superSourceCompilationUnitTypeSourceName);
- for (String nestedTypeBinaryName : nestedTypeBinaryNames) {
- librariesByCompilationUnitTypeBinaryName.put(nestedTypeBinaryName, library);
- }
- }
- }
- }
- return Collections.unmodifiableMap(librariesByCompilationUnitTypeBinaryName);
- }
-
- private Map<String, Library> getLibrariesByCompilationUnitTypeSourceName() {
- if (librariesByCompilationUnitTypeSourceName == null) {
- librariesByCompilationUnitTypeSourceName = Maps.newLinkedHashMap();
-
- // Record regular compilation units first.
- for (Library library : libraries) {
- for (String compilationUnitTypeSourceName :
- library.getRegularCompilationUnitTypeSourceNames()) {
- assertUniquelyProvided(library, compilationUnitTypeSourceName);
- librariesByCompilationUnitTypeSourceName.put(compilationUnitTypeSourceName, library);
-
- Collection<String> nestedTypeSourceNames = library
- .getNestedSourceNamesByCompilationUnitName().get(compilationUnitTypeSourceName);
- for (String nestedTypeSourceName : nestedTypeSourceNames) {
- librariesByCompilationUnitTypeSourceName.put(nestedTypeSourceName, library);
- }
- }
- }
-
- // Overwrite with superSource compilation units, so they have higher priority.
- for (Library library : libraries) {
- for (String superSourceCompilationUnitTypeSourceName :
- library.getSuperSourceCompilationUnitTypeSourceNames()) {
- assertUniquelyProvided(library, superSourceCompilationUnitTypeSourceName);
- librariesByCompilationUnitTypeSourceName.put(superSourceCompilationUnitTypeSourceName,
- library);
-
- Collection<String> nestedTypeSourceNames = library
- .getNestedSourceNamesByCompilationUnitName().get(
- superSourceCompilationUnitTypeSourceName);
- for (String nestedTypeSourceName : nestedTypeSourceNames) {
- librariesByCompilationUnitTypeSourceName.put(nestedTypeSourceName, library);
- }
- }
- }
- }
- return Collections.unmodifiableMap(librariesByCompilationUnitTypeSourceName);
- }
-
- private Map<String, Library> getLibrariesByPublicResourcePath() {
- if (librariesByPublicResourcePath == null) {
- librariesByPublicResourcePath = Maps.newLinkedHashMap();
- for (Library library : libraries) {
- Set<String> publicResourcePaths = library.getPublicResourcePaths();
- for (String publicResourcePath : publicResourcePaths) {
- librariesByPublicResourcePath.put(publicResourcePath, library);
- }
- }
-
- librariesByPublicResourcePath = Collections.unmodifiableMap(librariesByPublicResourcePath);
- }
- return librariesByPublicResourcePath;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracle.java b/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracle.java
deleted file mode 100644
index 202232a..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracle.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.resource.impl.AbstractResourceOracle;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.io.Files;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * A {@code ResourceOracle} for finding build resources in a library group.
- */
-public class LibraryGroupBuildResourceOracle extends AbstractResourceOracle {
-
- private Set<Resource> buildResources;
- private final LibraryGroup libraryGroup;
- private Set<String> pathNames;
-
- public LibraryGroupBuildResourceOracle(LibraryGroup libraryGroup) {
- this.libraryGroup = libraryGroup;
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException("A clear/refresh life cycle is not supported.");
- }
-
- @Override
- public Set<String> getPathNames() {
- if (pathNames == null) {
- pathNames = ImmutableSet.<String> copyOf(libraryGroup.getBuildResourcePaths());
- }
- return pathNames;
- }
-
- @Override
- public Resource getResource(String pathName) {
- pathName = Files.simplifyPath(pathName);
- return libraryGroup.getBuildResourceByPath(pathName);
- }
-
- @Override
- public Set<Resource> getResources() {
- if (buildResources == null) {
- Set<String> paths = getPathNames();
- buildResources = Sets.newHashSet();
- for (String path : paths) {
- buildResources.add(libraryGroup.getBuildResourceByPath(path));
- }
- buildResources = Collections.unmodifiableSet(buildResources);
- }
- return buildResources;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupPublicResourceOracle.java b/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupPublicResourceOracle.java
deleted file mode 100644
index 67e19f4..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/LibraryGroupPublicResourceOracle.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.resource.impl.AbstractResourceOracle;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.io.Files;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * A {@code ResourceOracle} for finding public resources in a library group.
- */
-public class LibraryGroupPublicResourceOracle extends AbstractResourceOracle {
-
- private final LibraryGroup libraryGroup;
- private Set<String> pathNames;
- private Set<Resource> publicResources;
-
- public LibraryGroupPublicResourceOracle(LibraryGroup libraryGroup) {
- this.libraryGroup = libraryGroup;
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException("A clear/refresh life cycle is not supported.");
- }
-
- @Override
- public Set<String> getPathNames() {
- if (pathNames == null) {
- pathNames = ImmutableSet.<String> copyOf(libraryGroup.getPublicResourcePaths());
- }
- return pathNames;
- }
-
- @Override
- public Resource getResource(String pathName) {
- pathName = Files.simplifyPath(pathName);
- return libraryGroup.getPublicResourceByPath(pathName);
- }
-
- @Override
- public Set<Resource> getResources() {
- if (publicResources == null) {
- Set<String> paths = getPathNames();
- publicResources = Sets.newHashSet();
- for (String path : paths) {
- publicResources.add(libraryGroup.getPublicResourceByPath(path));
- }
- publicResources = Collections.unmodifiableSet(publicResources);
- }
- return publicResources;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/LibraryWriter.java b/dev/core/src/com/google/gwt/dev/cfg/LibraryWriter.java
deleted file mode 100644
index dec2e1d..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/LibraryWriter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.javac.CompilationErrorsIndex;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.PersistenceBackedObject;
-
-import java.util.Set;
-
-/**
- * A builder which collects and writes the contents of a library.<br />
- *
- * It also provides access to a very small subset of properties for LibraryGroup access.
- */
-public interface LibraryWriter {
-
- /**
- * Adds a build resource. Build resources are any resources provided in source paths but which are
- * not themselves source code. For example *.gwt.xml and *.ui.xml files.
- */
- void addBuildResource(Resource buildResource);
-
- /**
- * Adds a previously compiled (but not yet unified) compilation unit.<br />
- *
- * Provided compilation units are assumed to have already been validated.
- */
- void addCompilationUnit(CompilationUnit compilationUnit);
-
- /**
- * Registers dependency on a set of other libraries.
- */
- void addDependencyLibraryNames(Set<String> dependencyLibraryNames);
-
- /**
- * Adds a generated artifact. Artifacts created by generators need to be collected so that they
- * can be provided to the final linker.
- */
- void addGeneratedArtifacts(ArtifactSet generatedArtifacts);
-
- /**
- * Adds a public resource (such as a html, css, or png file).
- */
- void addPublicResource(Resource publicResource);
-
- /**
- * Returns a handle to the permutation result object that was constructed as part of the
- * compilation for this library.
- */
- PersistenceBackedObject<PermutationResult> getPermutationResultHandle();
-
- /**
- * Returns the set of source names of rebound types that have been processed by the given
- * Generator.
- */
- Set<String> getProcessedReboundTypeSourceNames(String generatorName);
-
- /**
- * Returns the set of source names of types which are the subject of GWT.create() calls in source
- * code for this library.
- */
- Set<String> getReboundTypeSourceNames();
-
- /**
- * Registers the type (by it's source name) as having been processed by the given generator.
- */
- void markReboundTypeProcessed(String processedReboundTypeSourceName, String generatorName);
-
- /**
- * Records the set of names of types which are the subject of GWT.create() calls in source code
- * for this library.
- */
- void markReboundTypesProcessed(Set<String> reboundTypeSourceNames);
-
- /**
- * Records a source of compilation error information to support detailed logging.
- */
- void setCompilationErrorsIndex(CompilationErrorsIndex compilationErrorsIndex);
-
- /**
- * Records the library name.<br />
- *
- * Library names are the way that libraries reference one another as dependencies and should be
- * unique within the build tree.
- */
- void setLibraryName(String libraryName);
-
- /**
- * Finishes writing all library contents and closes the library.
- */
- void write();
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java b/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
index 8b864d1..0418c03 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
@@ -37,19 +37,12 @@
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
-import com.google.gwt.dev.util.transitiveclosure.TransitiveClosureSolver;
import com.google.gwt.thirdparty.guava.common.base.Charsets;
-import com.google.gwt.thirdparty.guava.common.base.Objects;
-import com.google.gwt.thirdparty.guava.common.base.Preconditions;
import com.google.gwt.thirdparty.guava.common.base.Predicates;
-import com.google.gwt.thirdparty.guava.common.collect.ArrayListMultimap;
import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
import com.google.gwt.thirdparty.guava.common.collect.Iterators;
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.ListMultimap;
import com.google.gwt.thirdparty.guava.common.collect.Lists;
import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Queues;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import java.io.File;
@@ -57,7 +50,6 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
@@ -65,11 +57,9 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Queue;
import java.util.Set;
/**
@@ -77,75 +67,6 @@
* XML for unit tests.
*/
public class ModuleDef implements DepsInfoProvider {
- /**
- * Marks a module in a way that can be used to calculate the effective bounds of a library module
- * in a module tree.
- */
- public enum ModuleType {
- /**
- * A module that acts as just a bundle of source code to be included in a referencing library.
- * The contained code may form circular references with other source within the contiguous chunk
- * of modules made up of a library and it's subtree of filesets. As a result a fileset can not
- * be compiled on it's own and must be compiled as part of a library.
- */
- FILESET,
- /**
- * The default type of module. Libraries should be independently compilable and are expected to
- * explicitly declare all of their immediate dependencies and include paths and none of their
- * contained source should be part of a circular reference with any source outside the effective
- * bounds of the library.
- */
- LIBRARY
- }
-
- /**
- * When walking a module tree of mixed library and fileset modules, attributes are accumulated and
- * stored. But when compiling separately, some attributes should only be collected from the
- * effective target module. AttributeSource is used to classify these "in target module" and "out
- * of target module" times.
- */
- private enum AttributeSource {
- EXTERNAL_LIBRARY, TARGET_LIBRARY
- }
-
- /**
- * Encapsulates two String names which conceptually represent the starting and ending points of a
- * path.
- * <p>
- * For example in the following module dependency path ["com.acme.MyApp",
- * "com.acme.widgets.Widgets", "com.google.gwt.user.User"] the fromName is "com.acme.MyApp" and
- * the toName is "com.google.gwt.user.User" and together they form a PathEndNames instance.
- * <p>
- * The purpose of the class is to serve as a key by which to lookup the fileset path that connects
- * two libraries. It makes it possible to insert fileset entries into a circular module reference
- * report.
- */
- private static class LibraryDependencyEdge {
-
- private String fromName;
- private String toName;
-
- public LibraryDependencyEdge(String fromName, String toName) {
- this.fromName = fromName;
- this.toName = toName;
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof LibraryDependencyEdge) {
- LibraryDependencyEdge that = (LibraryDependencyEdge) object;
- return Objects.equal(this.fromName, that.fromName)
- && Objects.equal(this.toName, that.toName);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(fromName, toName);
- }
- }
-
private static final ResourceFilter NON_JAVA_RESOURCES = new ResourceFilter() {
@Override
public boolean allows(String path) {
@@ -180,13 +101,6 @@
return true;
}
- private static LinkedList<String> createExtendedCopy(LinkedList<String> list,
- String extendingElement) {
- LinkedList<String> extendedCopy = Lists.newLinkedList(list);
- extendedCopy.add(extendingElement);
- return extendedCopy;
- }
-
/**
* All resources found on the public path, specified by <public> directives in
* modules (or the implicit ./public directory). Marked 'lazy' because it does not
@@ -200,54 +114,15 @@
private boolean collapseAllProperties;
- /**
- * Used to keep track of the current category of attribute source. When the attribute source is
- * TARGET_LIBRARY all attributes are accumulated but when it is EXTERNAL_LIBRARY there are some
- * attributes that are not collected.
- */
- private Deque<AttributeSource> currentAttributeSource = Lists.newLinkedList();
-
private final DefaultFilters defaultFilters;
- private TransitiveClosureSolver<String> depsTransitiveClosureSolver;
-
- /**
- * The canonical module names of dependency library modules per depending library module.
- */
- private LinkedHashMultimap<String, String> directDepModuleNamesByModuleName =
- LinkedHashMultimap.create();
-
private final List<String> entryPointTypeNames = new ArrayList<String>();
/**
- * Names of free-standing compilable library modules that are depended upon by this module.
- */
- private final Set<String> externalLibraryCanonicalModuleNames = Sets.newLinkedHashSet();
-
- /**
- * A stack that keeps track of the type of the current module in the enterModule/exitModule tree.
- */
- private final Deque<ModuleType> currentModuleType = Lists.newLinkedList();
-
- /**
* A stack that keeps track of the name of the current module in the enterModule/exitModule tree.
*/
private final Deque<String> currentLibraryModuleNames = Lists.newLinkedList();
- /**
- * Records the canonical module names for filesets.
- */
- private Set<String> filesetModuleNames = Sets.newHashSet();
-
- /**
- * A mapping from a pair of starting and ending module names of a path to the ordered list of
- * names of fileset modules that connect those end points. The mapping allows one to discover what
- * path of filesets are connecting a pair of libraries when those libraries do not directly depend
- * on one another. Multiple paths may exist; this map contains only one of them.
- */
- private ListMultimap<LibraryDependencyEdge, String> filesetPathPerEdge =
- ArrayListMultimap.create();
-
private final Set<File> gwtXmlFiles = new HashSet<File>();
private final Set<String> inheritedModules = new HashSet<String>();
@@ -269,12 +144,6 @@
private final long moduleDefCreationTime = System.currentTimeMillis();
- /**
- * Whether the module tree is being considered to be one contiguous compilable whole as opposed to
- * a tree of independently compilable library modules.
- */
- private final boolean monolithic;
-
private final String name;
/**
@@ -304,12 +173,6 @@
private final Styles styles = new Styles();
/**
- * Canonical names of non-independently-compilable modules (mostly filesets) that together make up
- * the current module.
- */
- private final Set<String> targetLibraryCanonicalModuleNames = Sets.newLinkedHashSet();
-
- /**
* A mapping from names of modules to path to their associated .gwt.xml file.
*/
private Map<String, String> gwtXmlPathByModuleName = Maps.newHashMap();
@@ -329,32 +192,14 @@
boolean mergePathPrefixes) {
this.name = name;
this.resources = resources;
- this.monolithic = monolithic;
sourcePrefixSet = new PathPrefixSet(mergePathPrefixes);
defaultFilters = new DefaultFilters();
}
- /**
- * Register a {@code dependencyModuleName} as a directDependency of {@code currentModuleName}
- */
- public void addDirectDependency(String currentModuleName, String dependencyModuleName) {
- directDepModuleNamesByModuleName.put(currentModuleName, dependencyModuleName);
- }
-
public synchronized void addEntryPointTypeName(String typeName) {
- if (!attributeIsForTargetLibrary()) {
- return;
- }
entryPointTypeNames.add(typeName);
}
- /**
- * Registers a module as a fileset.
- */
- public void addFileset(String filesetModuleName) {
- filesetModuleNames.add(filesetModuleName);
- }
-
public void addGwtXmlFile(File xmlFile) {
gwtXmlFiles.add(xmlFile);
}
@@ -379,9 +224,6 @@
if (lazyPublicOracle != null) {
throw new IllegalStateException("Already normalized");
}
- if (!attributeIsForTargetLibrary()) {
- return;
- }
publicPrefixSet.add(new PathPrefix(getCurrentLibraryModuleName(), publicPackage, defaultFilters
.customResourceFilter(includeList, excludeList, skipList, defaultExcludes, caseSensitive),
true, excludeList));
@@ -391,17 +233,11 @@
if (lazyResourcesOracle != null) {
throw new IllegalStateException("Already normalized");
}
- if (!attributeIsForTargetLibrary()) {
- return;
- }
resourcePrefixes.add(new PathPrefix(getCurrentLibraryModuleName(), resourcePath,
NON_JAVA_RESOURCES, false, null));
}
public void addRule(Rule rule) {
- if (!attributeIsForTargetLibrary()) {
- return;
- }
getRules().addFirst(rule);
}
@@ -417,9 +253,6 @@
if (lazySourceOracle != null) {
throw new IllegalStateException("Already normalized");
}
- if (!attributeIsForTargetLibrary()) {
- return;
- }
PathPrefix pathPrefix = new PathPrefix(getCurrentLibraryModuleName(),
sourcePackage, defaultFilters.customJavaFilter(includeList, excludeList, skipList,
defaultExcludes, caseSensitive), isSuperSource, excludeList);
@@ -477,62 +310,14 @@
/**
* Called as module tree parsing enters and exits individual module file of various types and so
* provides the ModuleDef with an opportunity to keep track of what context it is currently
- * operating.<br />
- *
- * At the moment the ModuleDef uses it's monolithic property in combination with the entering
- * modules ModuleType to updates its idea of attribute source.
+ * operating.
*/
- public void enterModule(ModuleType moduleType, String canonicalModuleName) {
- currentModuleType.push(moduleType);
- if (moduleType == ModuleType.FILESET) {
- addFileset(canonicalModuleName);
- } else {
- currentLibraryModuleNames.push(canonicalModuleName);
- }
- if (monolithic) {
- // When you're monolithic the module tree is all effectively one giant library.
- currentAttributeSource.push(AttributeSource.TARGET_LIBRARY);
- targetLibraryCanonicalModuleNames.add(canonicalModuleName);
- return;
- }
-
- // When compiling separately it's not legal to have a fileset module at the root.
- Preconditions.checkArgument(
- !(currentAttributeSource.isEmpty() && moduleType == ModuleType.FILESET));
-
- // The compilation target always starts at the root of the graph so if there is a library type
- // module at the root of the graph.
- if (currentAttributeSource.isEmpty() && moduleType == ModuleType.LIBRARY) {
- // Then any attributes you see are your own.
- currentAttributeSource.push(AttributeSource.TARGET_LIBRARY);
- targetLibraryCanonicalModuleNames.add(canonicalModuleName);
- return;
- }
-
- // If at the moment any attributes you see are your own.
- if (currentAttributeSource.peek() == AttributeSource.TARGET_LIBRARY) {
- // And you enter a fileset module
- if (moduleType == ModuleType.FILESET) {
- // Then any attributes you see are still your own.
- currentAttributeSource.push(AttributeSource.TARGET_LIBRARY);
- targetLibraryCanonicalModuleNames.add(canonicalModuleName);
- } else {
- // But if you enter a library module then any attributes you see are external.
- currentAttributeSource.push(AttributeSource.EXTERNAL_LIBRARY);
- addExternalLibraryCanonicalModuleName(canonicalModuleName);
- }
- } else if (currentAttributeSource.peek() == AttributeSource.EXTERNAL_LIBRARY) {
- // If your current attribute source is an external library then regardless of whether you
- // enter another fileset or library your attribute source is still external.
- currentAttributeSource.push(AttributeSource.EXTERNAL_LIBRARY);
- }
+ public void enterModule(String canonicalModuleName) {
+ currentLibraryModuleNames.push(canonicalModuleName);
}
public void exitModule() {
- if (currentModuleType.pop() == ModuleType.LIBRARY) {
- currentLibraryModuleNames.pop();
- }
- currentAttributeSource.pop();
+ currentLibraryModuleNames.pop();
}
public synchronized Resource findPublicFile(String partialPath) {
@@ -641,31 +426,11 @@
return compilationState;
}
- /**
- * The module names for its direct non fileset dependents.
- */
- public Collection<String> getDirectDependencies(String libraryModuleName) {
- assert !filesetModuleNames.contains(libraryModuleName);
- return directDepModuleNamesByModuleName.get(libraryModuleName);
- }
-
public synchronized String[] getEntryPointTypeNames() {
final int n = entryPointTypeNames.size();
return entryPointTypeNames.toArray(new String[n]);
}
- /**
- * Returns the names of free-standing compilable library modules that are depended upon by this
- * module.
- */
- public Set<String> getExternalLibraryCanonicalModuleNames() {
- return externalLibraryCanonicalModuleNames;
- }
-
- public List<String> getFileSetPathBetween(String fromModuleName, String toModuleName) {
- return filesetPathPerEdge.get(new LibraryDependencyEdge(fromModuleName, toModuleName));
- }
-
public synchronized String getFunctionName() {
return getName().replace('.', '_');
}
@@ -810,19 +575,6 @@
return styles;
}
- /**
- * Returns the names of non-independently-compilable modules (mostly filesets) that together make
- * up the current module.
- */
- public Set<String> getTargetLibraryCanonicalModuleNames() {
- return targetLibraryCanonicalModuleNames;
- }
-
- @Override
- public Set<String> getTransitiveDepModuleNames(String libraryModuleName) {
- return getDepsTransitiveClosureSolver().getReachableNodes(libraryModuleName);
- }
-
public boolean isGwtXmlFileStale() {
return lastModified() > moduleDefCreationTime;
}
@@ -853,10 +605,6 @@
servletClassNamesByPath.put(path, servletClassName);
}
- public void printOverlappingSourceWarnings(TreeLogger logger) {
- lazySourceOracle.printOverlappingModuleIncludeWarnings(logger);
- }
-
public void recordModuleGwtXmlFile(String moduleName, String fileSourcePath) {
gwtXmlPathByModuleName.put(moduleName, fileSourcePath);
}
@@ -881,19 +629,11 @@
}
void addBindingPropertyDefinedValue(BindingProperty bindingProperty, String token) {
- if (attributeIsForTargetLibrary()) {
- bindingProperty.addTargetLibraryDefinedValue(bindingProperty.getRootCondition(), token);
- } else {
- bindingProperty.addDefinedValue(bindingProperty.getRootCondition(), token);
- }
+ bindingProperty.addDefinedValue(bindingProperty.getRootCondition(), token);
}
void addConfigurationPropertyValue(ConfigurationProperty configurationProperty, String value) {
- if (attributeIsForTargetLibrary()) {
- configurationProperty.addTargetLibraryValue(value);
- } else {
- configurationProperty.addValue(value);
- }
+ configurationProperty.addValue(value);
}
void addInheritedModules(String moduleName) {
@@ -911,9 +651,6 @@
Event moduleDefNormalize =
SpeedTracerLogger.start(CompilerEventType.MODULE_DEF, "phase", "normalize");
- // Compute compact dependency graph;
- computeLibraryDependencyGraph();
-
// Normalize property providers.
//
for (BindingProperty prop : properties.getBindingProperties()) {
@@ -949,26 +686,8 @@
moduleDefNormalize.end();
}
- void setConfigurationPropertyValue(ConfigurationProperty configurationProperty,
- String value) {
- if (attributeIsForTargetLibrary()) {
- configurationProperty.setTargetLibraryValue(value);
- } else {
- configurationProperty.setValue(value);
- }
- }
-
- private void addExternalLibraryCanonicalModuleName(String externalLibraryCanonicalModuleName) {
- // Ignore circular dependencies on self.
- if (externalLibraryCanonicalModuleName.equals(getCanonicalName())) {
- return;
- }
- externalLibraryCanonicalModuleNames.add(externalLibraryCanonicalModuleName);
- }
-
- private boolean attributeIsForTargetLibrary() {
- return currentAttributeSource.isEmpty()
- || currentAttributeSource.peek() == AttributeSource.TARGET_LIBRARY;
+ void setConfigurationPropertyValue(ConfigurationProperty configurationProperty, String value) {
+ configurationProperty.setValue(value);
}
private void checkForSeedTypes(TreeLogger logger, CompilationState compilationState)
@@ -998,58 +717,6 @@
}
}
- /**
- * Reduce the direct dependency graph to exclude filesets.
- */
- private void computeLibraryDependencyGraph() {
- for (String moduleName : Lists.newArrayList(directDepModuleNamesByModuleName.keySet())) {
- Set<String> libraryModules = Sets.newHashSet();
- Set<String> filesetsProcessed = Sets.newHashSet();
-
- // Direct dependents might be libraries or fileset, so add them to a queue of modules
- // to process.
- Queue<LinkedList<String>> modulePathsToProcess = Queues.newArrayDeque();
- Collection<String> directDependencyModuleNames =
- directDepModuleNamesByModuleName.get(moduleName);
- for (String directDependencyModuleName : directDependencyModuleNames) {
- modulePathsToProcess.add(Lists.newLinkedList(ImmutableList.of(directDependencyModuleName)));
- }
- while (!modulePathsToProcess.isEmpty()) {
- LinkedList<String> dependentModuleNamePath = modulePathsToProcess.poll();
- String dependentModuleName = dependentModuleNamePath.getLast();
-
- boolean isLibrary = !filesetModuleNames.contains(dependentModuleName);
- if (isLibrary) {
- // Current dependent is not a fileset so it will be in the list of dependents unless it is
- // the library itself.
- if (!moduleName.equals(dependentModuleName)) {
- libraryModules.add(dependentModuleName);
-
- dependentModuleNamePath.removeLast();
- filesetPathPerEdge.putAll(new LibraryDependencyEdge(moduleName, dependentModuleName),
- dependentModuleNamePath);
- }
- continue;
- }
- // Mark the module as processed to avoid an infinite loop.
- filesetsProcessed.add(dependentModuleName);
-
- // Get the dependencies of the dependent module under consideration and add all those
- // that have not been already processed to the queue of modules to process.
- Set<String> unProcessedModules =
- Sets.newHashSet(directDepModuleNamesByModuleName.get(dependentModuleName));
- unProcessedModules.removeAll(filesetsProcessed);
- for (String unProcessedModule : unProcessedModules) {
- modulePathsToProcess.add(createExtendedCopy(dependentModuleNamePath, unProcessedModule));
- }
- }
- // Rewrite the dependents with the set just computed.
- directDepModuleNamesByModuleName.replaceValues(moduleName, libraryModules);
- }
- // Remove all fileset entries.
- directDepModuleNamesByModuleName.removeAll(filesetModuleNames);
- }
-
private synchronized void ensureResourcesScanned() {
if (resourcesScanned) {
return;
@@ -1069,14 +736,4 @@
private String getCurrentLibraryModuleName() {
return currentLibraryModuleNames.isEmpty() ? "" : currentLibraryModuleNames.peek();
}
-
- private TransitiveClosureSolver<String> getDepsTransitiveClosureSolver() {
- if (depsTransitiveClosureSolver == null) {
- depsTransitiveClosureSolver = new TransitiveClosureSolver<String>();
- for (Entry<String, String> entry : directDepModuleNamesByModuleName.entries()) {
- depsTransitiveClosureSolver.addConnection(entry.getKey(), entry.getValue());
- }
- }
- return depsTransitiveClosureSolver;
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
index 7990296..c91d54a 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
@@ -18,9 +18,6 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.PrecompileTaskOptions;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.resource.impl.UrlResource;
import com.google.gwt.dev.util.Util;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
@@ -155,31 +152,7 @@
return moduleDef;
}
ModuleDefLoader loader = new ModuleDefLoader(compilerContext, resources);
- PrecompileTaskOptions options = compilerContext.getOptions();
- boolean mergePathPrefixes = !(options.warnMissingDeps()
- || compilerContext.getOptions().warnOverlappingSource()
- || compilerContext.getOptions().getMissingDepsFile() != null);
- ModuleDef module = ModuleDefLoader.doLoadModule(loader, logger, moduleName, resources,
- compilerContext.shouldCompileMonolithic(), mergePathPrefixes);
-
- LibraryWriter libraryWriter = compilerContext.getLibraryWriter();
- libraryWriter.setLibraryName(module.getCanonicalName());
- libraryWriter.addDependencyLibraryNames(module.getExternalLibraryCanonicalModuleNames());
-
- // Saves non java and gwt.xml build resources, like PNG and CSS files.
- for (Resource buildResource : module.getBuildResourceOracle().getResources()) {
- if (buildResource.getPath().endsWith(".java")
- || buildResource.getPath().endsWith(".gwt.xml")) {
- continue;
- }
- libraryWriter.addBuildResource(buildResource);
- }
- // Saves public resources.
- for (Resource publicResource : module.getPublicResourceOracle().getResources()) {
- libraryWriter.addPublicResource(publicResource);
- }
-
- return module;
+ return ModuleDefLoader.doLoadModule(loader, logger, moduleName, resources, true, true);
} finally {
moduleDefLoadFromClassPathEvent.end();
}
@@ -303,8 +276,6 @@
TreeLogger logger = parentLogger.branch(TreeLogger.DEBUG, "Loading inherited module '"
+ moduleName + "'", null);
- LibraryWriter libraryWriter = compilerContext.getLibraryWriter();
- LibraryGroup libraryGroup = compilerContext.getLibraryGroup();
if (!ModuleDef.isValidModuleName(moduleName)) {
logger.log(TreeLogger.ERROR, "Invalid module name: '" + moduleName + "'",
@@ -318,11 +289,7 @@
String slashedModuleName = moduleName.replace('.', '/');
String resName = slashedModuleName + ModuleDefLoader.GWT_MODULE_XML_SUFFIX;
URL moduleURL = resourceLoader.getResource(resName);
- if (moduleURL == null && libraryGroup.containsBuildResource(resName)) {
- moduleURL = libraryGroup.getBuildResourceByPath(resName).getURL();
- }
- long lastModified = 0;
if (moduleURL != null) {
moduleDef.recordModuleGwtXmlFile(moduleName, moduleURL.getPath());
String externalForm = moduleURL.toExternalForm();
@@ -334,9 +301,7 @@
&& (!(externalForm.startsWith("zip:file")))
&& (!(externalForm.startsWith("http://")))
&& (!(externalForm.startsWith("ftp://")))) {
- File gwtXmlFile = new File(moduleURL.toURI());
- lastModified = gwtXmlFile.lastModified();
- moduleDef.addGwtXmlFile(gwtXmlFile);
+ moduleDef.addGwtXmlFile(new File(moduleURL.toURI()));
}
} catch (URISyntaxException e) {
logger.log(TreeLogger.ERROR, "Error parsing URI", e);
@@ -364,13 +329,6 @@
ModuleDefSchema schema =
new ModuleDefSchema(logger, this, moduleName, moduleURL, moduleDir, moduleDef);
ReflectiveParser.parse(logger, schema, r);
-
- // If this module.gwt.xml file is one of the target modules that together make up this
- // ModuleDef.
- if (moduleDef.getTargetLibraryCanonicalModuleNames().contains(moduleName)) {
- // Then save a copy of the xml file in the created library file.
- libraryWriter.addBuildResource(new UrlResource(moduleURL, resName, lastModified));
- }
} catch (UnableToCompleteException e) {
// The error has already been logged.
throw e;
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefSchema.java b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefSchema.java
index f5512df..656604c 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/ModuleDefSchema.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/ModuleDefSchema.java
@@ -21,7 +21,6 @@
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.LinkerOrder;
import com.google.gwt.core.ext.linker.PropertyProviderGenerator;
-import com.google.gwt.dev.cfg.ModuleDef.ModuleType;
import com.google.gwt.dev.js.JsParser;
import com.google.gwt.dev.js.JsParserException;
import com.google.gwt.dev.js.ast.JsExprStmt;
@@ -40,7 +39,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
import java.util.regex.Pattern;
@@ -500,7 +498,6 @@
@SuppressWarnings("unused") // called reflectively
protected Schema __inherits_begin(String name)
throws UnableToCompleteException {
- moduleDef.addDirectDependency(moduleName, name);
loader.nestedLoad(logger, name, moduleDef);
return null;
}
@@ -1455,8 +1452,7 @@
@SuppressWarnings("unused")
protected Schema __module_begin(NullableName renameTo, String type)
throws UnableToCompleteException {
- ModuleType moduleType = ModuleType.valueOf(type.toUpperCase(Locale.ROOT));
- moduleDef.enterModule(moduleType, moduleName);
+ moduleDef.enterModule(moduleName);
// All modules implicitly depend on com.google.gwt.core.Core. Processing of this dependency
// needs to occur early so that subsequent processing has the opportunity to override property
diff --git a/dev/core/src/com/google/gwt/dev/cfg/NullLibraryWriter.java b/dev/core/src/com/google/gwt/dev/cfg/NullLibraryWriter.java
deleted file mode 100644
index eae6538..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/NullLibraryWriter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.javac.CompilationErrorsIndex;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.PersistenceBackedObject;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
-
-import java.util.Set;
-
-/**
- * A do-nothing library writer for code paths that expect a library writer but which are running in
- * a context in which no library should to be built.
- */
-public class NullLibraryWriter implements LibraryWriter {
-
- private Set<String> strings = ImmutableSet.of();
-
- @Override
- public void addBuildResource(Resource buildResource) {
- }
-
- @Override
- public void addCompilationUnit(CompilationUnit compilationUnit) {
- }
-
- @Override
- public void addDependencyLibraryNames(Set<String> dependencyLibraryNames) {
- }
-
- @Override
- public void addGeneratedArtifacts(ArtifactSet generatedArtifacts) {
- }
-
- @Override
- public void addPublicResource(Resource publicResource) {
- }
-
- @Override
- public PersistenceBackedObject<PermutationResult> getPermutationResultHandle() {
- return null;
- }
-
- @Override
- public Set<String> getProcessedReboundTypeSourceNames(String generatorName) {
- return null;
- }
-
- @Override
- public Set<String> getReboundTypeSourceNames() {
- return strings;
- }
-
- @Override
- public void markReboundTypeProcessed(String processedReboundTypeSourceName,
- String generatorName) {
- }
-
- @Override
- public void markReboundTypesProcessed(Set<String> reboundTypeSourceNames) {
- }
-
- @Override
- public void setCompilationErrorsIndex(CompilationErrorsIndex compilationErrorsIndex) {
- }
-
- @Override
- public void setLibraryName(String libraryName) {
- }
-
- @Override
- public void write() {
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/PropertyProviderRegistratorGenerator.java b/dev/core/src/com/google/gwt/dev/cfg/PropertyProviderRegistratorGenerator.java
deleted file mode 100644
index 2aa71bb..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/PropertyProviderRegistratorGenerator.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.PropertyProviderGenerator;
-import com.google.gwt.core.ext.linker.impl.StandardConfigurationProperty;
-import com.google.gwt.core.ext.linker.impl.StandardLinkerContext;
-import com.google.gwt.dev.jjs.InternalCompilerException;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * Generator used to generate a class unique to the current module which has a register() function
- * that when invoked will register the given property provider implementations with a global
- * registry.<br />
- *
- * The resulting class is expected to be invoked at runtime as part of per module bootstrapping and
- * before anything that might depend on property lookups (like GWT.create() calls).
- */
-public class PropertyProviderRegistratorGenerator extends Generator {
-
- /**
- * The extension for all generated property provider registrator classes. Is exposed publicly so
- * others can filter using the extension.
- */
- public static final String PROPERTY_PROVIDER_REGISTRATOR_SUFFIX =
- "PropertyProviderRegistrator";
-
- private static final String PACKAGE_PATH = "com.google.gwt.lang";
-
- private static SortedSet<com.google.gwt.core.ext.linker.ConfigurationProperty> toLinkerStyle(
- SortedSet<ConfigurationProperty> configurationProperties) {
- SortedSet<com.google.gwt.core.ext.linker.ConfigurationProperty> linkerConfigurationProperties =
- new TreeSet<com.google.gwt.core.ext.linker.ConfigurationProperty>(
- StandardLinkerContext.CONFIGURATION_PROPERTY_COMPARATOR);
- for (ConfigurationProperty configurationProperty : configurationProperties) {
- linkerConfigurationProperties.add(new StandardConfigurationProperty(configurationProperty));
- }
- return linkerConfigurationProperties;
- }
-
- private SortedSet<com.google.gwt.core.ext.linker.ConfigurationProperty> configurationProperties;
- private Collection<BindingProperty> newBindingProperties;
- private Set<String> propertyProviderClassNames = Sets.newHashSet();
-
- /**
- * Constructs a PropertyProviderRegistratorGenerator that is able to generate a property provider
- * registrator for all of the given a collection of binding properties.<br />
- *
- * The provided binding properties are expected to all have been created by the current module but
- * the provided configuration properties should be all that have been created by the entire
- * current dependency tree.
- */
- public PropertyProviderRegistratorGenerator(Collection<BindingProperty> newBindingProperties,
- SortedSet<ConfigurationProperty> configurationProperties) {
- this.newBindingProperties = newBindingProperties;
- this.configurationProperties = toLinkerStyle(configurationProperties);
- }
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String moduleName)
- throws UnableToCompleteException {
- String typeName = moduleName.replace(".", "_").replace("-", "_") + "_"
- + PROPERTY_PROVIDER_REGISTRATOR_SUFFIX;
- PrintWriter out = context.tryCreate(logger, PACKAGE_PATH, typeName);
-
- if (out != null) {
- out.println("package " + PACKAGE_PATH + ";");
- out.println("import com.google.gwt.lang.RuntimePropertyRegistry;");
- out.println(
- "import com.google.gwt.lang.RuntimePropertyRegistry.PropertyValueProvider;");
- out.println("public class " + typeName + " {");
-
- for (BindingProperty bindingProperty : newBindingProperties) {
- // If nothing about the binding property was set or created in the current module.
- if (bindingProperty.getTargetLibraryDefinedValues().isEmpty()) {
- // Then its previously created property provider is still valid.
- continue;
- }
- createPropertyProviderClass(logger, out, bindingProperty);
- }
- // TODO(stalcup): create configuration property providers.
-
- out.println(" public static void register() {");
- for (String propertyProviderClassName : propertyProviderClassNames) {
- out.println(" RuntimePropertyRegistry.registerPropertyValueProvider(new "
- + propertyProviderClassName + "());");
- }
- // TODO(stalcup): register configuration property providers.
- out.println(" }");
- out.println("}");
-
- context.commit(logger, out);
- } else {
- // Must have been a cache hit.
- }
-
- return PACKAGE_PATH + "." + typeName;
- }
-
- private void createConditionTreeGetter(PrintWriter out, BindingProperty bindingProperty) {
- List<Entry<Condition, SortedSet<String>>> entries = new ArrayList<
- Entry<Condition, SortedSet<String>>>(bindingProperty.getConditionalValues().entrySet());
- List<Entry<Condition, SortedSet<String>>> prioritizedEntries = Lists.reverse(entries);
-
- out.println(" public native String getValue() /*-{");
- boolean alwaysReturnsAValue = false;
- for (Entry<Condition, SortedSet<String>> entry : prioritizedEntries) {
- Condition condition = entry.getKey();
- SortedSet<String> propertyValue = entry.getValue();
-
- String conditionSource = condition.toSource();
- if (!conditionSource.isEmpty() && !conditionSource.equals("true")) {
- out.println(" if (" + conditionSource + ") {");
- out.println(" return \"" + propertyValue.iterator().next() + "\";");
- out.println(" }");
- } else {
- alwaysReturnsAValue = true;
- out.println(" return \"" + propertyValue.iterator().next() + "\";");
- }
- }
- if (!alwaysReturnsAValue) {
- out.println(" throw @java.lang.RuntimeException::new(Ljava/lang/String;)"
- + "(\"No known value for property " + bindingProperty.getName() + "\");");
- }
- out.println(" }-*/;");
- }
-
- private void createConstrainedValueGetter(PrintWriter out, BindingProperty bindingProperty) {
- out.println(" public String getValue() {");
- out.println(" return \"" + bindingProperty.getConstrainedValue() + "\";");
- out.println(" }");
- }
-
- private void createPropertyProviderClass(
- TreeLogger logger, PrintWriter out, BindingProperty bindingProperty) {
- String bindingPropertyClassName = "PropertyValueProvider" + propertyProviderClassNames.size();
- propertyProviderClassNames.add(bindingPropertyClassName);
-
- out.println(
- " private static class " + bindingPropertyClassName + " extends PropertyValueProvider {");
- out.println(" public String getName() {");
- out.println(" return \"" + bindingProperty.getName() + "\";");
- out.println(" }");
-
- // There are four different ways that modules can register the runtime provider for binding
- // properties and the order of precedence is very particular and important.
- if (bindingProperty.getConstrainedValue() != null) {
- createConstrainedValueGetter(out, bindingProperty);
- } else if (bindingProperty.isDerived()) {
- createConditionTreeGetter(out, bindingProperty);
- } else if (bindingProperty.getProviderGenerator() != null) {
- createPropertyProviderGeneratorGetter(logger, out, bindingProperty);
- } else if (bindingProperty.getProvider() != null) {
- createProviderGetter(out, bindingProperty);
- } else {
- throw new InternalCompilerException("Failed to locate the runtime provider for "
- + "binding property '" + bindingProperty.getName() + "'");
- }
- out.println(" }");
- }
-
- private void createPropertyProviderGeneratorGetter(
- TreeLogger logger, PrintWriter out, BindingProperty bindingProperty) {
- out.print(" public native String getValue() /*-");
- out.print(generateValue(logger, bindingProperty).trim());
- out.println("-*/;");
- }
-
- private void createProviderGetter(PrintWriter out, BindingProperty bindingProperty) {
- out.print(" public native String getValue() /*-");
- out.print(bindingProperty.getProvider().getBody().trim());
- out.print("-*/;");
- }
-
- private String generateValue(TreeLogger logger, BindingProperty bindingProperty) {
- PropertyProviderGenerator propertyProviderGenerator;
- try {
- propertyProviderGenerator = bindingProperty.getProviderGenerator().newInstance();
- } catch (IllegalAccessException e) {
- throw new InternalCompilerException("Failed to instantiate property provider generator "
- + bindingProperty.getProviderGenerator());
- } catch (InstantiationException e) {
- throw new InternalCompilerException("Failed to instantiate property provider generator "
- + bindingProperty.getProviderGenerator());
- }
-
- try {
- return propertyProviderGenerator.generate(logger,
- Sets.newTreeSet(Arrays.asList(bindingProperty.getDefinedValues())),
- bindingProperty.getFallback(), configurationProperties);
-
- } catch (UnableToCompleteException e) {
- throw new InternalCompilerException("Failed to run property provider generator "
- + bindingProperty.getProviderGenerator());
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java b/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java
index 9641946..1481bcd 100644
--- a/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java
+++ b/dev/core/src/com/google/gwt/dev/cfg/RuleGenerateWith.java
@@ -15,25 +15,16 @@
*/
package com.google.gwt.dev.cfg;
-import com.google.gwt.core.ext.BadPropertyValueException;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.Generator.RunsLocal;
-import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.RebindResult;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.dev.javac.StandardGeneratorContext;
-import com.google.gwt.dev.javac.typemodel.LibraryTypeOracle.UnsupportedTypeOracleAccess;
-import com.google.gwt.dev.javac.typemodel.TypeOracle;
import com.google.gwt.dev.jjs.InternalCompilerException;
import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.base.Objects;
import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -55,7 +46,6 @@
return runsLocal == null ? ALL_PROPERTIES : ImmutableSet.copyOf(runsLocal.requiresProperties());
}
- private final Set<String> accessedPropertyNames;
private Generator generator;
private final Class<? extends Generator> generatorClass;
private Map<String, String> rebindProperties;
@@ -64,27 +54,6 @@
public RuleGenerateWith(Class<? extends Generator> generatorClass) {
this.generatorClass = generatorClass;
- this.accessedPropertyNames = getAccessedPropertyNames(generatorClass);
- }
-
- /**
- * Returns whether the output of the Generator being managed by this rule is modified by or
- * whether the rules embedded condition is judging any of the properties whose names have been
- * passed.<br />
- *
- * Makes it possible for external callers to watch the changing property environment and only
- * trigger Generators within Rules whose output might have changed.
- */
- public boolean caresAboutProperties(Set<String> propertyNames) {
- // If this generator cares about all properties.
- if (accessedPropertyNames.equals(ALL_PROPERTIES)) {
- // Then if some properties were supplied, it cares about them.
- return !propertyNames.isEmpty();
- }
-
- // Otherwise an explicit list of cared about properties was supplied. Return whether any of the
- // supplied properties is cared about.
- return !Sets.intersection(accessedPropertyNames, propertyNames).isEmpty();
}
/**
@@ -118,27 +87,6 @@
}
/**
- * Generate all possible Generator output for the wrapped Generator in combination with the scope
- * of Properties and values known about by the passed GeneratorContext. Additionally generate and
- * gather runtime rebind rules for all corresponding pairs of property values and Generator
- * output.
- */
- public void generate(TreeLogger logger, Properties moduleProperties, GeneratorContext context,
- String typeName) throws UnableToCompleteException {
- Map<Map<String, String>, String> resultTypeNamesByProperties =
- computeResultTypeNamesByProperties(
- logger, moduleProperties, (StandardGeneratorContext) context, typeName);
-
- rebindRequestTypeName = typeName;
- for (Entry<Map<String, String>, String> entry : resultTypeNamesByProperties.entrySet()) {
- rebindProperties = entry.getKey();
- rebindResultTypeName = entry.getValue();
- runtimeRebindRuleGenerator.generate(
- generateCreateInstanceExpression(), generateMatchesExpression());
- }
- }
-
- /**
* Returns the name of the class of Generator being managed here.
*/
public String getName() {
@@ -160,36 +108,6 @@
return context.runGeneratorIncrementally(logger, generatorClass, typeName);
}
- public boolean relevantPropertiesAreFinal(Properties currentProperties,
- Properties finalProperties) {
- if (accessedPropertyNames.equals(ALL_PROPERTIES)) {
- // Generator must be assumed to depend on all properties.
- for (BindingProperty finalProperty : finalProperties.getBindingProperties()) {
- Property currentProperty = currentProperties.find(finalProperty.getName());
- if (!Objects.equal(finalProperty, currentProperty)) {
- return false;
- }
- }
- for (ConfigurationProperty finalProperty : finalProperties.getConfigurationProperties()) {
- Property currentProperty = currentProperties.find(finalProperty.getName());
- if (!Objects.equal(finalProperty, currentProperty)) {
- return false;
- }
- }
- return true;
- }
-
- // Generator defines a limited set of properties it cares about.
- for (String accessedPropertyName : accessedPropertyNames) {
- Property finalProperty = finalProperties.find(accessedPropertyName);
- Property currentProperty = currentProperties.find(accessedPropertyName);
- if (!Objects.equal(finalProperty, currentProperty)) {
- return false;
- }
- }
- return true;
- }
-
@Override
public String toString() {
return "<generate-with class='" + generatorClass.getName() + "'/>";
@@ -230,88 +148,4 @@
}
return generator;
}
-
- /**
- * Repeatedly run the contained Generator with the maximum range of combinations of Properties and
- * values. Log corresponding pairs of property values and Generator output.
- */
- private Map<Map<String, String>, String> computeResultTypeNamesByProperties(TreeLogger logger,
- Properties moduleProperties, StandardGeneratorContext context, String typeName)
- throws UnableToCompleteException {
- Map<Map<String, String>, String> resultTypeNamesByProperties = Maps.newLinkedHashMap();
- DynamicPropertyOracle dynamicPropertyOracle = new DynamicPropertyOracle(moduleProperties);
-
- // Maybe prime the pump.
- if (!accessedPropertyNames.equals(ALL_PROPERTIES)) {
- for (String accessedPropertyName : accessedPropertyNames) {
- try {
- dynamicPropertyOracle.getSelectionProperty(logger, accessedPropertyName);
- } catch (BadPropertyValueException e) {
- // ignore
- }
- }
- }
- boolean needsAllTypesIfRun = contentDependsOnTypes() && context.isGlobalCompile();
- TypeOracle typeModelTypeOracle =
- (com.google.gwt.dev.javac.typemodel.TypeOracle) context.getTypeOracle();
-
- context.setPropertyOracle(dynamicPropertyOracle);
-
- context.setCurrentGenerator(generatorClass);
-
- do {
- resultTypeNamesByProperties.clear();
- Properties accessedProperties = new Properties();
-
- List<BindingProperty> accessedPropertiesList =
- new ArrayList<BindingProperty>(dynamicPropertyOracle.getAccessedProperties());
- for (BindingProperty bindingProperty : accessedPropertiesList) {
- accessedProperties.addBindingProperty(bindingProperty);
- }
- PropertyPermutations permutationsOfAccessedProperties =
- new PropertyPermutations(accessedProperties, Sets.<String> newHashSet());
-
- for (int permutationId = 0; permutationId < permutationsOfAccessedProperties.size();
- permutationId++) {
- String[] orderedPropertyValues =
- permutationsOfAccessedProperties.getOrderedPropertyValues(permutationId);
- BindingProperty[] orderedProperties =
- permutationsOfAccessedProperties.getOrderedProperties();
-
- dynamicPropertyOracle.reset();
- for (int propertyIndex = 0; propertyIndex < orderedPropertyValues.length; propertyIndex++) {
- dynamicPropertyOracle.prescribePropertyValue(orderedProperties[propertyIndex].getName(),
- orderedPropertyValues[propertyIndex]);
- }
-
- if (!isApplicable(logger, context, typeName)) {
- continue;
- }
- if (needsAllTypesIfRun) {
- typeModelTypeOracle.ensureAllLoaded();
- }
- String resultTypeName;
- try {
- resultTypeName = getGenerator().generate(logger, context, typeName);
- } catch (UnsupportedTypeOracleAccess e) {
- logger.log(TreeLogger.ERROR, String.format(
- "TypeOracle error when running generator '%s' in an incremental compile: %s",
- getName(), e.getMessage()));
- throw new UnableToCompleteException();
- }
- if (resultTypeName != null) {
- // Some generators only run to create resource artifacts and don't actually participate
- // in the requestType->resultType rebind process.
- resultTypeNamesByProperties.put(dynamicPropertyOracle.getPrescribedPropertyValuesByName(),
- resultTypeName);
- }
-
- if (dynamicPropertyOracle.haveAccessedPropertiesChanged()) {
- break;
- }
- }
- } while (dynamicPropertyOracle.haveAccessedPropertiesChanged());
-
- return resultTypeNamesByProperties;
- }
}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/RuleReplaceWithFallback.java b/dev/core/src/com/google/gwt/dev/cfg/RuleReplaceWithFallback.java
deleted file mode 100644
index 382f88b..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/RuleReplaceWithFallback.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.cfg;
-
-/**
- * A shorthand rule to replace the type being rebound with itself.<br />
- *
- * Useful when defining fallback rebind rules that makes sure that a GWT.create(Foo.class) will
- * attempt to instantiate a Foo if no other replacement rebinds have been declared or are currently
- * applicable.
- */
-public class RuleReplaceWithFallback extends RuleReplaceWith {
-
- public RuleReplaceWithFallback(String typeSourceName) {
- super(typeSourceName);
- }
-
- @Override
- protected String generateMatchesExpression() {
- return String.format("return requestTypeClass == @%s::class;", getReplacementTypeName());
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/RuntimeRebindRegistratorGenerator.java b/dev/core/src/com/google/gwt/dev/cfg/RuntimeRebindRegistratorGenerator.java
deleted file mode 100644
index ea0f7cd..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/RuntimeRebindRegistratorGenerator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-
-import java.io.PrintWriter;
-import java.util.Map;
-
-/**
- * Generator used to generate a class unique to the current module which has a register() function
- * which when invoked will register all currently known runtime rebind rule implementations with a
- * global registry.<br />
- *
- * The resulting class is expected to be invoked as part of per module bootstrapping and before
- * anything that might depend on GWT.create() rebinding (including onModuleLoad() or gwtOnLoad()
- * methods).
- */
-public class RuntimeRebindRegistratorGenerator extends Generator {
-
- private static final String PACKAGE_PATH = "com.google.gwt.lang";
-
- /**
- * The extension for all generated runtime rebind registrator classes. Is exposed publicly so
- * others can filter using the extension.
- */
- public static final String RUNTIME_REBIND_REGISTRATOR_SUFFIX = "RuntimeRebindRegistrator";
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String canonicalModuleName) {
- Map<String, String> runtimeRebindRuleSourcesByShortName =
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME;
-
- // Creates a new class definition unique per module to avoid collision.
- String typeShortName = canonicalModuleName.replace(".", "_").replace("-", "_") + "_"
- + RUNTIME_REBIND_REGISTRATOR_SUFFIX;
- PrintWriter out = context.tryCreate(logger, PACKAGE_PATH, typeShortName);
-
- if (out != null) {
- out.println("package " + PACKAGE_PATH + ";");
- out.println("public class " + typeShortName + " {");
-
- // Drop all of the runtime rebind rule class implementations in.
- for (String runtimeRebindRuleSource : runtimeRebindRuleSourcesByShortName.values()) {
- out.println(runtimeRebindRuleSource);
- }
-
- out.println(" public static void register() {");
- if (!runtimeRebindRuleSourcesByShortName.isEmpty()) {
- // Instantiates and registers each one.
- for (String runtimeRebindRuleShortName : runtimeRebindRuleSourcesByShortName.keySet()) {
- out.println(String.format(" RuntimeRebinder.registerRuntimeRebindRule(new %s());",
- runtimeRebindRuleShortName));
- }
- } else {
- out.println(" // There are no runtime rebind rules for this module.");
- }
- out.println(" }");
- out.println("}");
-
- context.commit(logger, out);
- } else {
- // Must have been a cache hit.
- }
-
- return PACKAGE_PATH + "." + typeShortName;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ZipLibraries.java b/dev/core/src/com/google/gwt/dev/cfg/ZipLibraries.java
deleted file mode 100644
index 3fb5d48..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/ZipLibraries.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-/**
- * Utility functions and constants for reading and writing zip library files.
- */
-public class ZipLibraries {
-
- /**
- * Should be incremented whenever an incompatible change is made to zip library format. For
- * example adding an entry, removing an entry and changing the format of existing entries are all
- * incompatible changes.
- */
- public static int versionNumber = 2;
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ZipLibrary.java b/dev/core/src/com/google/gwt/dev/cfg/ZipLibrary.java
deleted file mode 100644
index f90ba39..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/ZipLibrary.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.impl.StandardGeneratedResource;
-import com.google.gwt.dev.cfg.Libraries.IncompatibleLibraryVersionException;
-import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.CompilerIoException;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.resource.impl.ZipFileResource;
-import com.google.gwt.dev.util.StringInterningObjectInputStream;
-import com.google.gwt.dev.util.ZipEntryBackedObject;
-import com.google.gwt.thirdparty.guava.common.base.Splitter;
-import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Multimap;
-import com.google.gwt.thirdparty.guava.common.collect.Multimaps;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.io.ByteStreams;
-import com.google.gwt.thirdparty.guava.common.io.CharStreams;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-/**
- * A library that lazily reads and caches data from a zip file.
- */
-public class ZipLibrary implements Library {
-
- private class ZipLibraryReader {
-
- private long lastModified;
- private String libraryPath;
- private ZipFile zipFile;
-
- private ZipLibraryReader(String libraryPath) {
- this.libraryPath = libraryPath;
- try {
- File file = new File(libraryPath);
- lastModified = file.lastModified();
- zipFile = new ZipFile(file);
- } catch (IOException e) {
- throw new CompilerIoException("Failed to open zip file " + libraryPath + ".", e);
- }
- }
-
- private void close() {
- try {
- // Close our ZipFile.
- zipFile.close();
- zipFile = null;
- } catch (IOException e) {
- // nothing to be done about it.
- }
- }
-
- private String decode(String string) {
- string = decodeCharacter(string, Libraries.VALUE_SEPARATOR);
- string = decodeCharacter(string, Libraries.LINE_SEPARATOR);
- string = decodeCharacter(string, Libraries.KEY_VALUE_SEPARATOR);
- string = decodeCharacter(string, Libraries.ENCODE_PREFIX);
- return string;
- }
-
- private String decodeCharacter(String string, char character) {
- return string.replace(Libraries.ENCODE_PREFIX + Integer.toString(character), character + "");
- }
-
- private InputStream getClassFileStream(String classFilePath) {
- ZipEntry classFileEntry =
- zipFile.getEntry(Libraries.computeClassFileEntryName(classFilePath));
- return getInputStream(classFileEntry);
- }
-
- private InputStream getInputStream(ZipEntry zipEntry) {
- try {
- return zipFile.getInputStream(zipEntry);
- } catch (IOException e) {
- throw new CompilerIoException("Couldn't open an input stream to an entry named "
- + zipEntry.getName() + " in zip file " + zipFile.getName() + ".", e);
- }
- }
-
- private ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- return new ZipEntryBackedObject<PermutationResult>(
- zipFile, libraryPath, Libraries.PERMUTATION_RESULT_ENTRY_NAME, PermutationResult.class);
- }
-
- private Resource readBuildResourceByPath(String path) {
- return new ZipFileResource(zipFile, "file:" + libraryPath, lastModified,
- Libraries.DIRECTORY_BUILD_RESOURCES + path);
- }
-
- private Set<String> readBuildResourcePaths() {
- return readStringSet(Libraries.BUILD_RESOURCE_PATHS_ENTRY_NAME);
- }
-
- private byte[] readBytes(String entryName) {
- ZipEntry zipEntry = zipFile.getEntry(entryName);
- try {
- return ByteStreams.toByteArray(getInputStream(zipEntry));
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to read " + entryName + " in " + zipFile.getName() + " as bytes.", e);
- }
- }
-
- private CompilationErrorsIndexImpl readCompilationErrorsIndex() {
- ZipEntry compilationErrorsIndexEntry =
- zipFile.getEntry(Libraries.COMPILATION_ERRORS_INDEX_ENTRY_NAME);
- if (compilationErrorsIndexEntry == null) {
- return null;
- }
-
- InputStream compilationErrorsIndexInputStream = getInputStream(compilationErrorsIndexEntry);
-
- CompilationErrorsIndexImpl newCompilationErrorsIndex;
- try {
- ObjectInputStream objectInputStream =
- new StringInterningObjectInputStream(compilationErrorsIndexInputStream);
- newCompilationErrorsIndex = (CompilationErrorsIndexImpl) objectInputStream.readObject();
- objectInputStream.close();
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to read the compilation errors index for deserialization.", e);
- } catch (ClassNotFoundException e) {
- throw new CompilerIoException(
- "Failed to deserialize the compilation errors index because a "
- + "referenced type could not be found.", e);
- }
-
- return newCompilationErrorsIndex;
- }
-
- private CompilationUnit readCompilationUnitByTypeSourceName(String typeSourceName) {
- ZipEntry compilationUnitEntry =
- zipFile.getEntry(Libraries.computeCompilationUnitEntryName(typeSourceName));
- if (compilationUnitEntry == null) {
- return null;
- }
-
- InputStream compilationUnitInputStream = getInputStream(compilationUnitEntry);
-
- CompilationUnit compilationUnit;
- try {
- ObjectInputStream objectInputStream =
- new StringInterningObjectInputStream(compilationUnitInputStream);
- compilationUnit = (CompilationUnit) objectInputStream.readObject();
- objectInputStream.close();
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to read compilation unit " + typeSourceName + " for deserialization.", e);
- } catch (ClassNotFoundException e) {
- throw new CompilerIoException("Failed to deserialize compilation unit " + typeSourceName
- + " because of a missing referenced class.", e);
- }
- return compilationUnit;
- }
-
- private Set<String> readDependencyLibraryNames() {
- return readStringSet(Libraries.DEPENDENCY_LIBRARY_NAMES_ENTRY_NAME);
- }
-
- private ArtifactSet readGeneratedArtifacts() {
- Set<String> generatedArtifactNames =
- readStringSet(Libraries.GENERATED_ARTIFACT_NAMES_ENTRY_NAME);
- ArtifactSet artifacts = new ArtifactSet();
- for (String generatedArtifactName : generatedArtifactNames) {
- StandardGeneratedResource artifact = new StandardGeneratedResource(generatedArtifactName,
- readBytes(Libraries.DIRECTORY_GENERATED_ARTIFACTS + generatedArtifactName));
- artifacts.add(artifact);
- }
- return artifacts;
- }
-
- private String readLibraryName() {
- return readString(Libraries.LIBRARY_NAME_ENTRY_NAME);
- }
-
- private Multimap<String, String> readNestedBinaryNamesByCompilationUnitName() {
- return readStringMultimap(Libraries.NESTED_BINARY_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME);
- }
-
- private Multimap<String, String> readNestedSourceNamesByCompilationUnitName() {
- return readStringMultimap(Libraries.NESTED_SOURCE_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME);
- }
-
- private Multimap<String, String> readProcessedReboundTypeSourceNamesByGenerator() {
- return readStringMultimap(Libraries.PROCESSED_REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME);
- }
-
- private Resource readPublicResourceByPath(String path) {
- return new ZipFileResource(zipFile, "file:" + libraryPath, lastModified,
- Libraries.DIRECTORY_PUBLIC_RESOURCES + path);
- }
-
- private Set<String> readPublicResourcePaths() {
- return readStringSet(Libraries.PUBLIC_RESOURCE_PATHS_ENTRY_NAME);
- }
-
- private Set<String> readReboundTypeSourceNames() {
- return readStringSet(Libraries.REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME);
- }
-
- private Set<String> readRegularClassFilePaths() {
- return readStringSet(Libraries.REGULAR_CLASS_FILE_PATHS_ENTRY_NAME);
- }
-
- private Set<String> readRegularCompilationUnitTypeSourceNames() {
- return readStringSet(Libraries.REGULAR_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME);
- }
-
- private String readString(String entryName) {
- ZipEntry zipEntry = zipFile.getEntry(entryName);
- return readToString(entryName, getInputStream(zipEntry));
- }
-
- private Collection<String> readStringList(String entryName) {
- ZipEntry zipEntry = zipFile.getEntry(entryName);
- InputStream entryInputStream = getInputStream(zipEntry);
- String inputString = readToString(entryName, entryInputStream);
- Iterable<String> lines =
- Splitter.on(Libraries.LINE_SEPARATOR).omitEmptyStrings().split(inputString);
- return Collections.unmodifiableSet(Sets.newLinkedHashSet(lines));
- }
-
- private Multimap<String, String> readStringMultimap(String entryName) {
- ZipEntry zipEntry = zipFile.getEntry(entryName);
- InputStream entryInputStream = getInputStream(zipEntry);
- String inputString = readToString(entryName, entryInputStream);
- Iterable<String> lines =
- Splitter.on(Libraries.LINE_SEPARATOR).omitEmptyStrings().split(inputString);
-
- Multimap<String, String> stringMultimap = LinkedHashMultimap.<String, String> create();
-
- for (String line : lines) {
- LinkedList<String> entry = Lists.newLinkedList(
- Splitter.on(Libraries.KEY_VALUE_SEPARATOR).omitEmptyStrings().split(line));
-
- String key = decode(entry.getFirst());
- Iterable<String> values =
- Splitter.on(Libraries.VALUE_SEPARATOR).omitEmptyStrings().split(entry.getLast());
- List<String> decodedValues = Lists.newArrayList();
- for (String value : values) {
- decodedValues.add(decode(value));
- }
- stringMultimap.putAll(key, decodedValues);
- }
- return stringMultimap;
- }
-
- private Set<String> readStringSet(String entryName) {
- return Collections.unmodifiableSet(Sets.newLinkedHashSet(readStringList(entryName)));
- }
-
- private Set<String> readSuperSourceClassFilePaths() {
- return readStringSet(Libraries.SUPER_SOURCE_CLASS_FILE_PATHS_ENTRY_NAME);
- }
-
- private Set<String> readSuperSourceCompilationUnitTypeSourceNames() {
- return readStringSet(Libraries.SUPER_SOURCE_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME);
- }
-
- private String readToString(String entryName, InputStream inputStream) {
- try {
- return CharStreams.toString(new InputStreamReader(inputStream));
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to read " + entryName + " in " + zipFile.getName() + " as a String.", e);
- }
- }
-
- private int readVersionNumber() {
- return Integer.parseInt(readString(Libraries.VERSION_NUMBER_ENTRY_NAME));
- }
- }
-
- private Set<String> buildResourcePaths;
- private Map<String, Resource> buildResourcesByPath = Maps.newHashMap();
- private Set<String> classFilePaths;
- private CompilationErrorsIndexImpl compilationErrorsIndex;
- private Multimap<String, String> compilationUnitNamesByNestedBinaryName = HashMultimap.create();
- private Multimap<String, String> compilationUnitNamesByNestedSourceName = HashMultimap.create();
- private Map<String, CompilationUnit> compilationUnitsByTypeBinaryName = Maps.newHashMap();
- private Map<String, CompilationUnit> compilationUnitsByTypeSourceName = Maps.newHashMap();
- private Set<String> dependencyLibraryNames;
- private ArtifactSet generatedArtifacts;
- private String libraryName;
- private Multimap<String, String> nestedBinaryNamesByCompilationUnitName;
- private Multimap<String, String> nestedSourceNamesByCompilationUnitName;
- private ZipEntryBackedObject<PermutationResult> permutationResultHandle;
- private Multimap<String, String> processedReboundTypeSourceNamesByGenerator;
- private Set<String> publicResourcePaths;
- private Map<String, Resource> publicResourcesByPath = Maps.newHashMap();
- private Set<String> reboundTypeSourceNames;
- private Set<String> regularCompilationUnitTypeSourceNames;
- private Set<String> superSourceClassFilePaths;
- private Set<String> superSourceCompilationUnitTypeSourceNames;
- private final ZipLibraryReader zipLibraryReader;
-
- public ZipLibrary(String fileName) throws IncompatibleLibraryVersionException {
- zipLibraryReader = new ZipLibraryReader(fileName);
- if (ZipLibraries.versionNumber != zipLibraryReader.readVersionNumber()) {
- throw new IncompatibleLibraryVersionException(
- ZipLibraries.versionNumber, zipLibraryReader.readVersionNumber());
- }
- }
-
- @Override
- public void close() {
- zipLibraryReader.close();
- }
-
- @Override
- public Resource getBuildResourceByPath(String path) {
- if (!buildResourcesByPath.containsKey(path)) {
- buildResourcesByPath.put(path, zipLibraryReader.readBuildResourceByPath(path));
- }
- return buildResourcesByPath.get(path);
- }
-
- @Override
- public Set<String> getBuildResourcePaths() {
- if (buildResourcePaths == null) {
- buildResourcePaths = Collections.unmodifiableSet(zipLibraryReader.readBuildResourcePaths());
- }
- return buildResourcePaths;
- }
-
- @Override
- public InputStream getClassFileStream(String classFilePath) {
- return zipLibraryReader.getClassFileStream(classFilePath);
- }
-
- @Override
- public CompilationErrorsIndexImpl getCompilationErrorsIndex() {
- if (compilationErrorsIndex == null) {
- compilationErrorsIndex = zipLibraryReader.readCompilationErrorsIndex();
- // There may have been no compilation error index data to read but libraries must still return
- // an empty index instead of null.
- if (compilationErrorsIndex == null) {
- compilationErrorsIndex = new CompilationErrorsIndexImpl();
- }
- }
- return compilationErrorsIndex;
- }
-
- @Override
- public CompilationUnit getCompilationUnitByTypeBinaryName(String typeBinaryName) {
- // If the type cache doesn't contain the type yet.
- if (!compilationUnitsByTypeBinaryName.containsKey(typeBinaryName)) {
-
- // Ensure the nested name mapping has been read.
- getNestedBinaryNamesByCompilationUnitName();
- // Convert nested to enclosing type name.
- String typeSourceName =
- compilationUnitNamesByNestedBinaryName.get(typeBinaryName).iterator().next();
-
- // and the library on disk doesn't contain the type at all.
- if (!containsCompilationUnit(typeSourceName)) {
- // cache the fact that the type isn't available on disk.
- compilationUnitsByTypeBinaryName.put(typeBinaryName, null);
- return null;
- }
- // otherwise read and cache the type.
- CompilationUnit compilationUnit =
- zipLibraryReader.readCompilationUnitByTypeSourceName(typeSourceName);
- compilationUnitsByTypeBinaryName.put(typeBinaryName, compilationUnit);
- }
- return compilationUnitsByTypeBinaryName.get(typeBinaryName);
- }
-
- @Override
- public CompilationUnit getCompilationUnitByTypeSourceName(String typeSourceName) {
- // If the type cache doesn't contain the type yet.
- if (!compilationUnitsByTypeSourceName.containsKey(typeSourceName)) {
-
- // Ensure the nested name mapping has been read.
- getNestedSourceNamesByCompilationUnitName();
- // Convert nested to enclosing type name.
- typeSourceName = compilationUnitNamesByNestedSourceName.get(typeSourceName).iterator().next();
-
- // and the library on disk doesn't contain the type at all.
- if (!containsCompilationUnit(typeSourceName)) {
- // cache the fact that the type isn't available on disk.
- compilationUnitsByTypeSourceName.put(typeSourceName, null);
- return null;
- }
- // otherwise read and cache the type.
- compilationUnitsByTypeSourceName.put(
- typeSourceName, zipLibraryReader.readCompilationUnitByTypeSourceName(typeSourceName));
- }
- return compilationUnitsByTypeSourceName.get(typeSourceName);
- }
-
- @Override
- public Set<String> getDependencyLibraryNames() {
- if (dependencyLibraryNames == null) {
- dependencyLibraryNames =
- Collections.unmodifiableSet(zipLibraryReader.readDependencyLibraryNames());
- }
- return dependencyLibraryNames;
- }
-
- @Override
- public ArtifactSet getGeneratedArtifacts() {
- if (generatedArtifacts == null) {
- generatedArtifacts = zipLibraryReader.readGeneratedArtifacts();
- }
- return generatedArtifacts;
- }
-
- @Override
- public String getLibraryName() {
- if (libraryName == null) {
- libraryName = zipLibraryReader.readLibraryName();
- }
- return libraryName;
- }
-
- @Override
- public Multimap<String, String> getNestedBinaryNamesByCompilationUnitName() {
- if (nestedBinaryNamesByCompilationUnitName == null) {
- nestedBinaryNamesByCompilationUnitName = Multimaps.unmodifiableMultimap(
- zipLibraryReader.readNestedBinaryNamesByCompilationUnitName());
- Multimaps.invertFrom(nestedBinaryNamesByCompilationUnitName,
- compilationUnitNamesByNestedBinaryName);
- }
- return nestedBinaryNamesByCompilationUnitName;
- }
-
- @Override
- public Multimap<String, String> getNestedSourceNamesByCompilationUnitName() {
- if (nestedSourceNamesByCompilationUnitName == null) {
- nestedSourceNamesByCompilationUnitName = Multimaps.unmodifiableMultimap(
- zipLibraryReader.readNestedSourceNamesByCompilationUnitName());
- Multimaps.invertFrom(nestedSourceNamesByCompilationUnitName,
- compilationUnitNamesByNestedSourceName);
- }
- return nestedSourceNamesByCompilationUnitName;
- }
-
- @Override
- public ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- if (permutationResultHandle == null) {
- permutationResultHandle = zipLibraryReader.getPermutationResultHandle();
- }
- return permutationResultHandle;
- }
-
- @Override
- public Multimap<String, String> getProcessedReboundTypeSourceNamesByGenerator() {
- if (processedReboundTypeSourceNamesByGenerator == null) {
- processedReboundTypeSourceNamesByGenerator = Multimaps.unmodifiableMultimap(
- zipLibraryReader.readProcessedReboundTypeSourceNamesByGenerator());
- }
- return processedReboundTypeSourceNamesByGenerator;
- }
-
- @Override
- public Resource getPublicResourceByPath(String path) {
- if (!publicResourcesByPath.containsKey(path)) {
- publicResourcesByPath.put(path, zipLibraryReader.readPublicResourceByPath(path));
- }
- return publicResourcesByPath.get(path);
- }
-
- @Override
- public Set<String> getPublicResourcePaths() {
- if (publicResourcePaths == null) {
- publicResourcePaths = Collections.unmodifiableSet(zipLibraryReader.readPublicResourcePaths());
- }
- return publicResourcePaths;
- }
-
- @Override
- public Set<String> getReboundTypeSourceNames() {
- if (reboundTypeSourceNames == null) {
- reboundTypeSourceNames =
- Collections.unmodifiableSet(zipLibraryReader.readReboundTypeSourceNames());
- }
- return reboundTypeSourceNames;
- }
-
- @Override
- public Set<String> getRegularClassFilePaths() {
- if (classFilePaths == null) {
- classFilePaths = Collections.unmodifiableSet(zipLibraryReader.readRegularClassFilePaths());
- }
- return classFilePaths;
- }
-
- @Override
- public Set<String> getRegularCompilationUnitTypeSourceNames() {
- if (regularCompilationUnitTypeSourceNames == null) {
- regularCompilationUnitTypeSourceNames =
- Collections.unmodifiableSet(zipLibraryReader.readRegularCompilationUnitTypeSourceNames());
- }
- return regularCompilationUnitTypeSourceNames;
- }
-
- @Override
- public Set<String> getSuperSourceClassFilePaths() {
- if (superSourceClassFilePaths == null) {
- superSourceClassFilePaths =
- Collections.unmodifiableSet(zipLibraryReader.readSuperSourceClassFilePaths());
- }
- return superSourceClassFilePaths;
- }
-
- @Override
- public Set<String> getSuperSourceCompilationUnitTypeSourceNames() {
- if (superSourceCompilationUnitTypeSourceNames == null) {
- superSourceCompilationUnitTypeSourceNames = Collections.unmodifiableSet(
- zipLibraryReader.readSuperSourceCompilationUnitTypeSourceNames());
- }
- return superSourceCompilationUnitTypeSourceNames;
- }
-
- /**
- * Uses regular and super source compilation unit type source name indexes to determine whether a
- * compilation unit of any kind is present that matches the given type source name.
- */
- private boolean containsCompilationUnit(String typeSourceName) {
- return getRegularCompilationUnitTypeSourceNames().contains(typeSourceName)
- || getSuperSourceCompilationUnitTypeSourceNames().contains(typeSourceName);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/cfg/ZipLibraryWriter.java b/dev/core/src/com/google/gwt/dev/cfg/ZipLibraryWriter.java
deleted file mode 100644
index a0c55cb..0000000
--- a/dev/core/src/com/google/gwt/dev/cfg/ZipLibraryWriter.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.core.ext.linker.GeneratedResource;
-import com.google.gwt.dev.javac.CompilationErrorsIndex;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.CompiledClass;
-import com.google.gwt.dev.jjs.CompilerIoException;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.Name.InternalName;
-import com.google.gwt.dev.util.ZipEntryBackedObject;
-import com.google.gwt.thirdparty.guava.common.base.Joiner;
-import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Multimap;
-import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.io.ByteStreams;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.zip.Deflater;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-/**
- * A library builder that writes contents to a zip file.
- */
-// TODO(stalcup): the compiler currently uses an inefficient mixture of java, protobuf, and
-// custom serialization. unify all serialization on protobuf (either ascii or binary format
-// depending on human-readability constraints).
-public class ZipLibraryWriter implements LibraryWriter {
-
- private static String keyValueSeparatorString = Libraries.KEY_VALUE_SEPARATOR + "";
- private static String valueSeparatorString = Libraries.VALUE_SEPARATOR + "";
- private static String lineSeparatorString = Libraries.LINE_SEPARATOR + "";
- private static byte[] keyValueSeparatorBytes = keyValueSeparatorString.getBytes();
- private static byte[] valueSeparatorBytes = valueSeparatorString.getBytes();
- private static byte[] lineSeparatorBytes = lineSeparatorString.getBytes();
-
- private class ZipWriter {
-
- private boolean fileReady;
- private final File zipFile;
- private ZipOutputStream zipOutputStream;
-
- private ZipWriter(String zipFileName) {
- zipFile = new File(zipFileName);
- }
-
- public void writeCompilationErrorsIndex() {
- startEntry(Libraries.COMPILATION_ERRORS_INDEX_ENTRY_NAME);
- try {
- ObjectOutputStream out = new ObjectOutputStream(zipOutputStream);
- out.writeObject(compilationErrorsIndex);
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to serialize the compilation errors index in new library " + zipFile.getPath()
- + ".", e);
- }
- }
-
- public void writeProcessedReboundTypeSourceNamesForGenerators() {
- writeStringMultimap(Libraries.PROCESSED_REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME,
- processedReboundTypeSourceNamesByGenerator);
- }
-
- private void createFileIfMissing() {
- if (!zipFile.exists()) {
- try {
- zipFile.createNewFile();
- if (!zipFile.canWrite()) {
- throw new CompilerIoException(
- "Created new library file " + zipFile.getPath() + " but am unable to write to it.");
- }
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to create new library file " + zipFile.getPath() + ".", e);
- }
- }
- }
-
- private void createZipEntry(String entryName) {
- ZipEntry zipEntry = new ZipEntry(entryName);
- try {
- zipOutputStream.putNextEntry(zipEntry);
- } catch (Exception e) {
- throw new CompilerIoException("Failed to create zip entry " + entryName + ".", e);
- }
- }
-
- private String encode(String string) {
- string = encodeCharacter(string, Libraries.ENCODE_PREFIX);
- string = encodeCharacter(string, Libraries.KEY_VALUE_SEPARATOR);
- string = encodeCharacter(string, Libraries.LINE_SEPARATOR);
- string = encodeCharacter(string, Libraries.VALUE_SEPARATOR);
- return string;
- }
-
- private String encodeCharacter(String string, char character) {
- return string.replace(character + "", Libraries.ENCODE_PREFIX + Integer.toString(character));
- }
-
- private synchronized void ensureFileReady() {
- if (fileReady) {
- return;
- }
- fileReady = true;
-
- ensureParentDirectoryExists();
- createFileIfMissing();
- try {
- zipOutputStream =
- new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
- zipOutputStream.setLevel(Deflater.BEST_SPEED);
- } catch (FileNotFoundException e) {
- throw new CompilerIoException(
- "Failed to open new library file " + zipFile.getPath() + " as a stream.", e);
- }
- }
-
- private void ensureParentDirectoryExists() {
- zipFile.getParentFile().mkdirs();
- }
-
- private ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- return new ZipEntryBackedObject<PermutationResult>(zipOutputStream, zipFile.getPath(),
- Libraries.PERMUTATION_RESULT_ENTRY_NAME, PermutationResult.class);
- }
-
- private void startEntry(String entryName) {
- ZipEntry zipEntry = new ZipEntry(entryName);
- try {
- zipOutputStream.putNextEntry(zipEntry);
- } catch (IOException e) {
- throw new CompilerIoException("Failed to create entry " + entryName
- + " in new library file " + zipFile.getPath() + ".", e);
- }
- }
-
- private void write() {
- ensureFileReady();
-
- try {
- // Header
- writeLibraryName();
- writeVersionNumber();
-
- // Dependency tree structure
- writeDependencyLibraryNames();
-
- // Precompiled sources
- writeClassFilePaths();
- writeCompilationUnitTypeSourceNames();
- writeNestedNamesByCompilationUnitName();
- writeCompilationErrorsIndex();
-
- // Resources
- writeBuildResources();
- writeBuildResourcePaths();
- writePublicResources();
- writePublicResourcePaths();
-
- // Generator related
- writeReboundTypeSourceNames();
- writeProcessedReboundTypeSourceNamesForGenerators();
- writeGeneratedArtifactPaths();
- writeGeneratedArtifacts();
- } finally {
- try {
- zipOutputStream.close();
- } catch (IOException e) {
- throw new CompilerIoException(
- "Failed to close new library file " + zipFile.getPath() + ".", e);
- }
- }
- }
-
- private void writeBuildResourcePaths() {
- writeStringSet(Libraries.BUILD_RESOURCE_PATHS_ENTRY_NAME, buildResourcesByPath.keySet());
- }
-
- private void writeBuildResources() {
- writeResources("build", Libraries.DIRECTORY_BUILD_RESOURCES, buildResourcesByPath);
- }
-
- private void writeClassFile(String classFilePath, byte[] classBytes) {
- try {
- ensureFileReady();
-
- startEntry(Libraries.computeClassFileEntryName(classFilePath));
- zipOutputStream.write(classBytes);
- } catch (IOException e) {
- throw new CompilerIoException("Failed to write class file " + classFilePath
- + " to new library file " + zipFile.getPath() + ".", e);
- }
- }
-
- private void writeClassFilePaths() {
- writeStringSet(Libraries.REGULAR_CLASS_FILE_PATHS_ENTRY_NAME, regularClassFilePaths);
- writeStringSet(Libraries.SUPER_SOURCE_CLASS_FILE_PATHS_ENTRY_NAME, superSourceClassFilePaths);
- }
-
- private void writeCompilationUnitFile(CompilationUnit compilationUnit) {
- ensureFileReady();
-
- startEntry(Libraries.computeCompilationUnitEntryName(compilationUnit.getTypeName()));
- try {
- ObjectOutputStream out = new ObjectOutputStream(zipOutputStream);
- out.writeObject(compilationUnit);
- } catch (IOException e) {
- throw new CompilerIoException("Failed to serialize compilation unit "
- + compilationUnit.getTypeName() + " in new library " + zipFile.getPath() + ".", e);
- }
- }
-
- private void writeCompilationUnitTypeSourceNames() {
- writeStringSet(Libraries.REGULAR_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME,
- regularCompilationUnitTypeSourceNames);
- writeStringSet(Libraries.SUPER_SOURCE_COMPILATION_UNIT_TYPE_SOURCE_NAMES_ENTRY_NAME,
- superSourceCompilationUnitTypeSourceNames);
- }
-
- private void writeDependencyLibraryNames() {
- writeStringSet(Libraries.DEPENDENCY_LIBRARY_NAMES_ENTRY_NAME, dependencyLibraryNames);
- }
-
- private void writeGeneratedArtifactPaths() {
- Set<String> generatedArtifactNames = Sets.newHashSet();
- for (GeneratedResource generatedArtifact : generatedArtifacts.find(GeneratedResource.class)) {
- generatedArtifactNames.add(generatedArtifact.getPartialPath());
- }
- writeStringSet(Libraries.GENERATED_ARTIFACT_NAMES_ENTRY_NAME, generatedArtifactNames);
- }
-
- private void writeGeneratedArtifacts() {
- for (GeneratedResource generatedArtifact : generatedArtifacts.find(GeneratedResource.class)) {
- startEntry(Libraries.DIRECTORY_GENERATED_ARTIFACTS + generatedArtifact.getPartialPath());
- try {
- generatedArtifact.writeTo(TreeLogger.NULL, zipOutputStream);
- } catch (UnableToCompleteException e) {
- throw new CompilerIoException("Failed to read generated artifact "
- + generatedArtifact.getPartialPath() + " to write into new library file "
- + zipFile.getPath() + ".", e);
- }
- }
- }
-
- private void writeLibraryName() {
- writeString(Libraries.LIBRARY_NAME_ENTRY_NAME, libraryName);
- }
-
- private void writeNestedNamesByCompilationUnitName() {
- writeStringMultimap(Libraries.NESTED_SOURCE_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME,
- nestedSourceNamesByCompilationUnitName);
- writeStringMultimap(Libraries.NESTED_BINARY_NAMES_BY_ENCLOSING_NAME_ENTRY_NAME,
- nestedBinaryNamesByCompilationUnitName);
- }
-
- private void writePublicResourcePaths() {
- writeStringSet(Libraries.PUBLIC_RESOURCE_PATHS_ENTRY_NAME, publicResourcesByPath.keySet());
- }
-
- private void writePublicResources() {
- writeResources("public", Libraries.DIRECTORY_PUBLIC_RESOURCES, publicResourcesByPath);
- }
-
- private void writeReboundTypeSourceNames() {
- writeStringSet(Libraries.REBOUND_TYPE_SOURCE_NAMES_ENTRY_NAME, reboundTypeSourceNames);
- }
-
- private void writeResources(
- String typeSourceName, String directory, Map<String, Resource> resourcesByPath) {
- for (Resource resource : resourcesByPath.values()) {
- startEntry(directory + resource.getPath());
- try {
- ByteStreams.copy(resource.openContents(), zipOutputStream);
- } catch (IOException e) {
- throw new CompilerIoException("Failed to copy " + typeSourceName + " resource "
- + resource.getPath() + " into new library file " + zipFile.getPath() + ".", e);
- }
- }
- }
-
- private void writeString(String entryName, String string) {
- createZipEntry(entryName);
- try {
- zipOutputStream.write(string.getBytes());
- } catch (IOException e) {
- throw new CompilerIoException("Failed to write " + entryName + " as a String.", e);
- }
- }
-
- private void writeStringMultimap(String entryName, Multimap<String, String> stringMultimap) {
- Map<String, Collection<String>> stringListsByString = stringMultimap.asMap();
-
- createZipEntry(entryName);
-
- Iterator<Entry<String, Collection<String>>> entryIterator =
- stringListsByString.entrySet().iterator();
-
- try {
- while (entryIterator.hasNext()) {
- Entry<String, Collection<String>> entry = entryIterator.next();
- String key = encode(entry.getKey());
- zipOutputStream.write(key.getBytes());
-
- boolean first = true;
- Collection<String> values = entry.getValue();
- for (String value : values) {
- if (first) {
- first = false;
- zipOutputStream.write(keyValueSeparatorBytes);
- } else {
- zipOutputStream.write(valueSeparatorBytes);
- }
- zipOutputStream.write(encode(value).getBytes());
- }
-
- if (entryIterator.hasNext()) {
- zipOutputStream.write(lineSeparatorBytes);
- }
- }
- } catch (IOException e) {
- throw new CompilerIoException("Failed to write " + entryName + " as a String multimap.", e);
- }
- }
-
- private void writeStringSet(String entryName, Set<String> stringSet) {
- createZipEntry(entryName);
- Set<String> encodedStringSet = Sets.newHashSet();
- for (String string : stringSet) {
- encodedStringSet.add(encode(string));
- }
- try {
- zipOutputStream.write(
- Joiner.on(Libraries.LINE_SEPARATOR).join(encodedStringSet).getBytes());
- } catch (IOException e) {
- throw new CompilerIoException("Failed to write " + entryName + " as a String set.", e);
- }
- }
-
- private void writeVersionNumber() {
- writeString(
- Libraries.VERSION_NUMBER_ENTRY_NAME, Integer.toString(ZipLibraries.versionNumber));
- }
- }
-
- private Map<String, Resource> buildResourcesByPath = Maps.newHashMap();
- private CompilationErrorsIndex compilationErrorsIndex;
- private Map<String, CompilationUnit> compilationUnitsByTypeSourceName = Maps.newHashMap();
- private Set<String> dependencyLibraryNames = Sets.newHashSet();
- private ArtifactSet generatedArtifacts = new ArtifactSet();
- private String libraryName;
- private Multimap<String, String> nestedBinaryNamesByCompilationUnitName =
- LinkedHashMultimap.create();
- private Multimap<String, String> nestedSourceNamesByCompilationUnitName =
- LinkedHashMultimap.create();
- private ZipEntryBackedObject<PermutationResult> permutationResultHandle;
- private SetMultimap<String, String> processedReboundTypeSourceNamesByGenerator =
- HashMultimap.create();
- private Map<String, Resource> publicResourcesByPath = Maps.newHashMap();
- private Set<String> reboundTypeSourceNames = Sets.newHashSet();
- private Set<String> regularClassFilePaths = Sets.newHashSet();
- private Set<String> regularCompilationUnitTypeSourceNames = Sets.newLinkedHashSet();
- private Set<String> superSourceClassFilePaths = Sets.newHashSet();
- private Set<String> superSourceCompilationUnitTypeSourceNames = Sets.newLinkedHashSet();
- private ZipWriter zipWriter;
-
- public ZipLibraryWriter(String fileName) {
- zipWriter = new ZipWriter(fileName);
- }
-
- @Override
- public void addBuildResource(Resource buildResource) {
- buildResourcesByPath.put(buildResource.getPath(), buildResource);
- }
-
- @Override
- public void addCompilationUnit(CompilationUnit compilationUnit) {
- assert !compilationUnit.isError() : "Invalid units should be pruned before writing.";
- assert !compilationUnitsByTypeSourceName.containsKey(
- compilationUnit.getTypeName()) : "Units should be deduped before writing.";
-
- if (compilationUnit.isSuperSource()) {
- superSourceCompilationUnitTypeSourceNames.add(compilationUnit.getTypeName());
- } else {
- regularCompilationUnitTypeSourceNames.add(compilationUnit.getTypeName());
- }
- compilationUnitsByTypeSourceName.put(compilationUnit.getTypeName(), compilationUnit);
-
- nestedSourceNamesByCompilationUnitName.removeAll(compilationUnit.getTypeName());
- nestedBinaryNamesByCompilationUnitName.removeAll(compilationUnit.getTypeName());
- Collection<CompiledClass> compiledClasses = compilationUnit.getCompiledClasses();
- for (CompiledClass compiledClass : compiledClasses) {
- nestedSourceNamesByCompilationUnitName.put(compilationUnit.getTypeName(),
- compiledClass.getSourceName());
- nestedBinaryNamesByCompilationUnitName.put(compilationUnit.getTypeName(),
- InternalName.toBinaryName(compiledClass.getInternalName()));
- }
-
- for (CompiledClass compiledClass : compilationUnit.getCompiledClasses()) {
- if (compilationUnit.isSuperSource()) {
- String classFilePath = compiledClass.getInternalName();
- superSourceClassFilePaths.add(Libraries.computeClassFileName(classFilePath));
- zipWriter.writeClassFile(classFilePath, compiledClass.getBytes());
- } else {
- String classFilePath = compiledClass.getInternalName();
- regularClassFilePaths.add(Libraries.computeClassFileName(classFilePath));
- zipWriter.writeClassFile(classFilePath, compiledClass.getBytes());
- }
- }
-
- zipWriter.writeCompilationUnitFile(compilationUnit);
- }
-
- @Override
- public void addDependencyLibraryNames(Set<String> dependencyLibraryNames) {
- this.dependencyLibraryNames.addAll(dependencyLibraryNames);
- }
-
- @Override
- public void addGeneratedArtifacts(ArtifactSet generatedArtifacts) {
- this.generatedArtifacts.addAll(generatedArtifacts);
- }
-
- @Override
- public void addPublicResource(Resource publicResource) {
- publicResourcesByPath.put(publicResource.getPath(), publicResource);
- }
-
- @Override
- public ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- if (permutationResultHandle == null) {
- permutationResultHandle = zipWriter.getPermutationResultHandle();
- }
- return permutationResultHandle;
- }
-
- @Override
- public Set<String> getProcessedReboundTypeSourceNames(String generatorName) {
- return processedReboundTypeSourceNamesByGenerator.get(generatorName);
- }
-
- @Override
- public Set<String> getReboundTypeSourceNames() {
- return Collections.unmodifiableSet(reboundTypeSourceNames);
- }
-
- @Override
- public void markReboundTypeProcessed(String processedReboundTypeSourceName,
- String generatorName) {
- processedReboundTypeSourceNamesByGenerator.put(generatorName, processedReboundTypeSourceName);
- }
-
- @Override
- public void markReboundTypesProcessed(Set<String> reboundTypeSourceNames) {
- this.reboundTypeSourceNames = reboundTypeSourceNames;
- }
-
- @Override
- public void setCompilationErrorsIndex(CompilationErrorsIndex compilationErrorsIndex) {
- this.compilationErrorsIndex = compilationErrorsIndex;
- }
-
- @Override
- public void setLibraryName(String libraryName) {
- this.libraryName = libraryName;
- }
-
- @Override
- public void write() {
- zipWriter.write();
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CombinedCompilationErrorsIndex.java b/dev/core/src/com/google/gwt/dev/javac/CombinedCompilationErrorsIndex.java
deleted file mode 100644
index 38626be..0000000
--- a/dev/core/src/com/google/gwt/dev/javac/CombinedCompilationErrorsIndex.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.javac;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * A CompilationErrorsIndex facade that exposes the contents of two contained
- * CompilationErrorsIndices.
- */
-public class CombinedCompilationErrorsIndex implements CompilationErrorsIndex {
-
- private CompilationErrorsIndex libraryCompilationErrorsIndex;
- private CompilationErrorsIndex localCompilationErrorsIndexes;
-
- public CombinedCompilationErrorsIndex(CompilationErrorsIndex localCompilationErrorsIndexes,
- CompilationErrorsIndex libraryCompilationErrorsIndex) {
- this.localCompilationErrorsIndexes = localCompilationErrorsIndexes;
- this.libraryCompilationErrorsIndex = libraryCompilationErrorsIndex;
- }
-
- @Override
- public void add(String typeSourceName, String fileName, List<String> typeReferences,
- List<String> compilationErrors) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set<String> getCompileErrors(String typeSourceName) {
- if (localCompilationErrorsIndexes.hasCompileErrors(typeSourceName)) {
- return localCompilationErrorsIndexes.getCompileErrors(typeSourceName);
- }
- if (libraryCompilationErrorsIndex.hasCompileErrors(typeSourceName)) {
- return libraryCompilationErrorsIndex.getCompileErrors(typeSourceName);
- }
- return null;
- }
-
- @Override
- public String getFileName(String typeSourceName) {
- String localFileName = localCompilationErrorsIndexes.getFileName(typeSourceName);
- if (localFileName != null) {
- return localFileName;
- }
- String libraryFileName = libraryCompilationErrorsIndex.getFileName(typeSourceName);
- if (libraryFileName != null) {
- return libraryFileName;
- }
- return null;
- }
-
- @Override
- public Set<String> getTypeReferences(String typeSourceName) {
- if (localCompilationErrorsIndexes.hasTypeReferences(typeSourceName)) {
- return localCompilationErrorsIndexes.getTypeReferences(typeSourceName);
- }
- if (libraryCompilationErrorsIndex.hasTypeReferences(typeSourceName)) {
- return libraryCompilationErrorsIndex.getTypeReferences(typeSourceName);
- }
- return null;
- }
-
- @Override
- public boolean hasCompileErrors(String typeSourceName) {
- return localCompilationErrorsIndexes.hasCompileErrors(typeSourceName)
- || libraryCompilationErrorsIndex.hasCompileErrors(typeSourceName);
- }
-
- @Override
- public boolean hasTypeReferences(String typeSourceName) {
- return localCompilationErrorsIndexes.hasTypeReferences(typeSourceName)
- || libraryCompilationErrorsIndex.hasTypeReferences(typeSourceName);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationErrorsIndexImpl.java b/dev/core/src/com/google/gwt/dev/javac/CompilationErrorsIndexImpl.java
index b8ddbb6..5e80910 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationErrorsIndexImpl.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationErrorsIndexImpl.java
@@ -141,19 +141,6 @@
return referencesByTypeSourceName.containsKey(typeSourceName);
}
- public void merge(CompilationErrorsIndexImpl that) {
- for (String typeSourceName : that.fileNamesByTypeSourceName.keySet()) {
- if (!this.fileNamesByTypeSourceName.containsKey(typeSourceName)) {
- this.fileNamesByTypeSourceName.put(typeSourceName,
- that.fileNamesByTypeSourceName.get(typeSourceName));
- this.compilationErrorsByTypeSourceName.putAll(typeSourceName,
- that.compilationErrorsByTypeSourceName.get(typeSourceName));
- this.referencesByTypeSourceName.putAll(typeSourceName,
- that.referencesByTypeSourceName.get(typeSourceName));
- }
- }
- }
-
private void readObject(ObjectInputStream objectInputStream) throws IOException {
fileNamesByTypeSourceName = readStringMap(objectInputStream);
compilationErrorsByTypeSourceName = readStringListMap(objectInputStream);
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java b/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
index b815005..9fd6bb0 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
@@ -143,7 +143,7 @@
TreeLogger branch = logger.branch(TreeLogger.TRACE,
"Tracing compile failure path for type '" + typeSourceName + "'");
if (logErrorChain(branch, logLevel, typeSourceName,
- compilerContext.getGlobalCompilationErrorsIndex())) {
+ compilerContext.getCompilationErrorsIndex())) {
return;
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationState.java b/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
index d97ba9d..c3a1079 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
@@ -28,7 +28,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
/**
@@ -106,7 +105,7 @@
this.compilerContext = compilerContext;
this.typeOracle = typeOracle;
this.typeOracleUpdater = typeOracleUpdater;
- assimilateUnits(logger, units, true);
+ assimilateUnits(logger, units);
}
/**
@@ -124,29 +123,12 @@
generatedUnitsAddEvent.addData("# new generated units", "" + generatedUnits.size());
Collection<CompilationUnit> newUnits = compileMoreLater.addGeneratedTypes(
logger, generatedUnits, this);
- assimilateUnits(logger, newUnits, true);
+ assimilateUnits(logger, newUnits);
} finally {
generatedUnitsAddEvent.end();
}
}
- /**
- * Indexes referenced external compilation units but does not save them in a library.
- */
- public void addReferencedCompilationUnits(TreeLogger logger,
- List<CompilationUnit> referencedUnits) {
- Event referencedUnitsAddEvent =
- SpeedTracerLogger.start(DevModeEventType.COMP_STATE_ADD_REFERENCED_UNITS);
- try {
- logger = logger.branch(TreeLogger.DEBUG,
- "Adding '" + referencedUnits.size() + "' new referenced units");
- referencedUnitsAddEvent.addData("# new referenced units", "" + referencedUnits.size());
- assimilateUnits(logger, referencedUnits, false);
- } finally {
- referencedUnitsAddEvent.end();
- }
- }
-
public int getCachedGeneratedSourceCount() {
return cachedGeneratedSourceCount;
}
@@ -240,8 +222,7 @@
return typeOracleUpdater;
}
- private void assimilateUnits(TreeLogger logger, Collection<CompilationUnit> units,
- boolean saveInLibrary) {
+ private void assimilateUnits(TreeLogger logger, Collection<CompilationUnit> units) {
for (CompilationUnit unit : units) {
unitMap.put(unit.getTypeName(), unit);
for (CompiledClass compiledClass : unit.getCompiledClasses()) {
@@ -250,15 +231,8 @@
}
}
- // Performed after compilation unit invalidator because only valid units should be saved in the
- // library.
- if (saveInLibrary) {
- CompilationUnitInvalidator.retainValidUnits(logger, units, compileMoreLater.getValidClasses(),
- compilerContext.getLocalCompilationErrorsIndex());
- for (CompilationUnit compilationUnit : units) {
- compilerContext.getLibraryWriter().addCompilationUnit(compilationUnit);
- }
- }
+ CompilationUnitInvalidator.retainValidUnits(logger, units, compileMoreLater.getValidClasses(),
+ compilerContext.getCompilationErrorsIndex());
typeOracleUpdater.addNewUnits(logger, units);
}
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
index 8d678b5..afb0897 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -21,7 +21,6 @@
import com.google.gwt.dev.CompilerContext;
import com.google.gwt.dev.javac.JdtCompiler.AdditionalTypeProviderDelegate;
import com.google.gwt.dev.javac.JdtCompiler.UnitProcessor;
-import com.google.gwt.dev.javac.typemodel.LibraryTypeOracle;
import com.google.gwt.dev.javac.typemodel.TypeOracle;
import com.google.gwt.dev.jjs.CorrelationFactory.DummyCorrelationFactory;
import com.google.gwt.dev.jjs.ast.JDeclaredType;
@@ -116,28 +115,13 @@
}
});
- if (compilerContext.shouldCompileMonolithic()) {
- // GWT drives JDT in a way that allows missing references in the source to be
- // resolved to precompiled bytecode on disk (see INameEnvironment). This is
- // done so that annotations can be supplied in bytecode form only. But since no
- // AST is available for these types it creates the danger that some functional
- // class (not just an annotation) gets filled in but is missing AST. This would
- // cause later compiler stages to fail.
- //
- // Library compilation needs to ignore this check since it is expected behavior
- // for the source being compiled in a library to make references to other types
- // which are only available as bytecode coming out of dependency libraries.
- //
- // But if the referenced bytecode did not come from a dependency library but
- // instead was free floating in the classpath, then there is no guarantee that
- // AST for it was ever seen and translated to JS anywhere in the dependency tree.
- // This would be a mistake.
- //
- // TODO(stalcup): add a more specific check for library compiles such that binary
- // types can be referenced but only if they are an Annotation or if the binary
- // type comes from a dependency library.
- BinaryTypeReferenceRestrictionsChecker.check(cud);
- }
+ // GWT drives JDT in a way that allows missing references in the source to be
+ // resolved to precompiled bytecode on disk (see INameEnvironment). This is
+ // done so that annotations can be supplied in bytecode form only. But since no
+ // AST is available for these types it creates the danger that some functional
+ // class (not just an annotation) gets filled in but is missing AST. This would
+ // cause later compiler stages to fail.
+ BinaryTypeReferenceRestrictionsChecker.check(cud);
if (!cud.compilationResult().hasErrors()) {
// The above checks might have recorded errors; so we need to check here again.
@@ -395,7 +379,7 @@
}
// Index errors so that error chains can be reported.
- CompilationProblemReporter.indexErrors(compilerContext.getLocalCompilationErrorsIndex(),
+ CompilationProblemReporter.indexErrors(compilerContext.getCompilationErrorsIndex(),
resultUnits);
// Report error chains and hints.
@@ -570,16 +554,9 @@
logger, compilerContext, builders, cachedUnits,
CompilerEventType.JDT_COMPILER_CSB_FROM_ORACLE);
- boolean compileMonolithic = compilerContext.shouldCompileMonolithic();
- TypeOracle typeOracle = null;
- CompilationUnitTypeOracleUpdater typeOracleUpdater = null;
- if (compileMonolithic) {
- typeOracle = new TypeOracle();
- typeOracleUpdater = new CompilationUnitTypeOracleUpdater(typeOracle);
- } else {
- typeOracle = new LibraryTypeOracle(compilerContext);
- typeOracleUpdater = ((LibraryTypeOracle) typeOracle).getTypeOracleUpdater();
- }
+ TypeOracle typeOracle = new TypeOracle();
+ CompilationUnitTypeOracleUpdater typeOracleUpdater =
+ new CompilationUnitTypeOracleUpdater(typeOracle);
CompilationState compilationState = new CompilationState(logger, compilerContext, typeOracle,
typeOracleUpdater, resultUnits, compileMoreLater);
diff --git a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
index 41fab9f..f14f014 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
@@ -451,11 +451,6 @@
return additionalProviderAnswer;
}
- NameEnvironmentAnswer libraryGroupAnswer = findTypeInLibraryGroup(internalName);
- if (libraryGroupAnswer != null) {
- return libraryGroupAnswer;
- }
-
// TODO(stalcup): Add verification that all classpath bytecode is for Annotations.
NameEnvironmentAnswer classPathAnswer = findTypeInClassPath(internalName);
if (classPathAnswer != null) {
@@ -490,26 +485,6 @@
return new NameEnvironmentAnswer(new Adapter(CompilationUnitBuilder.create(unit)), null);
}
- private NameEnvironmentAnswer findTypeInLibraryGroup(String internalName) {
- InputStream classFileStream =
- compilerContext.getLibraryGroup().getClassFileStream(internalName);
- if (classFileStream == null) {
- return null;
- }
-
- try {
- ClassFileReader classFileReader =
- ClassFileReader.read(classFileStream, internalName + ".class", true);
- return new NameEnvironmentAnswer(classFileReader, null);
- } catch (IOException e) {
- return null;
- } catch (ClassFormatException e) {
- return null;
- } finally {
- Utility.close(classFileStream);
- }
- }
-
private NameEnvironmentAnswer findTypeInClassPath(String internalName) {
URL resource = getClassLoader().getResource(internalName + ".class");
if (resource == null) {
diff --git a/dev/core/src/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdater.java b/dev/core/src/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdater.java
deleted file mode 100644
index 425a424..0000000
--- a/dev/core/src/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdater.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.javac;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.javac.typemodel.JRealClassType;
-import com.google.gwt.dev.javac.typemodel.TypeOracle;
-import com.google.gwt.dev.util.Name.InternalName;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-
-/**
- * Lazily builds or rebuilds a {@link com.google.gwt.core.ext.typeinfo.TypeOracle} from a set of
- * compilation units and a LibraryGroup.
- */
-public class LibraryCompilationUnitTypeOracleUpdater extends CompilationUnitTypeOracleUpdater {
-
- private CompilerContext compilerContext;
- private TypeOracleBuildContext context;
-
- public LibraryCompilationUnitTypeOracleUpdater(TypeOracle typeOracle,
- CompilerContext compilerContext) {
- super(typeOracle);
- this.compilerContext = compilerContext;
- }
-
- /**
- * Lazily returns the type corresponding to the given internal name.
- */
- @Override
- protected JRealClassType findByInternalName(String internalName) {
- if (super.findByInternalName(internalName) == null) {
- CompilationUnit compilationUnit = compilerContext.getLibraryGroup()
- .getCompilationUnitByTypeSourceName(InternalName.toSourceName(internalName));
- if (compilationUnit != null) {
- compilerContext.getUnitCache().add(compilationUnit);
- // We're already executing within the recursive call tree resulting from a addNewUnits()
- // invocation. That invocation will index all new types at the end. We avoid indexing here
- // for both performance and correctness (to avoid indexing types that have already arrived
- // in the TypeOracle.recentTypes list but which have not yet finished resolving).
- addNewTypesDontIndex(TreeLogger.NULL, Lists.newArrayList(compilationUnit));
- }
- }
- return super.findByInternalName(internalName);
- }
-
- @Override
- protected void finish() {
- super.finish();
- // Reset the build context after each externally invoked addNewTypes() invocation.
- context = null;
- }
-
- /**
- * Returns the same build context across multiple (recursive) addNewTypesDontIndex() invocations.
- */
- @Override
- protected TypeOracleBuildContext getContext(MethodArgNamesLookup argsLookup) {
- if (context == null) {
- context = new TypeOracleBuildContext(argsLookup);
- } else {
- context.allMethodArgs.mergeFrom(argsLookup);
- }
- return context;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/javac/typemodel/LibraryTypeOracle.java b/dev/core/src/com/google/gwt/dev/javac/typemodel/LibraryTypeOracle.java
deleted file mode 100644
index 098b77f..0000000
--- a/dev/core/src/com/google/gwt/dev/javac/typemodel/LibraryTypeOracle.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.javac.typemodel;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.CompilationUnitTypeOracleUpdater;
-import com.google.gwt.dev.javac.LibraryCompilationUnitTypeOracleUpdater;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-
-/**
- * Provides lazy type-related information about a set of types from libraries.
- */
-public class LibraryTypeOracle extends TypeOracle {
-
- /**
- * An exception indicating that the Library flavor of TypeOracle does not support the requested
- * behavior. This runtime exception can be thrown during LibraryTypeOracle access (from
- * Generators) and is expected to be caught in the incremental Generator execution framework in
- * RuleGenerateWith. It would be an error for this exception to ever become visible beyond those
- * bounds.
- */
- public static class UnsupportedTypeOracleAccess extends RuntimeException {
-
- public UnsupportedTypeOracleAccess(String message) {
- super(message);
- }
- }
-
- private boolean allLoaded;
- private CompilerContext compilerContext;
- private CompilationUnitTypeOracleUpdater typeOracleUpdater;
-
- public LibraryTypeOracle(CompilerContext compilerContext) {
- this.compilerContext = compilerContext;
- this.typeOracleUpdater = new LibraryCompilationUnitTypeOracleUpdater(this, compilerContext);
- }
-
- @Override
- public synchronized void ensureAllLoaded() {
- if (allLoaded) {
- return;
- }
- allLoaded = true;
-
- for (String typeName : compilerContext.getLibraryGroup().getCompilationUnitTypeSourceNames()) {
- findType(typeName);
- }
- for (String superSourceTypeName :
- compilerContext.getLibraryGroup().getSuperSourceCompilationUnitTypeSourceNames()) {
- findType(superSourceTypeName);
- }
- }
-
- @Override
- public JPackage findPackage(String pkgName) {
- throw new UnsupportedTypeOracleAccess("Packages can't be lazily loaded from libraries.");
- }
-
- @Override
- public JClassType findType(String typeSourceName) {
- // If the type is already loaded.
- JClassType type = super.findType(typeSourceName);
- if (type != null) {
- // Then return it.
- return type;
- }
-
- // Otherwise load its compilation unit.
- CompilationUnit compilationUnit =
- compilerContext.getLibraryGroup().getCompilationUnitByTypeSourceName(typeSourceName);
- if (compilationUnit != null) {
- // Cache the compilation unit.
- compilerContext.getUnitCache().add(compilationUnit);
- // Transform the compilation unit into a type.
- typeOracleUpdater.addNewUnits(TreeLogger.NULL, Lists.newArrayList(compilationUnit));
- // And return it.
- return super.findType(typeSourceName);
- }
-
- return null;
- }
-
- @Override
- public JClassType findType(String pkgName, String shortName) {
- return findType(pkgName + "." + shortName);
- }
-
- @Override
- public JPackage getPackage(String pkgName) throws NotFoundException {
- throw new UnsupportedTypeOracleAccess("Packages can't be lazily loaded from libraries.");
- }
-
- @Override
- public JPackage[] getPackages() {
- throw new UnsupportedTypeOracleAccess("Packages can't be lazily loaded from libraries.");
- }
-
- public CompilationUnitTypeOracleUpdater getTypeOracleUpdater() {
- return typeOracleUpdater;
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaScriptCompiler.java
index eb1ea7e..aa647ec 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaScriptCompiler.java
@@ -31,10 +31,8 @@
RebindPermutationOracle rpo, String[] declEntryPts, String[] additionalRootTypes,
boolean singlePermutation, PrecompilationMetricsArtifact precompilationMetrics)
throws UnableToCompleteException {
- boolean compileMonolithic = compilerContext.shouldCompileMonolithic();
- JavaToJavaScriptCompiler javaToJavaScriptCompiler = compileMonolithic
- ? new MonolithicJavaToJavaScriptCompiler(logger, compilerContext)
- : new LibraryJavaToJavaScriptCompiler(logger, compilerContext);
+ JavaToJavaScriptCompiler javaToJavaScriptCompiler =
+ new MonolithicJavaToJavaScriptCompiler(logger, compilerContext);
return javaToJavaScriptCompiler.precompile(
rpo, declEntryPts, additionalRootTypes, singlePermutation, precompilationMetrics);
}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
index e43d275..3fd155b 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
@@ -39,7 +39,6 @@
import com.google.gwt.dev.PrecompileTaskOptions;
import com.google.gwt.dev.cfg.ConfigProps;
import com.google.gwt.dev.cfg.EntryMethodHolderGenerator;
-import com.google.gwt.dev.cfg.LibraryGroup.CollidingCompilationUnitException;
import com.google.gwt.dev.cfg.ModuleDef;
import com.google.gwt.dev.cfg.PermProps;
import com.google.gwt.dev.javac.CompilationProblemReporter;
@@ -91,7 +90,6 @@
import com.google.gwt.dev.jjs.impl.ResolveRuntimeTypeReferences.TypeMapper;
import com.google.gwt.dev.jjs.impl.SameParameterValueOptimizer;
import com.google.gwt.dev.jjs.impl.SourceInfoCorrelator;
-import com.google.gwt.dev.jjs.impl.TypeRefDepsChecker;
import com.google.gwt.dev.jjs.impl.TypeReferencesRecorder;
import com.google.gwt.dev.jjs.impl.TypeTightener;
import com.google.gwt.dev.jjs.impl.UnifyAst;
@@ -140,7 +138,6 @@
import com.google.gwt.dev.util.Memory;
import com.google.gwt.dev.util.Name.SourceName;
import com.google.gwt.dev.util.Pair;
-import com.google.gwt.dev.util.TinyCompileSummary;
import com.google.gwt.dev.util.Util;
import com.google.gwt.dev.util.arg.OptionOptimize;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
@@ -251,9 +248,7 @@
new TreeMap<StandardSymbolData, JsName>(new SymbolData.ClassIdentComparator());
// TODO(stalcup): hide metrics gathering in a callback or subclass
- if (compilerContext.shouldCompileMonolithic() && logger.isLoggable(TreeLogger.INFO)) {
- logger.log(TreeLogger.INFO, "Compiling permutation " + permutationId + "...");
- }
+ logger.log(TreeLogger.INFO, "Compiling permutation " + permutationId + "...");
printPermutationTrace(permutation);
// (2) Transform unresolved Java AST to resolved Java AST
@@ -963,8 +958,6 @@
// TODO(stalcup): hide metrics gathering in a callback or subclass
JsniRestrictionChecker.exec(logger, jprogram);
- TypeRefDepsChecker.exec(logger, jprogram, module, options.warnMissingDeps(),
- options.getMissingDepsFile());
logTypeOracleMetrics(precompilationMetrics, compilationState);
Memory.maybeDumpMemory("AstOnly");
AstDumper.maybeDumpAST(jprogram);
@@ -1048,18 +1041,6 @@
SourceInfoCorrelator.exec(jprogram);
}
- // Gathers simple metrics that can highlight overly-large modules in an incremental compile.
- TinyCompileSummary tinyCompileSummary = compilerContext.getTinyCompileSummary();
- tinyCompileSummary.setTypesForGeneratorsCount(
- rpo.getGeneratorContext().getTypeOracle().getTypes().length);
- tinyCompileSummary.setTypesForAstCount(jprogram.getDeclaredTypes().size());
- tinyCompileSummary.setStaticSourceFilesCount(compilationState.getStaticSourceCount());
- tinyCompileSummary.setGeneratedSourceFilesCount(compilationState.getGeneratedSourceCount());
- tinyCompileSummary.setCachedStaticSourceFilesCount(
- compilationState.getCachedStaticSourceCount());
- tinyCompileSummary.setCachedGeneratedSourceFilesCount(
- compilationState.getCachedGeneratedSourceCount());
-
// Free up memory.
rpo.clear();
Set<String> deletedTypeNames = options.isIncrementalCompileEnabled()
@@ -1289,13 +1270,7 @@
Event event = SpeedTracerLogger.start(CompilerEventType.UNIFY_AST);
- UnifyAst unifyAst;
- try {
- unifyAst = new UnifyAst(logger, compilerContext, jprogram, jsProgram, rpo);
- } catch (CollidingCompilationUnitException e) {
- logger.log(TreeLogger.ERROR, e.getMessage());
- throw new UnableToCompleteException();
- }
+ UnifyAst unifyAst = new UnifyAst(logger, compilerContext, jprogram, jsProgram, rpo);
// Makes JProgram aware of these types so they can be accessed via index.
unifyAst.addRootTypes(allRootTypes);
// Must synthesize entryPoint.onModuleLoad() calls because some EntryPoint classes are
diff --git a/dev/core/src/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompiler.java
deleted file mode 100644
index 47a2792..0000000
--- a/dev/core/src/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompiler.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * 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.jjs;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.impl.ResourceGeneratorUtilImpl;
-import com.google.gwt.core.ext.linker.PrecompilationMetricsArtifact;
-import com.google.gwt.core.ext.linker.SyntheticArtifact;
-import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.Permutation;
-import com.google.gwt.dev.cfg.BindingProperty;
-import com.google.gwt.dev.cfg.ConfigProps;
-import com.google.gwt.dev.cfg.ConfigurationProperty;
-import com.google.gwt.dev.cfg.PermProps;
-import com.google.gwt.dev.cfg.PropertyProviderRegistratorGenerator;
-import com.google.gwt.dev.cfg.Rule;
-import com.google.gwt.dev.cfg.RuleGenerateWith;
-import com.google.gwt.dev.cfg.RuleReplaceWithFallback;
-import com.google.gwt.dev.cfg.RuntimeRebindRegistratorGenerator;
-import com.google.gwt.dev.cfg.RuntimeRebindRuleGenerator;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.CompiledClass;
-import com.google.gwt.dev.javac.StandardGeneratorContext;
-import com.google.gwt.dev.jdt.RebindPermutationOracle;
-import com.google.gwt.dev.jjs.ast.JDeclaredType;
-import com.google.gwt.dev.jjs.ast.JProgram;
-import com.google.gwt.dev.jjs.impl.ArrayNormalizer;
-import com.google.gwt.dev.jjs.impl.CatchBlockNormalizer;
-import com.google.gwt.dev.jjs.impl.ComputeExhaustiveCastabilityInformation;
-import com.google.gwt.dev.jjs.impl.ComputeInstantiatedJsoInterfaces;
-import com.google.gwt.dev.jjs.impl.Devirtualizer;
-import com.google.gwt.dev.jjs.impl.EqualityNormalizer;
-import com.google.gwt.dev.jjs.impl.ImplementCastsAndTypeChecks;
-import com.google.gwt.dev.jjs.impl.JavaToJavaScriptMap;
-import com.google.gwt.dev.jjs.impl.LongCastNormalizer;
-import com.google.gwt.dev.jjs.impl.LongEmulationNormalizer;
-import com.google.gwt.dev.jjs.impl.PostOptimizationCompoundAssignmentNormalizer;
-import com.google.gwt.dev.jjs.impl.ReboundTypeRecorder;
-import com.google.gwt.dev.jjs.impl.ReplaceGetClassOverrides;
-import com.google.gwt.dev.jjs.impl.ResolveRuntimeTypeReferences;
-import com.google.gwt.dev.jjs.impl.ResolveRuntimeTypeReferences.StringTypeMapper;
-import com.google.gwt.dev.jjs.impl.ResolveRuntimeTypeReferences.TypeMapper;
-import com.google.gwt.dev.jjs.impl.ResolveRuntimeTypeReferences.TypeOrder;
-import com.google.gwt.dev.jjs.impl.TypeCoercionNormalizer;
-import com.google.gwt.dev.jjs.impl.codesplitter.MultipleDependencyGraphRecorder;
-import com.google.gwt.dev.js.JsNamer.IllegalNameException;
-import com.google.gwt.dev.js.JsVerboseNamer;
-import com.google.gwt.dev.js.ast.JsLiteral;
-import com.google.gwt.dev.js.ast.JsName;
-import com.google.gwt.dev.js.ast.JsNode;
-import com.google.gwt.dev.resource.impl.FileResource;
-import com.google.gwt.dev.util.Name.BinaryName;
-import com.google.gwt.dev.util.Pair;
-import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedSet;
-
-/**
- * Compiles the Java <code>JProgram</code> representation into its corresponding library Js source.
- * <br />
- *
- * Care is taken to ensure that the resulting Js source will be valid for runtime linking, such as
- * performing only local optimizations, running only local stages of Generators, gathering and
- * enqueueing rebind information for runtime usage and outputting Js source with names that are
- * stable across libraries.
- */
-public class LibraryJavaToJavaScriptCompiler extends JavaToJavaScriptCompiler {
-
- @VisibleForTesting
- class LibraryPermutationCompiler extends PermutationCompiler {
-
- public LibraryPermutationCompiler(Permutation permutation) {
- super(permutation);
- }
-
- @Override
- protected TypeMapper<?> normalizeSemantics() {
- Devirtualizer.exec(jprogram);
- CatchBlockNormalizer.exec(jprogram);
- PostOptimizationCompoundAssignmentNormalizer.exec(jprogram);
- LongCastNormalizer.exec(jprogram);
- LongEmulationNormalizer.exec(jprogram);
- TypeCoercionNormalizer.exec(jprogram);
- ComputeExhaustiveCastabilityInformation.exec(jprogram);
- ComputeInstantiatedJsoInterfaces.exec(jprogram);
- ImplementCastsAndTypeChecks.exec(jprogram, options.isCastCheckingDisabled(), false);
- ArrayNormalizer.exec(jprogram, options.isCastCheckingDisabled());
- EqualityNormalizer.exec(jprogram);
- TypeMapper<?> typeMapper = new StringTypeMapper();
- ResolveRuntimeTypeReferences.exec(jprogram, typeMapper, TypeOrder.NONE);
- return typeMapper;
- }
-
- @Override
- protected void optimizeJava() {
- }
-
- @Override
- protected void optimizeJs(Set<JsNode> inlinableJsFunctions)throws InterruptedException {
- }
-
- @Override
- protected void postNormalizationOptimizeJava() {
- // Does not prune types and functions when constructing a library since final runtime usage
- // can not be predicted.
- ReplaceGetClassOverrides.exec(jprogram);
- }
-
- @Override
- protected Map<JsName, JsLiteral> runDetailedNamer(ConfigProps config)
- throws IllegalNameException {
- JsVerboseNamer.exec(jsProgram, config);
- return null;
- }
-
- @Override
- protected Pair<SyntheticArtifact, MultipleDependencyGraphRecorder> splitJsIntoFragments(
- PermProps props, int permutationId, JavaToJavaScriptMap jjsmap) {
- // Local control flow knowledge and the local list of RunAsyncs is not enough information to
- // be able to accurately split program fragments.
- return Pair.<SyntheticArtifact, MultipleDependencyGraphRecorder>create(null, null);
- }
- }
-
- @VisibleForTesting
- class LibraryPrecompiler extends Precompiler {
-
- public LibraryPrecompiler(RebindPermutationOracle rpo, String[] entryPointTypeNames) {
- super(rpo, entryPointTypeNames);
- }
-
- @Override
- protected void beforeUnifyAst(Set<String> allRootTypes)
- throws UnableToCompleteException {
- runGeneratorsToFixedPoint(rpo);
-
- Set<JDeclaredType> reboundTypes = gatherReboundTypes(rpo);
- buildFallbackRuntimeRebindRules(reboundTypes);
- buildSimpleRuntimeRebindRules(module.getRules());
-
- buildRuntimeRebindRegistrator(allRootTypes);
- buildPropertyProviderRegistrator(allRootTypes, module.getProperties().getBindingProperties(),
- module.getProperties().getConfigurationProperties());
- }
-
- @Override
- protected void checkEntryPoints(String[] additionalRootTypes) {
- // Library construction does not need to care whether their are or are not any entry points.
- }
-
- @Override
- protected void createJProgram(CompilerContext compilerContext) {
- jprogram = new JProgram(compilerContext.getMinimalRebuildCache(), false);
- }
-
- @VisibleForTesting
- protected JDeclaredType ensureFullTypeLoaded(JDeclaredType type) {
- return findTypeBySourceName(BinaryName.toSourceName(type.getName()));
- }
-
- private JDeclaredType findType(List<JDeclaredType> types, String typeName) {
- for (JDeclaredType type : types) {
- if (BinaryName.toSourceName(type.getName()).equals(typeName)) {
- return type;
- }
- }
- return null;
- }
-
- // TODO(stalcup): performs much the same load logic as UnifyAst.findType(), but is necessary
- // much earlier. Replace with some single mechanism. This logic only exists to support the
- // ability to analyze whether a type is instantiable prior to creating a rebind rule that
- // attempts to instantiate it. It would be very nice to not be duplicating an instantiability
- // check here that JDT already does quite well during its own compile.
- private JDeclaredType findTypeBySourceName(String sourceTypeName) {
- Map<String, CompiledClass> compiledClassesBySourceName =
- rpo.getCompilationState().getClassFileMapBySource();
- // If the type is available as compiled source.
- if (compiledClassesBySourceName.containsKey(sourceTypeName)) {
- // Get and return it.
- CompiledClass compiledClass = compiledClassesBySourceName.get(sourceTypeName);
- return findType(compiledClass.getUnit().getTypes(), sourceTypeName);
- }
- // Otherwise if the type is available in a loaded library.
- CompilationUnit compilationUnit =
- compilerContext.getLibraryGroup().getCompilationUnitByTypeSourceName(sourceTypeName);
- if (compilationUnit != null) {
- // Get and return it.
- compilerContext.getUnitCache().add(compilationUnit);
- return findType(compilationUnit.getTypes(), sourceTypeName);
- }
- return null;
- }
-
- @VisibleForTesting
- protected Set<JDeclaredType> gatherReboundTypes(RebindPermutationOracle rpo) {
- Collection<CompilationUnit> compilationUnits =
- rpo.getCompilationState().getCompilationUnits();
- Set<JDeclaredType> reboundTypes = Sets.newLinkedHashSet();
- // EntryPoints are rebound but the rebind synthetisation has not occurred yet. Gather them as
- // rebound types anyway.
- for (String entryPointTypeName : entryPointTypeNames) {
- reboundTypes.add(findTypeBySourceName(entryPointTypeName));
- }
-
- for (CompilationUnit compilationUnit : compilationUnits) {
- for (JDeclaredType type : compilationUnit.getTypes()) {
- ReboundTypeRecorder.exec(type, reboundTypes);
- }
- }
- return reboundTypes;
- }
-
- protected StandardGeneratorContext getGeneratorContext() {
- return rpo.getGeneratorContext();
- }
-
- @VisibleForTesting
- protected Set<String> getTypeNames(Set<JDeclaredType> types) {
- Set<String> typeNames = Sets.newHashSet();
- for (JDeclaredType type : types) {
- typeNames.add(type.getName());
- }
- return typeNames;
- }
-
- /**
- * Runs a particular generator on the provided set of rebound types. Takes care to guard against
- * duplicate work during reruns as generation approaches a fixed point.
- */
- @VisibleForTesting
- protected void runGenerator(RuleGenerateWith generatorRule, Set<String> reboundTypeNames)
- throws UnableToCompleteException {
- for (String reboundTypeName : reboundTypeNames) {
- generatorRule.generate(logger, module.getProperties(), getGeneratorContext(),
- BinaryName.toSourceName(reboundTypeName));
- }
- }
-
- @VisibleForTesting
- protected void runGeneratorsToFixedPoint(RebindPermutationOracle rpo)
- throws UnableToCompleteException {
- boolean fixedPoint;
- do {
- compilerContext.getLibraryWriter()
- .markReboundTypesProcessed(getTypeNames(gatherReboundTypes(rpo)));
-
- fixedPoint = runGenerators();
- } while (!fixedPoint);
-
- // This is a horribly dirty hack to work around the fact that CssResourceGenerator uses a
- // completely nonstandard resource creation and caching mechanism that ignores the
- // GeneratorContext infrastructure. It and GenerateCssAst need to be fixed.
- for (Entry<String, File> entry :
- ResourceGeneratorUtilImpl.getGeneratedFilesByName().entrySet()) {
- String resourcePath = entry.getKey();
- File resourceFile = entry.getValue();
- compilerContext.getLibraryWriter()
- .addBuildResource(FileResource.of(resourcePath, resourceFile));
- }
- }
-
- @VisibleForTesting
- void buildFallbackRuntimeRebindRules(Set<JDeclaredType> reboundTypes)
- throws UnableToCompleteException {
- // Create fallback rebinds.
- for (JDeclaredType reboundType : reboundTypes) {
- // It's possible for module A to declare rebind rules about types that were defined in
- // module B. While processing module A these types might not be loaded in their full form,
- // which would cause their instantiability analysis to be wrong. So, make sure the full
- // version of each such type has been loaded.
- // TODO(stalcup) find a way to check if a type is instantiable without having to have the
- // full version of the type loaded.
- reboundType = ensureFullTypeLoaded(reboundType);
- if (!reboundType.isInstantiable()) {
- continue;
- }
- RuleReplaceWithFallback fallbackRule =
- new RuleReplaceWithFallback(reboundType.getName().replace("$", "."));
- fallbackRule.generateRuntimeRebindClasses(logger, module, getGeneratorContext());
- }
- }
-
- @VisibleForTesting
- void buildPropertyProviderRegistrator(Set<String> allRootTypes,
- SortedSet<BindingProperty> bindingProperties,
- SortedSet<ConfigurationProperty> configurationProperties) throws UnableToCompleteException {
- PropertyProviderRegistratorGenerator propertyProviderRegistratorGenerator =
- new PropertyProviderRegistratorGenerator(bindingProperties, configurationProperties);
- StandardGeneratorContext generatorContext = getGeneratorContext();
- // Name based on module canonical name, to avoid collisions resulting from multiple modules
- // with the same rename.
- String propertyProviderRegistratorTypeName = propertyProviderRegistratorGenerator.generate(
- logger, generatorContext, module.getCanonicalName());
- // Ensures that unification traverses and keeps the class.
- allRootTypes.add(propertyProviderRegistratorTypeName);
- // Ensures that JProgram knows to index this class's methods so that later bootstrap
- // construction code is able to locate the FooPropertyProviderRegistrator.register() function.
- jprogram.addIndexedTypeName(propertyProviderRegistratorTypeName);
- jprogram.setPropertyProviderRegistratorTypeSourceName(propertyProviderRegistratorTypeName);
- generatorContext.finish(logger);
- }
-
- @VisibleForTesting
- void buildRuntimeRebindRegistrator(Set<String> allRootTypes) throws UnableToCompleteException {
- // If no runtime rebind rules were created for this library.
- if (RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME.isEmpty()) {
- // Then there's no need to generate a registrator to attach them to the runtime registry.
- return;
- }
-
- RuntimeRebindRegistratorGenerator runtimeRebindRegistratorGenerator =
- new RuntimeRebindRegistratorGenerator();
- StandardGeneratorContext generatorContext = getGeneratorContext();
- // Name based on module canonical name, to avoid collisions resulting from multiple modules
- // with the same rename.
- String runtimeRebindRegistratorTypeName = runtimeRebindRegistratorGenerator.generate(logger,
- generatorContext, module.getCanonicalName());
- // Ensures that unification traverses and keeps the class.
- allRootTypes.add(runtimeRebindRegistratorTypeName);
- // Ensures that JProgram knows to index this class's methods so that later bootstrap
- // construction code is able to locate the FooRuntimeRebindRegistrator.register() function.
- jprogram.addIndexedTypeName(runtimeRebindRegistratorTypeName);
- jprogram.setRuntimeRebindRegistratorTypeName(runtimeRebindRegistratorTypeName);
- generatorContext.finish(logger);
- }
-
- @VisibleForTesting
- void buildSimpleRuntimeRebindRules(Deque<Rule> rules) throws UnableToCompleteException {
- // Create rebinders for rules specified in the module.
- Iterator<Rule> iterator = rules.iterator();
- while (iterator.hasNext()) {
- Rule rule = iterator.next();
- if (rule instanceof RuleGenerateWith) {
- continue;
- }
- rule.generateRuntimeRebindClasses(logger, module, getGeneratorContext());
- }
- }
-
- /**
- * Figures out which generators should run based on the current state and runs them. Generator
- * execution can create new opportunities for further generator execution so this function
- * should be invoked repeatedly till a fixed point is reached.<br />
- *
- * Returns whether a fixed point was reached.
- */
- private boolean runGenerators() throws UnableToCompleteException {
- boolean globalCompile = compilerContext.getOptions().shouldLink();
- Set<Rule> generatorRules = Sets.newHashSet(module.getGeneratorRules());
-
- TreeLogger branch = logger.branch(TreeLogger.SPAM, "running generators");
-
- for (Rule rule : generatorRules) {
- RuleGenerateWith generatorRule = (RuleGenerateWith) rule;
- String generatorName = generatorRule.getName();
-
- if (generatorRule.contentDependsOnTypes() && !globalCompile) {
- // Type unstable generators can only be safely run in the global phase.
- // TODO(stalcup): modify type unstable generators such that their output is no longer
- // unstable.
- branch.log(TreeLogger.SPAM,
- "skipping generator " + generatorName + " since it can only run in the global phase");
- continue;
- }
-
- if (!generatorRule.relevantPropertiesAreFinal(module.getProperties(),
- options.getFinalProperties())) {
- // Some property(s) that this generator cares about have not yet reached their final
- // value. Running the generator now would be wasted effort as it would just need to be run
- // again later anyway.
- branch.log(TreeLogger.SPAM, "skipping generator " + generatorName
- + " since properties it cares about have not reached their final values.");
- continue;
- }
-
- Set<String> reboundTypes = Sets.newHashSet(compilerContext.getReboundTypeSourceNames());
- Set<String> processedReboundTypeSourceNamesForGenerator =
- compilerContext.getProcessedReboundTypeSourceNames(generatorName);
-
- Set<String> unprocessedReboundTypeSourceNames = Sets.newHashSet(reboundTypes);
- unprocessedReboundTypeSourceNames.removeAll(processedReboundTypeSourceNamesForGenerator);
- if (unprocessedReboundTypeSourceNames.isEmpty()) {
- // All the requested rebound types have already been processed by this generator.
- branch.log(TreeLogger.SPAM, "skipping generator " + generatorName
- + " since it has already processed all requested rebound types.");
- continue;
- }
-
- branch.log(TreeLogger.SPAM, "running generator " + generatorName + " on "
- + unprocessedReboundTypeSourceNames.size() + " not yet processed rebound types");
- runGenerator(generatorRule, unprocessedReboundTypeSourceNames);
-
- // Marks the previously unprocessed types as processed.
- for (String unprocessedReboundTypeSourceName : unprocessedReboundTypeSourceNames) {
- compilerContext.getLibraryWriter().markReboundTypeProcessed(
- unprocessedReboundTypeSourceName, generatorName);
- }
- }
-
- // If there is output.
- if (getGeneratorContext().isDirty()) {
- // Compile and assimilate it.
- getGeneratorContext().finish(logger);
- return false;
- }
-
- return true;
- }
- }
-
- /**
- * Constructs a JavaToJavaScriptCompiler with customizations for compiling independent libraries.
- */
- public LibraryJavaToJavaScriptCompiler(TreeLogger logger, CompilerContext compilerContext) {
- super(logger, compilerContext);
- }
-
- @Override
- public PermutationResult compilePermutation(UnifiedAst unifiedAst, Permutation permutation)
- throws UnableToCompleteException {
- return new LibraryPermutationCompiler(permutation).compilePermutation(unifiedAst);
- }
-
- @Override
- public UnifiedAst precompile(RebindPermutationOracle rpo, String[] entryPointTypeNames,
- String[] additionalRootTypes, boolean singlePermutation,
- PrecompilationMetricsArtifact precompilationMetrics) throws UnableToCompleteException {
- return new LibraryPrecompiler(rpo, entryPointTypeNames).precompile(
- additionalRootTypes, singlePermutation, precompilationMetrics);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java b/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
index 87ca2b1..e21cafd 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
@@ -125,10 +125,8 @@
public PermutationResult compilePermutation(
TreeLogger logger, CompilerContext compilerContext, Permutation permutation)
throws UnableToCompleteException {
- boolean compileMonolithic = compilerContext.shouldCompileMonolithic();
- JavaToJavaScriptCompiler javaToJavaScriptCompiler = compileMonolithic
- ? new MonolithicJavaToJavaScriptCompiler(logger, compilerContext)
- : new LibraryJavaToJavaScriptCompiler(logger, compilerContext);
+ JavaToJavaScriptCompiler javaToJavaScriptCompiler =
+ new MonolithicJavaToJavaScriptCompiler(logger, compilerContext);
return javaToJavaScriptCompiler.compilePermutation(this, permutation);
}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
index ed26448..ee57b04 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
@@ -1930,7 +1930,7 @@
SortedSet<JDeclaredType> reachableClasses =
computeReachableTypes(METHODS_PROVIDED_BY_PREAMBLE);
- assert !modularCompile || checkCoreModulePreambleComplete(program,
+ assert !compilePerFile || checkCoreModulePreambleComplete(program,
program.getTypeClassLiteralHolder().getClinitMethod());
Set<JDeclaredType> orderedPreambleClasses = Sets.newLinkedHashSet();
@@ -3363,8 +3363,6 @@
private final TreeLogger logger;
- private final boolean modularCompile;
-
private final boolean compilePerFile;
/**
@@ -3423,10 +3421,8 @@
compilerContext.getOptions().getOptimizationLevel() > OptionOptimize.OPTIMIZE_LEVEL_DRAFT;
this.methodNameMappingMode = compilerContext.getOptions().getMethodNameDisplayMode();
assert methodNameMappingMode != null;
- this.hasWholeWorldKnowledge = compilerContext.shouldCompileMonolithic()
- && !compilerContext.getOptions().isIncrementalCompileEnabled();
+ this.hasWholeWorldKnowledge = !compilerContext.getOptions().isIncrementalCompileEnabled();
this.compilePerFile = compilerContext.getOptions().isIncrementalCompileEnabled();
- this.modularCompile = !compilerContext.shouldCompileMonolithic();
this.symbolTable = symbolTable;
this.typeMapper = typeMapper;
this.props = props;
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ReboundTypeRecorder.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ReboundTypeRecorder.java
deleted file mode 100644
index 8d97cc4..0000000
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ReboundTypeRecorder.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2013 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.jjs.impl;
-
-import com.google.gwt.dev.jjs.InternalCompilerException;
-import com.google.gwt.dev.jjs.ast.Context;
-import com.google.gwt.dev.jjs.ast.JClassLiteral;
-import com.google.gwt.dev.jjs.ast.JDeclaredType;
-import com.google.gwt.dev.jjs.ast.JExpression;
-import com.google.gwt.dev.jjs.ast.JMethod;
-import com.google.gwt.dev.jjs.ast.JMethodCall;
-import com.google.gwt.dev.jjs.ast.JNode;
-import com.google.gwt.dev.jjs.ast.JType;
-import com.google.gwt.dev.jjs.ast.JVisitor;
-import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
-import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
-import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.util.Set;
-
-/**
- * Records all rebinds in an AST that has not been unified.
- */
-public class ReboundTypeRecorder {
-
- private class ReboundTypeVisitor extends JVisitor {
- @Override
- public void endVisit(JMethodCall x, Context ctx) {
- JMethod method = x.getTarget();
- String methodSignature = method.getEnclosingType().getName() + '.' + method.getSignature();
- if (GWT_CREATE_METHOD_SIGNATURES.contains(methodSignature)) {
- JExpression classLiteralArgument = x.getArgs().get(0);
- if (!(classLiteralArgument instanceof JClassLiteral)) {
- throw new InternalCompilerException(
- "Only class literals may be used as arguments to GWT.create()");
- }
- JClassLiteral classLiteral = (JClassLiteral) classLiteralArgument;
-
- JType requestType = classLiteral.getRefType();
- if (!(requestType instanceof JDeclaredType)) {
- throw new InternalCompilerException(
- "Only classes and interfaces may be used as arguments to GWT.create()");
- }
-
- reboundTypes.add((JDeclaredType) requestType);
- }
- }
- }
-
- private static final Set<String> GWT_CREATE_METHOD_SIGNATURES =
- Sets.newHashSet(UnifyAst.GWT_CREATE, UnifyAst.OLD_GWT_CREATE);
-
- /**
- * Walks the AST from the provided node and records seen rebound types into the provided
- * reboundTypes set.
- */
- public static void exec(JNode node, Set<JDeclaredType> reboundTypes) {
- Event recordRebindsEvent = SpeedTracerLogger.start(CompilerEventType.RECORD_REBINDS);
- new ReboundTypeRecorder(node, reboundTypes).execImpl();
- recordRebindsEvent.end();
- }
-
- private final JNode node;
- private final Set<JDeclaredType> reboundTypes;
-
- private ReboundTypeRecorder(JNode node, Set<JDeclaredType> reboundTypes) {
- this.node = node;
- this.reboundTypes = reboundTypes;
- }
-
- private void execImpl() {
- new ReboundTypeVisitor().accept(node);
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRefDepsChecker.java b/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRefDepsChecker.java
deleted file mode 100644
index d10b815..0000000
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRefDepsChecker.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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.jjs.impl;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.cfg.DepsInfoProvider;
-import com.google.gwt.dev.jjs.ast.Context;
-import com.google.gwt.dev.jjs.ast.JCastOperation;
-import com.google.gwt.dev.jjs.ast.JClassLiteral;
-import com.google.gwt.dev.jjs.ast.JDeclaredType;
-import com.google.gwt.dev.jjs.ast.JField;
-import com.google.gwt.dev.jjs.ast.JFieldRef;
-import com.google.gwt.dev.jjs.ast.JInstanceOf;
-import com.google.gwt.dev.jjs.ast.JMethod;
-import com.google.gwt.dev.jjs.ast.JMethodCall;
-import com.google.gwt.dev.jjs.ast.JProgram;
-import com.google.gwt.dev.jjs.ast.JType;
-import com.google.gwt.dev.jjs.ast.JValueLiteral;
-import com.google.gwt.dev.jjs.ast.JVariable;
-import com.google.gwt.dev.jjs.ast.JVisitor;
-import com.google.gwt.dev.jjs.ast.js.JsniFieldRef;
-import com.google.gwt.dev.jjs.ast.js.JsniMethodRef;
-import com.google.gwt.thirdparty.guava.common.annotations.VisibleForTesting;
-import com.google.gwt.thirdparty.guava.common.base.Function;
-import com.google.gwt.thirdparty.guava.common.base.Joiner;
-import com.google.gwt.thirdparty.guava.common.base.Objects;
-import com.google.gwt.thirdparty.guava.common.collect.Collections2;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A Java AST visitor that verifies that "Type A"->"Type B" references are enabled by matching "Type
- * A Module"->"Type B Module" inherits.
- */
-public class TypeRefDepsChecker extends JVisitor {
-
- /**
- * A Tuple of 'from' and 'to' type source names.
- */
- private static class TypeRef {
- private String fromTypeSourceName;
- private String toTypeSourceName;
-
- public TypeRef(String fromTypeSourceName, String toTypeSourceName) {
- this.fromTypeSourceName = fromTypeSourceName;
- this.toTypeSourceName = toTypeSourceName;
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof TypeRef) {
- TypeRef that = (TypeRef) object;
- return Objects.equal(this.fromTypeSourceName, that.fromTypeSourceName)
- && Objects.equal(this.toTypeSourceName, that.toTypeSourceName);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(fromTypeSourceName, toTypeSourceName);
- }
- }
-
- public static void exec(TreeLogger logger, JProgram program, DepsInfoProvider depsInfoProvider,
- boolean warnMissingDeps, File missingDepsFile) {
- if (!warnMissingDeps && missingDepsFile == null) {
- return;
- }
-
- new TypeRefDepsChecker(logger, program, depsInfoProvider, warnMissingDeps, missingDepsFile)
- .execImpl();
- }
-
- private static JDeclaredType getOuterMostType(JDeclaredType type) {
- while (type.getEnclosingType() != null) {
- type = type.getEnclosingType();
- }
- return type;
- }
-
- private final DepsInfoProvider depsInfoProvider;
- private String fromTypeSourceName;
- private final TreeLogger logger;
- private final File missingDepsFile;
- private final Function<String, String> moduleNameToModuleFile = new Function<String, String>() {
- @Override
- public String apply(String moduleName) {
- return depsInfoProvider.getGwtXmlFilePath(moduleName);
- }
- };
- private final JProgram program;
- private final Set<TypeRef> recordedTypeRefs = new HashSet<TypeRef>();
- private final boolean warnMissingDeps;
-
- public TypeRefDepsChecker(TreeLogger logger, JProgram program, DepsInfoProvider depsInfoProvider,
- boolean warnMissingDeps, File missingDepsFile) {
- this.logger = logger;
- this.program = program;
- this.depsInfoProvider = depsInfoProvider;
- this.warnMissingDeps = warnMissingDeps;
- this.missingDepsFile = missingDepsFile;
- }
-
- @Override
- public void endVisit(JCastOperation x, Context ctx) {
- // Gather (Foo) casts.
- maybeRecordTypeRef(x.getCastType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JClassLiteral x, Context ctx) {
- // Gather Foo.class literal references.
- maybeRecordTypeRef(x.getRefType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JFieldRef x, Context ctx) {
- // Gather Foo.someField static references.
- processJFieldRef(x);
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JInstanceOf x, Context ctx) {
- // Gather instanceof Foo references.
- maybeRecordTypeRef(x.getTestType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JMethod x, Context ctx) {
- // Gather return types of method definitions.
- maybeRecordTypeRef(x.getType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JMethodCall x, Context ctx) {
- // Gather Foo.doSomething() static method calls.
- processMethodCall(x);
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JsniFieldRef x, Context ctx) {
- // Gather Foo.someField static references.
- processJFieldRef(x);
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JsniMethodRef x, Context ctx) {
- // Gather Foo.doSomething() static method calls.
- processMethodCall(x);
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JValueLiteral x, Context ctx) {
- // Gather types whose constructor function is effectively called in value literal definitions.
- maybeRecordTypeRef(x.getType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public void endVisit(JVariable x, Context ctx) {
- // Gather declared types of local variables, class fields and method parameters.
- maybeRecordTypeRef(x.getType());
- super.endVisit(x, ctx);
- }
-
- @Override
- public boolean visit(JDeclaredType x, Context ctx) {
- fromTypeSourceName = getOuterMostType(x).getName();
-
- // Gather superclass and implemented interface types.
- maybeRecordTypeRef(x.getSuperClass());
- maybeRecordTypeRefs(x.getImplements());
- return super.visit(x, ctx);
- }
-
- @VisibleForTesting
- boolean maybeRecordTypeRef(String fromTypeSourceName, String toTypeSourceName) {
- return recordedTypeRefs.add(new TypeRef(fromTypeSourceName, toTypeSourceName));
- }
-
- /**
- * Verifies that no Type->Type references exceed the bounds of Module->Module dependencies.
- * <p>
- * In actuality both the "from" and "to" Types can be provided by multiple modules. Each "from"
- * module is considered valid if its set of transitive deps modules contains at least one of the
- * multiple "to" modules.
- */
- @VisibleForTesting
- void verifyTypeRefsInModules() {
- Set<String> examinedModuleRefs = new HashSet<String>();
-
- PrintStream missingDepsStream = null;
- if (missingDepsFile != null) {
- try {
- missingDepsStream = new PrintStream(missingDepsFile);
- } catch (FileNotFoundException e) {
- logger.log(TreeLogger.WARN, "Failed to open missing deps file " + missingDepsFile);
- }
- }
-
- for (TypeRef recordedTypeRef : recordedTypeRefs) {
- // Figure out where each type came from.
- Collection<String> fromModuleNames =
- depsInfoProvider.getSourceModuleNames(recordedTypeRef.fromTypeSourceName);
- List<String> toModuleNames = Lists.newArrayList(
- depsInfoProvider.getSourceModuleNames(recordedTypeRef.toTypeSourceName));
- Collections.sort(toModuleNames);
-
- // Types created by Generators do not currently have a known source module.
- if (fromModuleNames.isEmpty() || toModuleNames.isEmpty()) {
- continue;
- }
-
- for (String fromModuleName : fromModuleNames) {
- // Only examine each unique module dep one time.
- String moduleRef = fromModuleName + ":" + toModuleNames;
- if (examinedModuleRefs.contains(moduleRef)) {
- continue;
- }
- examinedModuleRefs.add(moduleRef);
- // If both files are from the same module then the reference is obviously legal.
- if (toModuleNames.contains(fromModuleName)) {
- continue;
- }
- // If the toType is supplied by at least one module that is in the set of transitive dep
- // modules of the module that provided the fromType then the reference is legal.
- if (!Collections.disjoint(depsInfoProvider.getTransitiveDepModuleNames(fromModuleName),
- toModuleNames)) {
- continue;
- }
-
- if (warnMissingDeps) {
- logger.log(TreeLogger.WARN, String.format(
- "Type '%s' wants to reference type '%s' but can't because module '%s' "
- + "has no dependency (neither direct nor transitive) on '%s'.",
- recordedTypeRef.fromTypeSourceName, recordedTypeRef.toTypeSourceName, fromModuleName,
- Joiner.on("|").join(toModuleNames)));
- }
- if (missingDepsStream != null) {
- missingDepsStream.printf("%s\t%s\t%s\t%s\t%s\n", fromModuleName,
- depsInfoProvider.getGwtXmlFilePath(fromModuleName),
- Joiner.on("|").join(toModuleNames),
- Joiner.on("|").join(Collections2.transform(toModuleNames, moduleNameToModuleFile)),
- "Type '" + recordedTypeRef.fromTypeSourceName + "' wants to reference type '"
- + recordedTypeRef.toTypeSourceName + "'.");
- }
- }
- }
-
- if (missingDepsStream != null) {
- missingDepsStream.close();
- }
- }
-
- private void execImpl() {
- accept(program);
- verifyTypeRefsInModules();
- }
-
- private void maybeRecordTypeRef(JType toPossiblyNestedType) {
- if (toPossiblyNestedType instanceof JDeclaredType) {
- JDeclaredType toType = getOuterMostType((JDeclaredType) toPossiblyNestedType);
- maybeRecordTypeRef(fromTypeSourceName, toType.getName());
- }
- }
-
- private void maybeRecordTypeRefs(List<? extends JDeclaredType> toTypes) {
- for (JDeclaredType toType : toTypes) {
- maybeRecordTypeRef(toType);
- }
- }
-
- private void processJFieldRef(JFieldRef x) {
- if (x.getTarget() instanceof JField) {
- JField field = (JField) x.getTarget();
- if (field.isStatic()) {
- maybeRecordTypeRef(field.getEnclosingType());
- }
- }
- }
-
- private void processMethodCall(JMethodCall x) {
- if (x.getTarget().isStatic()) {
- maybeRecordTypeRef(x.getTarget().getEnclosingType());
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java b/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
index 179caf8..c8f6d5b 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
@@ -87,7 +87,6 @@
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.gwt.thirdparty.guava.common.collect.Sets.SetView;
@@ -147,8 +146,6 @@
protected abstract boolean hasCompileErrors(String typeName);
- protected abstract CompilationUnit getCompilationUnitFromLibrary(String typeName);
-
protected abstract void logErrorTrace(TreeLogger branch, Type logLevel, String sourceName);
protected CompilationUnit getCompilationUnitFromSource(String typeName) {
@@ -160,10 +157,6 @@
return resolvedType;
}
- protected boolean libraryCompilationUnitIsAvailable(String typeName) {
- return getCompilationUnitFromLibrary(typeName) != null;
- }
-
protected boolean resolvedTypeIsAvailable(String typeName) {
return program.getFromTypeMap(typeName) != null;
}
@@ -438,31 +431,18 @@
return null;
}
- if (compilerContext.shouldCompileMonolithic()) {
- Event event = SpeedTracerLogger.start(CompilerEventType.VISIT_GWT_CREATE,
- "argument",
- classLiteral.getRefType().getName(),
- "caller",
- gwtCreateCall.getSourceInfo().getFileName());
- try {
- return createStaticRebindExpression(gwtCreateCall, classLiteral);
- } finally {
- event.end();
- }
- } else {
- return createRuntimeRebindExpression(gwtCreateCall, classLiteral);
+ Event event = SpeedTracerLogger.start(CompilerEventType.VISIT_GWT_CREATE,
+ "argument",
+ classLiteral.getRefType().getName(),
+ "caller",
+ gwtCreateCall.getSourceInfo().getFileName());
+ try {
+ return createStaticRebindExpression(gwtCreateCall, classLiteral);
+ } finally {
+ event.end();
}
}
- private JExpression createRuntimeRebindExpression(JMethodCall gwtCreateCall,
- JClassLiteral classLiteral) {
- // RuntimeRebinder.createInstance(classLiteral);
- JMethod runtimeCreateInstanceMethod =
- program.getIndexedMethod("RuntimeRebinder.createInstance");
- return new JMethodCall(gwtCreateCall.getSourceInfo(), null, runtimeCreateInstanceMethod,
- classLiteral);
- }
-
private JExpression createStaticRebindExpression(JMethodCall gwtCreateCall,
JClassLiteral classLiteral) {
JDeclaredType type = (JDeclaredType) classLiteral.getRefType();
@@ -708,14 +688,12 @@
private MinimalRebuildCache minimalRebuildCache;
private boolean incrementalCompile;
- private boolean isLibraryCompile;
private boolean jsInteropEnabled;
private final List<String> rootTypeSourceNames = new ArrayList<String>();
public UnifyAst(TreeLogger logger, CompilerContext compilerContext, JProgram program,
JsProgram jsProgram, RebindPermutationOracle rpo) {
this.incrementalCompile = compilerContext.getOptions().isIncrementalCompileEnabled();
- this.isLibraryCompile = !compilerContext.shouldCompileMonolithic();
this.jsInteropEnabled = program.typeOracle.isJsInteropEnabled();
this.logger = logger;
@@ -765,11 +743,8 @@
/**
* Translates and stitches (unifies) type ASTs into one connected graph.<br />
*
- * For normal monolithic compiles only types reachable from entry points are traversed. This
- * speeds, saves memory trims unreferenced elements.<br />
- *
- * Library compiles traverse all types that were supplied as source in the compilation state and
- * no elements are pruned.
+ * Only types reachable from entry points are traversed. This speeds, saves memory trims
+ * unreferenced elements.
*/
public void exec() throws UnableToCompleteException {
// Trace execution from entry points and resolve references.
@@ -810,22 +785,6 @@
if (incrementalCompile) {
fullFlowIntoRemainingStaleTypes();
- } else if (isLibraryCompile) {
- // Trace execution from all types supplied as source and resolve references.
- Set<String> internalNames = ImmutableSet.copyOf(compiledClassesByInternalName.keySet());
- for (String internalName : internalNames) {
- // Library compilation needs to walk all local types so that they can be in the library
- // output. If one of these types contains errors but is not locally reachable the
- // compilation might still be a success. So ignore errors in this set of types.
- boolean reportErrors = false;
- JDeclaredType type =
- internalFindType(internalName, internalNameBasedTypeLocator, reportErrors);
- if (type == null) {
- continue;
- }
-
- fullFlowIntoType(type);
- }
}
/*
@@ -891,9 +850,7 @@
computeOverrides();
// Post-stitching clean-ups.
- if (compilerContext.shouldCompileMonolithic()) {
- pruneDeadFieldsAndMethods();
- }
+ pruneDeadFieldsAndMethods();
if (errorsFound) {
// Already logged.
throw new UnableToCompleteException();
@@ -955,32 +912,6 @@
}
}
- private void assimilateLibraryUnit(CompilationUnit referencedCompilationUnit,
- boolean reportErrors) {
- if (referencedCompilationUnit.isError()) {
- if (failedUnits.add(referencedCompilationUnit) && reportErrors) {
- CompilationProblemReporter.logErrorTrace(logger, TreeLogger.ERROR,
- compilerContext, referencedCompilationUnit.getTypeName(), true);
- errorsFound = true;
- }
- return;
- }
-
- compilerContext.getUnitCache().add(referencedCompilationUnit);
- compilationState.addReferencedCompilationUnits(logger, Lists.create(referencedCompilationUnit));
- // Record the types in the JProgram but do *not* flow into them and resolve their internal
- // references. There's no need since they're not part of this library. It's important to call
- // getTypes() only ONCE since each call returns a new copy.
- List<JDeclaredType> types = referencedCompilationUnit.getTypes();
- for (JDeclaredType referenceOnlyType : types) {
- program.addType(referenceOnlyType);
- program.addReferenceOnlyType(referenceOnlyType);
- }
- for (JDeclaredType referenceOnlyType : types) {
- resolveType(referenceOnlyType);
- }
- }
-
private void assimilateSourceUnit(CompilationUnit unit, boolean reportErrors) {
if (unit.isError()) {
if (failedUnits.add(unit) && reportErrors) {
@@ -1314,13 +1245,8 @@
private void initializeNameBasedLocators() {
sourceNameBasedTypeLocator = new NameBasedTypeLocator(compiledClassesBySourceName) {
@Override
- protected CompilationUnit getCompilationUnitFromLibrary(String sourceName) {
- return compilerContext.getLibraryGroup().getCompilationUnitByTypeSourceName(sourceName);
- }
-
- @Override
protected boolean hasCompileErrors(String sourceName) {
- return compilerContext.getGlobalCompilationErrorsIndex().hasCompileErrors(sourceName);
+ return compilerContext.getCompilationErrorsIndex().hasCompileErrors(sourceName);
}
@Override
@@ -1331,11 +1257,6 @@
};
binaryNameBasedTypeLocator = new NameBasedTypeLocator(null) {
@Override
- protected CompilationUnit getCompilationUnitFromLibrary(String binaryName) {
- return compilerContext.getLibraryGroup().getCompilationUnitByTypeBinaryName(binaryName);
- }
-
- @Override
protected CompilationUnit getCompilationUnitFromSource(String binaryName) {
// There is no binary name based index for this, use the internal name based one instead.
return internalNameBasedTypeLocator.getCompilationUnitFromSource(
@@ -1363,13 +1284,6 @@
};
internalNameBasedTypeLocator = new NameBasedTypeLocator(compiledClassesByInternalName) {
@Override
- protected CompilationUnit getCompilationUnitFromLibrary(String internalName) {
- // There is no internal name based index for this, use the binary name based one instead.
- return binaryNameBasedTypeLocator.getCompilationUnitFromLibrary(
- InternalName.toBinaryName(internalName));
- }
-
- @Override
protected JDeclaredType getResolvedType(String internalName) {
// There is no internal name based index for this, use the binary name based one instead.
return binaryNameBasedTypeLocator.getResolvedType(InternalName.toBinaryName(internalName));
@@ -1597,30 +1511,17 @@
return nameBasedTypeLocator.getResolvedType(typeName);
}
- if (!compilerContext.shouldCompileMonolithic() &&
- nameBasedTypeLocator.libraryCompilationUnitIsAvailable(typeName)) {
- // Resolve from a library in modular compiles.
- assimilateLibraryUnit(nameBasedTypeLocator.getCompilationUnitFromLibrary(typeName),
- reportErrors);
- return nameBasedTypeLocator.getResolvedType(typeName);
- }
-
if (reportErrors) {
- // The type could not be resolved as source nor from a library; report the appropriate error.
+ // The type could not be resolved as source; report the appropriate error.
if (nameBasedTypeLocator.hasCompileErrors(typeName)) {
TreeLogger branch = logger.branch(TreeLogger.ERROR, String.format(
- "Type %s could not be referenced because it previously failed to "
- + "compile with errors:", typeName));
- nameBasedTypeLocator.logErrorTrace(branch, TreeLogger.ERROR, typeName);
- } else if (compilerContext.shouldCompileMonolithic()) {
- logger.log(TreeLogger.ERROR, String.format(
- "Could not find %s in types compiled from source. Is the source glob too strict?",
- typeName));
- } else {
- logger.log(TreeLogger.ERROR, String.format(
- "Could not find %s in types compiled from source or in provided dependency libraries. "
- + "Either the source file was unavailable or there is a missing dependency.",
- typeName));
+ "Type %s could not be referenced because it previously failed to "
+ + "compile with errors:", typeName));
+ nameBasedTypeLocator.logErrorTrace(branch, TreeLogger.ERROR, typeName);
+ } else {
+ logger.log(TreeLogger.ERROR, String.format(
+ "Could not find %s in types compiled from source. Is the source glob too strict?",
+ typeName));
}
errorsFound = true;
}
diff --git a/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java b/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
index 5edd773..4b030c0 100644
--- a/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
+++ b/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
@@ -24,10 +24,8 @@
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
import com.google.gwt.dev.util.msg.Message0;
import com.google.gwt.dev.util.msg.Message1String;
-import com.google.gwt.thirdparty.guava.common.base.Joiner;
import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
import com.google.gwt.thirdparty.guava.common.collect.MapMaker;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.gwt.thirdparty.guava.common.io.Files;
@@ -169,8 +167,6 @@
private SetMultimap<String, String> sourceModulesByTypeSourceName =
HashMultimap.create();
- private Map<String, String> overlapWarningsByModuleSet = Maps.newHashMap();
-
public static void clearCache() {
classPathCache.clear();
}
@@ -249,16 +245,6 @@
}
/**
- * Print overlapping include warnings that accumulated during resource
- * scanning. Prints only one entry per set of overlapping modules.
- */
- public void printOverlappingModuleIncludeWarnings(TreeLogger logger) {
- for (String overlapWarning : overlapWarningsByModuleSet.values()) {
- logger.log(TreeLogger.WARN, overlapWarning);
- }
- }
-
- /**
* Scans the associated paths to recompute the available resources.
*
* @param logger status and error details are written here
@@ -284,7 +270,6 @@
new ResourceDescription(resource, resourceResolution.getPathPrefix());
String resourcePath = resourceDescription.resource.getPath();
maybeRecordTypeForModule(resourceResolution, resourcePath);
- maybeRecordOverlapWarning(resourceResolution, resourcePath);
// In case of collision.
if (resourceDescriptionsByPath.containsKey(resourcePath)) {
@@ -329,26 +314,6 @@
return resourcePath.replace(".java", "").replace("/", ".");
}
- private void maybeRecordOverlapWarning(ResourceResolution resourceResolution,
- String resourcePath) {
- // If PathPrefix->Module associations are inaccurate because PathPrefixes have been merged.
- if (pathPrefixSet.mergePathPrefixes()) {
- // Then don't record any overlap warnings since they won't be accurate;
- return;
- }
-
- if (resourceResolution.getSourceModuleNames().size() > 1) {
- if (!overlapWarningsByModuleSet.containsKey(
- resourceResolution.getSourceModuleNames().toString())) {
- overlapWarningsByModuleSet.put(
- resourceResolution.getSourceModuleNames().toString(), String.format(
- "Resource %s is included by multiple modules (%s).",
- resourcePath, Joiner.on(", ").join(
- resourceResolution.getSourceModuleNames())));
- }
- }
- }
-
private static void addAllClassPathEntries(TreeLogger logger, ResourceLoader loader,
List<ClassPathEntry> classPath) {
// URL is expensive in collections, so we use URI instead
@@ -444,7 +409,6 @@
@Override
public void clear() {
sourceModulesByTypeSourceName.clear();
- overlapWarningsByModuleSet.clear();
exposedPathNames = Collections.emptySet();
exposedResourceMap = Collections.emptyMap();
exposedResources = Collections.emptySet();
diff --git a/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java b/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
index 07ea34b..5811ef3 100644
--- a/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
+++ b/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
@@ -34,21 +34,6 @@
private final ZipFile zipFile;
/**
- * Constructs a ZipFileResource from a zip file and entry name.<br />
- *
- * File path and modification time stamp parameters may seem redundant but are necessary because
- * ZipFile can not provide them.
- */
- public ZipFileResource(ZipFile zipFile, String filePath, long lastModified, String entryName) {
- assert filePath.startsWith("file:/");
- this.zipFile = zipFile;
- this.filePath = filePath;
- this.lastModified = lastModified;
- this.entryName = StringInterner.get().intern(entryName);
- this.pathParts = entryName.split("/");
- }
-
- /**
* Constructs a ZipFileResource from a jar class path entry and a zip entry name.<br />
*/
public ZipFileResource(ZipFileClassPathEntry classPathEntry, String entryName) {
diff --git a/dev/core/src/com/google/gwt/dev/util/TinyCompileSummary.java b/dev/core/src/com/google/gwt/dev/util/TinyCompileSummary.java
deleted file mode 100644
index e1a6e08..0000000
--- a/dev/core/src/com/google/gwt/dev/util/TinyCompileSummary.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.util;
-
-/**
- * A small set of compile metrics that should be used to warn incremental compile users when a
- * module is getting too large.
- */
-public class TinyCompileSummary {
-
- private int typesForGeneratorsCount;
- private int typesForAstCount;
- private int staticSourceFilesCount;
- private int generatedSourceFilesCount;
- private int cachedStaticSourceFilesCount;
- private int cachedGeneratedSourceFilesCount;
-
- public int getTypesForGeneratorsCount() {
- return typesForGeneratorsCount;
- }
-
- public void setTypesForGeneratorsCount(int typesForGeneratorsCount) {
- this.typesForGeneratorsCount = typesForGeneratorsCount;
- }
-
- public int getTypesForAstCount() {
- return typesForAstCount;
- }
-
- public void setTypesForAstCount(int typesForAstCount) {
- this.typesForAstCount = typesForAstCount;
- }
-
- public int getStaticSourceFilesCount() {
- return staticSourceFilesCount;
- }
-
- public void setStaticSourceFilesCount(int staticSourceFilesCount) {
- this.staticSourceFilesCount = staticSourceFilesCount;
- }
-
- public int getGeneratedSourceFilesCount() {
- return generatedSourceFilesCount;
- }
-
- public void setGeneratedSourceFilesCount(int generatedSourceFilesCount) {
- this.generatedSourceFilesCount = generatedSourceFilesCount;
- }
-
- public int getCachedStaticSourceFilesCount() {
- return cachedStaticSourceFilesCount;
- }
-
- public void setCachedStaticSourceFilesCount(int cachedStaticSourceFilesCount) {
- this.cachedStaticSourceFilesCount = cachedStaticSourceFilesCount;
- }
-
- public int getCachedGeneratedSourceFilesCount() {
- return cachedGeneratedSourceFilesCount;
- }
-
- public void setCachedGeneratedSourceFilesCount(int cachedGeneratedSourceFilesCount) {
- this.cachedGeneratedSourceFilesCount = cachedGeneratedSourceFilesCount;
- }
-}
\ No newline at end of file
diff --git a/dev/core/src/com/google/gwt/dev/util/ZipEntryBackedObject.java b/dev/core/src/com/google/gwt/dev/util/ZipEntryBackedObject.java
deleted file mode 100644
index f400771..0000000
--- a/dev/core/src/com/google/gwt/dev/util/ZipEntryBackedObject.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2013 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.util;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-
-/**
- * Represents an entry in a ZipFile that contains the serialized form of a Serializable object.
- *
- * @param <T> the type of object serialized into the zip entry
- */
-public class ZipEntryBackedObject<T extends Serializable> implements PersistenceBackedObject<T> {
-
- private final Class<T> clazz;
- private final String libraryPath;
- private final String resourcePath;
- private final ZipFile zipFile;
- private final ZipOutputStream zipOutputStream;
-
- /**
- * Constructs a read-only instance that will dynamically open the provided resourcePath in the
- * provided zipFile when requested.
- */
- public ZipEntryBackedObject(
- ZipFile zipFile, String libraryPath, String resourcePath, Class<T> clazz) {
- this.zipFile = zipFile;
- this.zipOutputStream = null;
- this.libraryPath = libraryPath;
- this.resourcePath = resourcePath;
- this.clazz = clazz;
- }
-
- /**
- * Constructs a write-only instance that will write a ZipEntry and bytes to the provided
- * zipOutputStream when requested.<br />
- *
- * Cannot be used to overwrite an already existing entry. Brand new zip files that are being built
- * manifest as empty files which can not be probed by ZipFile but which are legal for zip output
- * stream writing and ZipOutputStreams can't be probed about existing entries. So it is left up to
- * the user to avoid duplicate entry errors.
- */
- public ZipEntryBackedObject(
- ZipOutputStream zipOutputStream, String libraryPath, String resourcePath, Class<T> clazz) {
- this.zipFile = null;
- this.zipOutputStream = zipOutputStream;
- this.libraryPath = libraryPath;
- this.resourcePath = resourcePath;
- this.clazz = clazz;
- }
-
- @Override
- public boolean exists() {
- return zipFile.getEntry(resourcePath) != null;
- }
-
- @Override
- public String getPath() {
- return "jar:file:" + libraryPath + "!/" + resourcePath;
- }
-
- @Override
- public T newInstance(TreeLogger logger) throws UnableToCompleteException {
- if (zipOutputStream != null) {
- logger.log(TreeLogger.ERROR, "Tried to read from a write-only ZipEntryBackedObject");
- throw new UnableToCompleteException();
- }
- try {
- return Util.readStreamAsObject(zipFile.getInputStream(zipFile.getEntry(resourcePath)), clazz);
- } catch (ClassNotFoundException e) {
- logger.log(TreeLogger.ERROR, "Missing class definition", e);
- throw new UnableToCompleteException();
- } catch (IOException e) {
- logger.log(TreeLogger.ERROR, "Unable to instantiate object", e);
- throw new UnableToCompleteException();
- }
- }
-
- @Override
- public void set(TreeLogger logger, T object)
- throws IllegalStateException, UnableToCompleteException {
- assert clazz.isInstance(object);
- if (zipOutputStream == null) {
- logger.log(TreeLogger.ERROR, "Tried to write to a read-only ZipEntryBackedObject");
- throw new UnableToCompleteException();
- }
- try {
- // Inherently disallows duplicate entries.
- zipOutputStream.putNextEntry(new ZipEntry(resourcePath));
- Util.writeObjectToStream(zipOutputStream, object);
- } catch (IOException e) {
- logger.log(TreeLogger.ERROR, "Unable to write file: " + getPath(), e);
- throw new UnableToCompleteException();
- }
- }
-}
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLibraries.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLibraries.java
index 3d80e91..a8d43ca 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLibraries.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLibraries.java
@@ -24,6 +24,7 @@
/**
* An argument handler for providing a list of paths to input precompiled library files.
*/
+@Deprecated
public class ArgHandlerLibraries extends ArgHandlerString {
private final OptionLibraryPaths option;
@@ -34,7 +35,7 @@
@Override
public String getPurpose() {
- return "The path(s) to .gwtlib library file(s).";
+ return "DEPRECATED: The path(s) to .gwtlib library file(s).";
}
@Override
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLink.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLink.java
index 150434f..43d7941 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLink.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerLink.java
@@ -22,6 +22,7 @@
* Normally the separate compiler does not link and instead outputs just a precompiled library of
* the currently being compiled module.
*/
+@Deprecated
public class ArgHandlerLink extends ArgHandlerFlag {
private final OptionLink options;
@@ -42,7 +43,7 @@
@Override
public String getPurposeSnippet() {
- return "Link compiled output and supplied precompiled libraries "
+ return "DEPRECATED: Link compiled output and supplied precompiled libraries "
+ "into a usable result.";
}
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerMissingDepsFile.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerMissingDepsFile.java
index 57e158c..14f2a22 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerMissingDepsFile.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerMissingDepsFile.java
@@ -22,6 +22,7 @@
/**
* Optionally specifies a file into which detailed missing dependency information will be written.
*/
+@Deprecated
public final class ArgHandlerMissingDepsFile extends ArgHandlerFile {
private final OptionMissingDepsFile option;
@@ -32,7 +33,8 @@
@Override
public String getPurpose() {
- return "Specifies a file into which detailed missing dependency information will be written.";
+ return "DEPRECATED: Specifies a file into which detailed missing dependency "
+ + "information will be written.";
}
@Override
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOutputLibrary.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOutputLibrary.java
index fcccc7a..aac3002 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOutputLibrary.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOutputLibrary.java
@@ -19,6 +19,7 @@
/**
* An argument handler for specifying the path for the generated precompiled library file.
*/
+@Deprecated
public class ArgHandlerOutputLibrary extends ArgHandlerString {
private final OptionOutputLibraryPath option;
@@ -29,7 +30,7 @@
@Override
public String getPurpose() {
- return "The path into which the generated .gwtlib library will be written.";
+ return "DEPRECATED: The path into which the generated .gwtlib library will be written.";
}
@Override
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOverlappingSourceWarnings.java b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOverlappingSourceWarnings.java
index 5eecc22..6ca779f 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOverlappingSourceWarnings.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerOverlappingSourceWarnings.java
@@ -18,6 +18,7 @@
/**
* Toggles the display of overlapping source include warnings (during monolithic compiles).
*/
+@Deprecated
public final class ArgHandlerOverlappingSourceWarnings extends ArgHandlerFlag {
private final OptionWarnOverlappingSource optionWarnOverlappingSource;
@@ -38,7 +39,8 @@
@Override
public String getPurposeSnippet() {
- return "Whether to show warnings during monolithic compiles for overlapping source inclusion.";
+ return "DEPRECATED: Whether to show warnings during monolithic compiles for "
+ + "overlapping source inclusion.";
}
@Override
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionLibraryPaths.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionLibraryPaths.java
index c0d47c9..6502671 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/OptionLibraryPaths.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionLibraryPaths.java
@@ -18,6 +18,7 @@
/**
* Option providing the paths to the input libraries.
*/
+@Deprecated
public interface OptionLibraryPaths {
/**
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionMissingDepsFile.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionMissingDepsFile.java
index f121e03..aeebbb7 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/OptionMissingDepsFile.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionMissingDepsFile.java
@@ -23,6 +23,7 @@
* If provided the compiler will dump a record of missing dependencies to this file formatted like:
* <fromModuleName>\t<fromModuleUrl>\t<toModuleName>\t<toModuleUrl>\t<humanReadableWarning>
*/
+@Deprecated
public interface OptionMissingDepsFile {
/**
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionOutputLibraryPath.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionOutputLibraryPath.java
index 9eb0143..0d4721e 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/OptionOutputLibraryPath.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionOutputLibraryPath.java
@@ -16,6 +16,7 @@
/**
* Option providing the path for the output library.
*/
+@Deprecated
public interface OptionOutputLibraryPath {
/**
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnMissingDeps.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnMissingDeps.java
index d8c08f5..ba2a3fd 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnMissingDeps.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnMissingDeps.java
@@ -17,6 +17,7 @@
* Option to report warnings when modules are missing dependencies necessary to satisfy type
* references in their provided source.
*/
+@Deprecated
public interface OptionWarnMissingDeps {
/**
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnOverlappingSource.java b/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnOverlappingSource.java
index 7515ac8..206af60 100644
--- a/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnOverlappingSource.java
+++ b/dev/core/src/com/google/gwt/dev/util/arg/OptionWarnOverlappingSource.java
@@ -16,6 +16,7 @@
/**
* Option to turn on warnings for when more than one module includes the same source files.
*/
+@Deprecated
public interface OptionWarnOverlappingSource {
/**
diff --git a/dev/core/src/com/google/gwt/dev/util/transitiveclosure/TransitiveClosureSolver.java b/dev/core/src/com/google/gwt/dev/util/transitiveclosure/TransitiveClosureSolver.java
deleted file mode 100644
index 297c086..0000000
--- a/dev/core/src/com/google/gwt/dev/util/transitiveclosure/TransitiveClosureSolver.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.util.transitiveclosure;
-
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-
-/**
- * A transitive closure solver that lazily calculates reachability for a requested node by
- * recursively walking the tree and then performing a fixup pass on nodes that were seen to be
- * participating in cycles.
- *
- * @param <T> the graph node type.
- */
-public class TransitiveClosureSolver<T> {
-
- /**
- * Builds the reachability for a particular node.
- * <p>
- * Building requires a recursive walk and following fixup of partial views caused by cycles.
- * Temporary state is contained here to facilitate fixup.
- */
- private class ReachabilityBuilder {
-
- private boolean processed;
- private final Set<T> reachableNodes = Sets.newHashSet();
- private int sawPartialViewCount;
- private final Queue<ReachabilityBuilder> showedPartialViewToBuilders = Lists.newLinkedList();
-
- private void build(T node) {
- Collection<T> childNodes = childNodesByNode.get(node);
- reachableNodes.add(node);
- reachableNodes.addAll(childNodes);
-
- for (T childNode : childNodes) {
- ReachabilityBuilder childBuilder = getReachabilityBuilder(childNode);
-
- // If we're looking at the contents of builder before it is done with its own build. (Can
- // only happen when traversing cycles).
- if (!childBuilder.processed) {
- // Then remember that this partial view occurred so that it can be fixed up later.
- sawPartialViewCount++;
- childBuilder.showedPartialViewToBuilders.add(this);
- }
-
- reachableNodes.addAll(childBuilder.reachableNodes);
- }
-
- processed = true;
- maybeFixPartialViewers();
- }
-
- private boolean hasOthersToFix() {
- return !showedPartialViewToBuilders.isEmpty();
- }
-
- private void maybeFixPartialViewers() {
- if (!resultIsAccurate()) {
- return;
- }
-
- while (hasOthersToFix()) {
- ReachabilityBuilder builderWithPartialView = showedPartialViewToBuilders.remove();
-
- // Fix the partial view of me that had been previously shown to this other builder.
- builderWithPartialView.reachableNodes.addAll(reachableNodes);
- builderWithPartialView.sawPartialViewCount--;
-
- // This other builder might now be complete, give it a chance to cascade to fix up any other
- // builders that saw a partial view of it.
- builderWithPartialView.maybeFixPartialViewers();
- }
- }
-
- private boolean resultIsAccurate() {
- return sawPartialViewCount == 0;
- }
- }
-
- private final LinkedHashMultimap<T, T> childNodesByNode = LinkedHashMultimap.create();
- private final Map<T, ReachabilityBuilder> reachabilityBuildersByNode = Maps.newHashMap();
-
- public void addConnection(T node, T childNode) {
- childNodesByNode.put(node, childNode);
- }
-
- public Set<T> getReachableNodes(T node) {
- return getReachabilityBuilder(node).reachableNodes;
- }
-
- private ReachabilityBuilder getReachabilityBuilder(T node) {
- if (!reachabilityBuildersByNode.containsKey(node)) {
- ReachabilityBuilder reachabilityBuilder = new ReachabilityBuilder();
- // Store the builder (even before it's been expanded) to short-circuit circular dependencies.
- reachabilityBuildersByNode.put(node, reachabilityBuilder);
- reachabilityBuilder.build(node);
- return reachabilityBuilder;
- }
- return reachabilityBuildersByNode.get(node);
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/CompilerContextTest.java b/dev/core/test/com/google/gwt/dev/CompilerContextTest.java
deleted file mode 100644
index f9075f2..0000000
--- a/dev/core/test/com/google/gwt/dev/CompilerContextTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for CompilerContext.
- */
-public class CompilerContextTest extends TestCase {
-
- public void testDefaultLibraryGroup() {
- CompilerContext compilerContext = new CompilerContext();
-
- // Doesn't throw an NPE.
- assertFalse(compilerContext.getLibraryGroup().containsBuildResource("com/google/gwt/Foo.xml"));
-
- compilerContext = new CompilerContext.Builder().build();
-
- // Doesn't throw an NPE.
- assertFalse(compilerContext.getLibraryGroup().containsBuildResource("com/google/gwt/Foo.xml"));
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/IncrementalBuilderTest.java b/dev/core/test/com/google/gwt/dev/IncrementalBuilderTest.java
deleted file mode 100644
index 191c871..0000000
--- a/dev/core/test/com/google/gwt/dev/IncrementalBuilderTest.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.ModuleDefLoader;
-import com.google.gwt.dev.cfg.ResourceLoader;
-import com.google.gwt.dev.cfg.ResourceLoaders;
-import com.google.gwt.dev.util.UnitTestTreeLogger;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.io.Files;
-import com.google.gwt.thirdparty.guava.common.io.Resources;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * Test for {@link IncrementalBuilder}.
- */
-public class IncrementalBuilderTest extends TestCase {
-
- private static void assertBuildResult(String rootModuleName, boolean expectedBuildSuccess,
- String... expectedErrorMessages) throws MalformedURLException {
- UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
- for (String expectedErrorMessage : expectedErrorMessages) {
- loggerBuilder.expectError(expectedErrorMessage, null);
- }
- UnitTestTreeLogger testLogger = loggerBuilder.createLogger();
-
- IncrementalBuilder incrementalBuilder =
- createIncrementalBuilder(rootModuleName, createGwtClassPathResourceLoader());
- incrementalBuilder.clean();
-
- boolean actualBuildSuccess = incrementalBuilder.build(testLogger).isSuccess();
-
- assertEquals(expectedBuildSuccess, actualBuildSuccess);
- testLogger.assertLogEntriesContainExpected();
- }
-
- private static ResourceLoader createGwtClassPathResourceLoader() throws MalformedURLException {
- String gwtClassPathProperty = System.getProperty("gwt.cp");
- String[] gwtClassPathStrings = gwtClassPathProperty.split(";");
- final List<URL> gwtClassPathEntries = Lists.newArrayList();
- for (String gwtClassPathString : gwtClassPathStrings) {
- gwtClassPathEntries.add(new File(gwtClassPathString).toURI().toURL());
- }
- ResourceLoader gwtClassPathResourceLoader = new ResourceLoader() {
- @Override
- public List<URL> getClassPath() {
- return gwtClassPathEntries;
- }
-
- @Override
- public URL getResource(String resourceName) {
- return Thread.currentThread().getContextClassLoader().getResource(resourceName);
- }
- };
- return gwtClassPathResourceLoader;
- }
-
- private static ResourceLoader createGwtClassPathResourceLoaderWithMocks(
- String... mockResourceNames) throws FileNotFoundException, IOException {
- final ResourceLoader gwtClassPathResourceLoader = createGwtClassPathResourceLoader();
- File mockResourcesDirectory = Files.createTempDir();
-
- for (String mockResourceName : mockResourceNames) {
- File mockFooFile = new File(mockResourcesDirectory, mockResourceName);
- mockFooFile.getParentFile().mkdirs();
- URL realFooResource = gwtClassPathResourceLoader.getResource(mockResourceName);
- Resources.copy(realFooResource, new FileOutputStream(mockFooFile));
- }
-
- return ResourceLoaders.forPathAndFallback(Lists.newArrayList(mockResourcesDirectory),
- gwtClassPathResourceLoader);
- }
-
- private static IncrementalBuilder createIncrementalBuilder(String rootModuleName,
- ResourceLoader resourceLoader) {
- String warDir = Files.createTempDir().getAbsolutePath();
- String libDir = "/tmp/gwt/lib";
- String genDir = "/tmp/gwt/gen";
- IncrementalBuilder incrementalBuilder =
- new IncrementalBuilder(rootModuleName, warDir, libDir, genDir, resourceLoader);
- return incrementalBuilder;
- }
-
- public void testBuildRebuildEditRebuild() throws FileNotFoundException, IOException {
- // Setup logging expectations for a full compile with no caching.
- UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage("com.google.gwt.core.Core"),
- null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleBottom"), null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleMid"), null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop"), null);
- UnitTestTreeLogger testLogger = loggerBuilder.createLogger();
-
- // Prepare the compiler.
- ResourceLoader resourceLoader = createGwtClassPathResourceLoaderWithMocks(
- "com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java");
- IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop", resourceLoader);
- incrementalBuilder.clean();
-
- // Compile.
- boolean actualBuildSuccess = incrementalBuilder.build(testLogger).isSuccess();
-
- // Assert compile succeeded and was a full compile with no caching.
- assertEquals(true, actualBuildSuccess);
- testLogger.assertLogEntriesContainExpected();
-
- // Setup logging expectations for a fully cached compile.
- loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
- loggerBuilder.expectInfo(IncrementalBuilder.NO_FILES_HAVE_CHANGED, null);
- testLogger = loggerBuilder.createLogger();
-
- // Recompile without changes.
- actualBuildSuccess = incrementalBuilder.rebuild(testLogger).isSuccess();
-
- // Assert compile succeeded and was fully cached.
- assertEquals(true, actualBuildSuccess);
- testLogger.assertLogEntriesContainExpected();
-
- // Change modification date of the Foo.java seen by SimpleMid.gwt.xml
- File fooFile = new File(resourceLoader.getResource(
- "com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java").getPath());
- fooFile.setLastModified(System.currentTimeMillis() + 60 * 1000);
-
- // Setup logging expectations for partially cached recompile.
- loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.SPAM);
- loggerBuilder.expectSpam(
- BuildTarget.formatReusingCachedLibraryMessage("com.google.gwt.core.Core"), null);
- loggerBuilder.expectSpam(BuildTarget.formatReusingCachedLibraryMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleBottom"), null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleMid"), null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop"), null);
- testLogger = loggerBuilder.createLogger();
-
- // Recompile with changes.
- actualBuildSuccess = incrementalBuilder.rebuild(testLogger).isSuccess();
-
- // Assert compile succeeded and was partially cached.
- assertEquals(true, actualBuildSuccess);
- testLogger.assertLogEntriesContainExpected();
- }
-
- public void testCircularReference() throws MalformedURLException {
- List<String> circularModulePath = Arrays.asList(new String[] {
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CircularRoot",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CircularB <loop>",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CircularC",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CircularFilesetD <fileset>",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CircularB <loop>"});
- assertBuildResult("com.google.gwt.dev.testdata.incrementalbuildsystem.CircularRoot", false,
- IncrementalBuilder.formatCircularModulePathMessage(circularModulePath));
- }
-
- public void testContinuesAfterFirstFailure() throws MalformedURLException {
- UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailLeft"), null);
- loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailRight"), null);
- UnitTestTreeLogger testLogger = loggerBuilder.createLogger();
-
- IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailTop",
- createGwtClassPathResourceLoader());
- incrementalBuilder.clean();
-
- boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
- assertFalse(buildSucceeded);
- testLogger.assertLogEntriesContainExpected();
- }
-
- public void testDuplicateGeneratorOutput() throws MalformedURLException {
- String duplicateCompilationUnitError = LibraryGroup.formatDuplicateCompilationUnitMessage(
- "com.google.gwt.dev.Bar", "com.google.gwt.dev.testdata.incrementalbuildsystem.ParallelLeft",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.ParallelRight");
- assertBuildResult("com.google.gwt.dev.testdata.incrementalbuildsystem.ParallelRoot", false,
- duplicateCompilationUnitError);
- }
-
- public void testDuplicateSourceInclusion() throws MalformedURLException {
- String duplicateCompilationUnitError = LibraryGroup.formatDuplicateCompilationUnitMessage(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.Foo",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.DuplicateLeft",
- "com.google.gwt.dev.testdata.incrementalbuildsystem.DuplicateRight");
- assertBuildResult("com.google.gwt.dev.testdata.incrementalbuildsystem.DuplicateRoot", false,
- duplicateCompilationUnitError);
- }
-
- public void testEntryPointWithFailedCrossModuleTypeReference() throws MalformedURLException {
- String victimTypeName =
- "com.google.gwt.dev.testdata.incrementalbuildsystem.EntryPointCompileFails";
-
- UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.TRACE);
- loggerBuilder.expectTrace("Tracing compile failure path for type '" + victimTypeName + "'",
- null);
- loggerBuilder.expectError(Pattern.compile("Errors in '.*EntryPointCompileFails\\.java'"), null);
- loggerBuilder.expectError("Line 24: ImmediateCompileFails cannot be resolved to a type", null);
- loggerBuilder.expectError(Pattern.compile("Errors in '.*ImmediateCompileFails\\.java'"), null);
- loggerBuilder.expectError("Line 20: List cannot be resolved to a type", null);
- UnitTestTreeLogger testLogger = loggerBuilder.createLogger();
-
- IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.CrossModuleCompileFails",
- createGwtClassPathResourceLoader());
- incrementalBuilder.clean();
-
- boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
- assertFalse(buildSucceeded);
- testLogger.assertLogEntriesContainExpected();
- }
-
- public void testEntryPointWithFailedSameModuleTypeReference() throws MalformedURLException {
- String victimTypeName =
- "com.google.gwt.dev.testdata.incrementalbuildsystem.EntryPointCompileFails";
- String causeTypeName =
- "com.google.gwt.dev.testdata.incrementalbuildsystem.ImmediateCompileFails";
-
- UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
- loggerBuilder.setLowestLogLevel(TreeLogger.TRACE);
- loggerBuilder.expectTrace("Tracing compile failure path for type '" + victimTypeName + "'",
- null);
- loggerBuilder.expectError(Pattern.compile("Errors in '.*EntryPointCompileFails\\.java'"), null);
- loggerBuilder.expectError(causeTypeName + " cannot be resolved to a type", null);
- loggerBuilder.expectError(Pattern.compile("Errors in '.*ImmediateCompileFails\\.java'"), null);
- loggerBuilder.expectError("Line 20: List cannot be resolved to a type", null);
- UnitTestTreeLogger testLogger = loggerBuilder.createLogger();
-
- IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.SameModuleCompileFails",
- createGwtClassPathResourceLoader());
- incrementalBuilder.clean();
-
- boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
- assertFalse(buildSucceeded);
- testLogger.assertLogEntriesContainExpected();
- }
-
- public void testIgnoresCompileFailuresInUnreachableTypes() throws MalformedURLException {
- assertBuildResult(
- "com.google.gwt.dev.testdata.incrementalbuildsystem.UnreachableTypeCompileFails", true);
- }
-
- public void testUnableToFindModule() throws MalformedURLException {
- String unableToFindModuleMessage = ModuleDefLoader.formatUnableToFindModuleMessage(
- "com/google/gwt/dev/testdata/incrementalbuildsystem/NoSuchModule.gwt.xml");
- assertBuildResult("com.google.gwt.dev.testdata.incrementalbuildsystem.NoSuchModule", false,
- unableToFindModuleMessage);
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/CombinedResourceOracleTest.java b/dev/core/test/com/google/gwt/dev/cfg/CombinedResourceOracleTest.java
deleted file mode 100644
index 3555c82..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/CombinedResourceOracleTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.javac.testing.impl.JavaResourceBase;
-import com.google.gwt.dev.javac.testing.impl.MockResourceOracle;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import junit.framework.TestCase;
-
-import java.util.List;
-
-/**
- * Tests for CombinedResourceOracle.
- */
-public class CombinedResourceOracleTest extends TestCase {
-
- private static LibraryGroupBuildResourceOracle createLibraryGroupBuildResourceOracle() {
- // Create random libraries with some build resources.
- List<MockLibrary> libraries = MockLibrary.createRandomLibraryGraph(4, 1);
- libraries.get(0).getBuildResourcePaths().add("User.gwt.xml");
- libraries.get(0).getBuildResourcePaths().add("Tab.ui.xml");
- libraries.get(3).getBuildResourcePaths().add("Core.gwt.xml");
-
- // Wrap them up into a library group.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(libraries, true);
-
- // Put a resource oracle facade in front of that library group.
- return new LibraryGroupBuildResourceOracle(libraryGroup);
- }
-
- public void testRetrieveBuildResource() {
- // Create some independent resource oracles.
- LibraryGroupBuildResourceOracle buildResourceOracle = createLibraryGroupBuildResourceOracle();
- MockResourceOracle mockResourceOracle = new MockResourceOracle(JavaResourceBase.FOO);
-
- // Wrap them up in a combined resource oracle.
- CombinedResourceOracle combinedResourceOracle =
- new CombinedResourceOracle(buildResourceOracle, mockResourceOracle);
-
- // Verify that the combined resource oracle sees all of the build resource paths in the
- // libraries.
- assertEquals(Sets.newHashSet("test/Foo.java", "Tab.ui.xml", "User.gwt.xml", "Core.gwt.xml"),
- combinedResourceOracle.getPathNames());
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracleTest.java b/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracleTest.java
deleted file mode 100644
index b9f3e3f..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupBuildResourceOracleTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import junit.framework.TestCase;
-
-import java.util.List;
-
-/**
- * Tests for LibraryGroupBuildResourceOracle.
- */
-public class LibraryGroupBuildResourceOracleTest extends TestCase {
-
- public void testRetrieveBuildResource() {
- // Create random libraries with some build resources.
- List<MockLibrary> libraries = MockLibrary.createRandomLibraryGraph(4, 1);
- libraries.get(0).getBuildResourcePaths().add("User.gwt.xml");
- libraries.get(0).getBuildResourcePaths().add("Tab.ui.xml");
- libraries.get(3).getBuildResourcePaths().add("Core.gwt.xml");
-
- // Wrap them up into a library group.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(libraries, true);
-
- // Put a resource oracle facade in front of that library group.
- LibraryGroupBuildResourceOracle buildResourceOracle =
- new LibraryGroupBuildResourceOracle(libraryGroup);
-
- // Verify that the build resource oracle sees all of the build resource paths in the libraries.
- assertEquals(Sets.newHashSet("Tab.ui.xml", "User.gwt.xml", "Core.gwt.xml"),
- buildResourceOracle.getPathNames());
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupTest.java b/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupTest.java
deleted file mode 100644
index a314cb1..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/LibraryGroupTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.cfg.LibraryGroup.CollidingCompilationUnitException;
-import com.google.gwt.dev.cfg.LibraryGroup.DuplicateLibraryNameException;
-import com.google.gwt.dev.cfg.LibraryGroup.UnresolvedLibraryException;
-import com.google.gwt.dev.javac.CompiledClass;
-import com.google.gwt.dev.javac.MockCompilationUnit;
-import com.google.gwt.dev.javac.MockCompiledClass;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import junit.framework.TestCase;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Tests for LibraryGroup.
- */
-public class LibraryGroupTest extends TestCase {
-
- public void testCreateSubGroup() {
- LibraryGroup looseLibraryGroup = LibraryGroup.fromLibraries(Lists.<Library> newArrayList(
- new MockLibrary("LibraryA"), new MockLibrary("LibraryB"), new MockLibrary("LibraryC"),
- new MockLibrary("LibraryD")), true);
-
- assertEquals(4, looseLibraryGroup.getLibraries().size());
-
- LibraryGroup strictLibraryGroup =
- looseLibraryGroup.createSubgroup(Lists.newArrayList("LibraryA", "LibraryA", "LibraryC"));
-
- assertEquals(2, strictLibraryGroup.getLibraries().size());
- }
-
- public void testDuplicateLibraryNames() {
- // Create regular/super source libraries.
- MockLibrary fooLibrary = new MockLibrary("FooLibrary");
- MockLibrary alsoFooLibrary = new MockLibrary("FooLibrary");
-
- // Try but fail to stick them in a library group.
- try {
- LibraryGroup.fromLibraries(
- Lists.<Library> newArrayList(fooLibrary, alsoFooLibrary, fooLibrary), true);
- fail("library group construction sould have failed because of a library name collision.");
- } catch (DuplicateLibraryNameException e) {
- // Expected behavior.
- }
- }
-
- public void testGetCompilationUnitByTypeNamesSeesAllNested() {
- // Create a nested compilation units.
- MockCompilationUnit nestedTypeCompilationUnit =
- new MockCompilationUnit("com.google.gwt.user.Outer", "superblah") {
- @Override
- public Collection<CompiledClass> getCompiledClasses() {
- MockCompiledClass outerCompiledClass = new MockCompiledClass(null,
- "com/google/gwt/user/Outer", "com.google.gwt.user.Outer");
- MockCompiledClass innerCompiledClass = new MockCompiledClass(outerCompiledClass,
- "com/google/gwt/user/Outer$Inner", "com.google.gwt.user.Outer.Inner");
- return Lists.<CompiledClass> newArrayList(outerCompiledClass, innerCompiledClass);
- }
- };
-
- // Create the library.
- MockLibrary regularLibrary = new MockLibrary("LibraryA");
- regularLibrary.addCompilationUnit(nestedTypeCompilationUnit);
-
- // Stick it in a library group.
- LibraryGroup libraryGroup =
- LibraryGroup.fromLibraries(Lists.<Library> newArrayList(regularLibrary), true);
-
- // Shows that get by source or binary name works for nested types.
- assertEquals(nestedTypeCompilationUnit,
- libraryGroup.getCompilationUnitByTypeSourceName("com.google.gwt.user.Outer.Inner"));
- assertEquals(nestedTypeCompilationUnit,
- libraryGroup.getCompilationUnitByTypeBinaryName("com.google.gwt.user.Outer$Inner"));
- }
-
- public void testGetCompilationUnitTypeNamesSourceNamesSeesAll() {
- // Create regular/super source compilation units.
- MockCompilationUnit regularCompilationUnit =
- new MockCompilationUnit("com.google.gwt.Regular", "blah");
- MockCompilationUnit superSourceCompilationUnit =
- new MockCompilationUnit("com.google.gwt.Super", "blah");
-
- // Create regular/super source libraries.
- MockLibrary regularLibrary = new MockLibrary("LibraryA");
- regularLibrary.addCompilationUnit(regularCompilationUnit);
- MockLibrary superSourceLibrary = new MockLibrary("LibraryB");
- superSourceLibrary.addSuperSourceCompilationUnit(superSourceCompilationUnit);
-
- // Stick them in a library group.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(
- Lists.<Library> newArrayList(regularLibrary, superSourceLibrary), true);
-
- // Show that getCompilationUnitTypeSourceNames sees both kinds of compilation units.
- assertEquals(libraryGroup.getCompilationUnitTypeSourceNames(),
- Sets.newHashSet("com.google.gwt.Regular", "com.google.gwt.Super"));
- }
-
- public void testGetReboundTypeSourceNames() {
- // Build a large random acyclic library graph.
- List<MockLibrary> libraries = MockLibrary.createRandomLibraryGraph(210, 3);
- // Stick the libraries into a library group.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(libraries, true);
-
- // Insert a differently named rebound type into every library.
- Set<String> expectedReboundTypeSourceNames = Sets.newHashSet();
- for (Library library : libraries) {
- String reboundTypeSourceName = "Type" + System.identityHashCode(library);
- library.getReboundTypeSourceNames().add(reboundTypeSourceName);
- expectedReboundTypeSourceNames.add(reboundTypeSourceName);
- }
-
- // Show that the library group collects and returns them all.
- assertTrue(
- expectedReboundTypeSourceNames.equals(libraryGroup.getReboundTypeSourceNames()));
- }
-
- public void testLibraryLinkOrder() {
- // Build a large random acyclic library graph.
- List<MockLibrary> libraries = MockLibrary.createRandomLibraryGraph(210, 3);
-
- // Stick it in a LibraryGroup.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(libraries, true);
-
- // Verify that each parent comes after all of its children after the LibraryGroup has performed
- // link ordering.
- List<Library> linkOrderLibraries = libraryGroup.getLibraries();
- for (Library parentLibrary : libraries) {
- int parentLibraryIndex = linkOrderLibraries.indexOf(parentLibrary);
- assertTrue(parentLibraryIndex != -1);
- Collection<Library> childLibraries =
- libraryGroup.getLibraries(parentLibrary.getDependencyLibraryNames());
- for (Library childLibrary : childLibraries) {
- int childLibraryIndex = linkOrderLibraries.indexOf(childLibrary);
- assertTrue(childLibraryIndex != -1);
- assertTrue(childLibraryIndex < parentLibraryIndex);
- }
- }
- assertEquals(libraries.size(), linkOrderLibraries.size());
- }
-
- public static LibraryGroup buildVariedPropertyGeneratorLibraryGroup(
- Set<String> reboundTypeSourceNamesOne, Set<String> reboundTypeSourceNamesTwo) {
- // A root library that adds more legal user.agent and locale values but for which no generators
- // have been run.
- MockLibrary rootLibrary = new MockLibrary("RootLibrary");
- rootLibrary.getDependencyLibraryNames().addAll(
- Lists.newArrayList("SubLibrary1", "SubLibrary2"));
-
- // A library that adds legal user.agent values and has already run the UserAgentAsserter
- // generator.
- MockLibrary subLibrary1 = new MockLibrary("SubLibrary1");
- subLibrary1.getReboundTypeSourceNames().addAll(reboundTypeSourceNamesOne);
-
- // A library that adds legal locale values and has already run the LocaleMessageGenerator
- // generator.
- MockLibrary subLibrary2 = new MockLibrary("SubLibrary2");
- subLibrary2.getReboundTypeSourceNames().addAll(reboundTypeSourceNamesTwo);
-
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(
- Lists.<Library> newArrayList(rootLibrary, subLibrary1, subLibrary2), true);
- return libraryGroup;
- }
-
- public void testEnforcesUniqueCompilationUnits() {
- MockCompilationUnit compilationUnit = new MockCompilationUnit("com.google.gwt.Regular", "blah");
-
- // Creates libraries with colliding compilation units.
- MockLibrary libraryA = new MockLibrary("LibraryA");
- libraryA.addCompilationUnit(compilationUnit);
- MockLibrary libraryB = new MockLibrary("LibraryB");
- libraryB.addCompilationUnit(compilationUnit);
-
- // Stick them in a library group.
- LibraryGroup libraryGroup =
- LibraryGroup.fromLibraries(Lists.<Library> newArrayList(libraryA, libraryB), true);
-
- // Show that the library group catches the duplication.
- try {
- libraryGroup.getCompilationUnitByTypeSourceName("com.google.gwt.Regular");
- fail("The library group should have detected and rejected the duplicate compilation unit.");
- } catch (CollidingCompilationUnitException e) {
- // expected behavior
- }
- }
-
- public void testUnresolvedLibraryReference() {
- // Create a library that references some library which is not available.
- MockLibrary library = new MockLibrary("RootLibrary");
- library.getDependencyLibraryNames().add("com.something.Missing");
-
- try {
- // Attempt to build a library group with strict library reference enforcement.
- LibraryGroup.fromLibraries(Lists.<Library> newArrayList(library), true);
- fail("Expected library group construction to fail on the missing referenced library.");
- } catch (UnresolvedLibraryException e) {
- // Expected behavior.
- }
-
- // Successfully build the library group when allowing missing references.
- LibraryGroup.fromLibraries(Lists.<Library> newArrayList(library), false);
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/MockLibrary.java b/dev/core/test/com/google/gwt/dev/cfg/MockLibrary.java
deleted file mode 100644
index 7349f22..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/MockLibrary.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.CompiledClass;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.Name.InternalName;
-import com.google.gwt.dev.util.ZipEntryBackedObject;
-import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Multimap;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-/**
- * A mock and in memory library for setting up test situations.
- */
-public class MockLibrary implements Library {
-
- public static List<MockLibrary> createRandomLibraryGraph(
- int libraryCount, int maxParentsPerChild) {
- Random rng = new Random();
- List<MockLibrary> libraries = Lists.newArrayList();
- libraries.add(new MockLibrary("RootLibrary"));
- for (int libraryIndex = 0; libraryIndex < libraryCount; libraryIndex++) {
- MockLibrary childLibrary = new MockLibrary("Library-" + libraryIndex);
- int parentCount = rng.nextInt(maxParentsPerChild) + 1;
-
- for (int parentIndex = 0; parentIndex < parentCount; parentIndex++) {
- Library parentLibrary = libraries.get(rng.nextInt(libraries.size()));
- parentLibrary.getDependencyLibraryNames().add(childLibrary.getLibraryName());
- }
- libraries.add(childLibrary);
- }
- Collections.shuffle(libraries);
- return libraries;
- }
-
- private Set<String> buildResourcePaths = Sets.newHashSet();
- private CompilationErrorsIndexImpl compilationErrorsIndex = new CompilationErrorsIndexImpl();
- private Multimap<String, String> compilationUnitNamesByNestedBinaryName = HashMultimap.create();
- private Multimap<String, String> compilationUnitNamesByNestedSourceName = HashMultimap.create();
- private Map<String, CompilationUnit> compilationUnitsByTypeName = Maps.newHashMap();
- private Set<String> compilationUnitTypeNames = Sets.newHashSet();
- private Set<String> dependencyLibraryNames = Sets.newLinkedHashSet();
- private String libraryName;
- private Multimap<String, String> nestedBinaryNamesByCompilationUnitName = HashMultimap.create();
- private Multimap<String, String> nestedSourceNamesByCompilationUnitName = HashMultimap.create();
- private Multimap<String, String> processedReboundTypeSourceNamesByGenerator =
- HashMultimap.create();
- private Set<String> reboundTypeNames = Sets.newHashSet();
- private Set<String> superSourceCompilationUnitTypeNames = Sets.newHashSet();
-
- public MockLibrary(String libraryName) {
- this.libraryName = libraryName;
- }
-
- public void addCompilationUnit(CompilationUnit compilationUnit) {
- String compilationUnitTypeSourceName = compilationUnit.getTypeName();
- compilationUnitsByTypeName.put(compilationUnitTypeSourceName, compilationUnit);
- compilationUnitTypeNames.add(compilationUnitTypeSourceName);
-
- Collection<CompiledClass> compiledClasses = compilationUnit.getCompiledClasses();
- for (CompiledClass compiledClass : compiledClasses) {
- String sourceName = compiledClass.getSourceName();
- String binaryName = InternalName.toBinaryName(compiledClass.getInternalName());
- nestedSourceNamesByCompilationUnitName.put(compilationUnitTypeSourceName, sourceName);
- nestedBinaryNamesByCompilationUnitName.put(compilationUnitTypeSourceName, binaryName);
- compilationUnitNamesByNestedSourceName.put(sourceName, compilationUnitTypeSourceName);
- compilationUnitNamesByNestedBinaryName.put(binaryName, compilationUnitTypeSourceName);
- }
- }
-
- public void addSuperSourceCompilationUnit(CompilationUnit superSourceCompilationUnit) {
- String superSourceCompilationUnitTypeSourceName = superSourceCompilationUnit.getTypeName();
- compilationUnitsByTypeName.put(superSourceCompilationUnitTypeSourceName,
- superSourceCompilationUnit);
- compilationUnitTypeNames.add(superSourceCompilationUnitTypeSourceName);
-
- Collection<CompiledClass> compiledClasses = superSourceCompilationUnit.getCompiledClasses();
- for (CompiledClass compiledClass : compiledClasses) {
- String sourceName = compiledClass.getSourceName();
- String binaryName = InternalName.toBinaryName(compiledClass.getInternalName());
- nestedSourceNamesByCompilationUnitName.put(superSourceCompilationUnitTypeSourceName,
- sourceName);
- nestedBinaryNamesByCompilationUnitName.put(superSourceCompilationUnitTypeSourceName,
- binaryName);
- compilationUnitNamesByNestedSourceName.put(sourceName,
- superSourceCompilationUnitTypeSourceName);
- compilationUnitNamesByNestedBinaryName.put(binaryName,
- superSourceCompilationUnitTypeSourceName);
- }
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Resource getBuildResourceByPath(String path) {
- return null;
- }
-
- @Override
- public Set<String> getBuildResourcePaths() {
- return buildResourcePaths;
- }
-
- @Override
- public InputStream getClassFileStream(String classFilePath) {
- return null;
- }
-
- @Override
- public CompilationErrorsIndexImpl getCompilationErrorsIndex() {
- return compilationErrorsIndex;
- }
-
- @Override
- public CompilationUnit getCompilationUnitByTypeBinaryName(String typeBinaryName) {
- // Convert nested binary name to enclosing type source name.
- String typeSourceName =
- compilationUnitNamesByNestedBinaryName.get(typeBinaryName).iterator().next();
- return compilationUnitsByTypeName.get(typeSourceName);
- }
-
- @Override
- public CompilationUnit getCompilationUnitByTypeSourceName(String typeSourceName) {
- // Convert nested source name to enclosing type source name.
- typeSourceName = compilationUnitNamesByNestedSourceName.get(typeSourceName).iterator().next();
- return compilationUnitsByTypeName.get(typeSourceName);
- }
-
- @Override
- public Set<String> getDependencyLibraryNames() {
- return dependencyLibraryNames;
- }
-
- @Override
- public ArtifactSet getGeneratedArtifacts() {
- return null;
- }
-
- @Override
- public String getLibraryName() {
- return libraryName;
- }
-
- @Override
- public Multimap<String, String> getNestedBinaryNamesByCompilationUnitName() {
- return nestedBinaryNamesByCompilationUnitName;
- }
-
- @Override
- public Multimap<String, String> getNestedSourceNamesByCompilationUnitName() {
- return nestedSourceNamesByCompilationUnitName;
- }
-
- @Override
- public ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- return null;
- }
-
- @Override
- public Multimap<String, String> getProcessedReboundTypeSourceNamesByGenerator() {
- return processedReboundTypeSourceNamesByGenerator;
- }
-
- @Override
- public Resource getPublicResourceByPath(String path) {
- return null;
- }
-
- @Override
- public Set<String> getPublicResourcePaths() {
- return null;
- }
-
- @Override
- public Set<String> getReboundTypeSourceNames() {
- return reboundTypeNames;
- }
-
- @Override
- public Set<String> getRegularClassFilePaths() {
- return null;
- }
-
- @Override
- public Set<String> getRegularCompilationUnitTypeSourceNames() {
- return compilationUnitTypeNames;
- }
-
- @Override
- public Set<String> getSuperSourceClassFilePaths() {
- return null;
- }
-
- @Override
- public Set<String> getSuperSourceCompilationUnitTypeSourceNames() {
- return superSourceCompilationUnitTypeNames;
- }
-
- @Override
- public String toString() {
- return libraryName;
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/MockLibraryWriter.java b/dev/core/test/com/google/gwt/dev/cfg/MockLibraryWriter.java
deleted file mode 100644
index 90c3317..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/MockLibraryWriter.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.javac.CompilationErrorsIndex;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.jjs.PermutationResult;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.ZipEntryBackedObject;
-import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.util.Set;
-
-/**
- * A mock and in memory library writer for setting up test situations.
- */
-public class MockLibraryWriter implements LibraryWriter {
-
- private Set<String> buildResourcePaths = Sets.newHashSet();
- private Set<String> dependencyLibraryNames = Sets.newHashSet();
- private String libraryName;
- private SetMultimap<String, String> processedReboundTypeSourceNamesByGenerator =
- HashMultimap.create();
- private Set<String> reboundTypeNames;
-
- @Override
- public void addBuildResource(Resource buildResource) {
- buildResourcePaths.add(buildResource.getPath());
- }
-
- @Override
- public void addCompilationUnit(CompilationUnit compilationUnit) {
- }
-
- @Override
- public void addDependencyLibraryNames(Set<String> dependencyLibraryNames) {
- this.dependencyLibraryNames.addAll(dependencyLibraryNames);
- }
-
- @Override
- public void addGeneratedArtifacts(ArtifactSet generatedArtifacts) {
- }
-
- @Override
- public void addPublicResource(Resource publicResource) {
- }
-
- public Set<String> getBuildResourcePaths() {
- return buildResourcePaths;
- }
-
- public Set<String> getDependencyLibraryNames() {
- return dependencyLibraryNames;
- }
-
- public String getLibraryName() {
- return libraryName;
- }
-
- @Override
- public ZipEntryBackedObject<PermutationResult> getPermutationResultHandle() {
- return null;
- }
-
- @Override
- public Set<String> getProcessedReboundTypeSourceNames(String generatorName) {
- return processedReboundTypeSourceNamesByGenerator.get(generatorName);
- }
-
- @Override
- public Set<String> getReboundTypeSourceNames() {
- return reboundTypeNames;
- }
-
- @Override
- public void markReboundTypeProcessed(String processedReboundTypeSourceName,
- String generatorName) {
- processedReboundTypeSourceNamesByGenerator.put(generatorName, processedReboundTypeSourceName);
- }
-
- @Override
- public void markReboundTypesProcessed(Set<String> reboundTypeSourceNames) {
- this.reboundTypeNames = reboundTypeSourceNames;
- }
-
- @Override
- public void setCompilationErrorsIndex(CompilationErrorsIndex compilationErrorsIndex) {
- }
-
- @Override
- public void setLibraryName(String libraryName) {
- this.libraryName = libraryName;
- }
-
- @Override
- public void write() {
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/ModuleDefLoaderTest.java b/dev/core/test/com/google/gwt/dev/cfg/ModuleDefLoaderTest.java
index d28ac61..23b2662 100644
--- a/dev/core/test/com/google/gwt/dev/cfg/ModuleDefLoaderTest.java
+++ b/dev/core/test/com/google/gwt/dev/cfg/ModuleDefLoaderTest.java
@@ -18,20 +18,12 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.cfg.Libraries.IncompatibleLibraryVersionException;
-import com.google.gwt.dev.javac.testing.impl.MockResource;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.util.UnitTestTreeLogger;
-import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import junit.framework.TestCase;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
import java.util.Set;
/**
@@ -41,7 +33,6 @@
private CompilerContext compilerContext;
private CompilerContext.Builder compilerContextBuilder;
- private MockLibraryWriter mockLibraryWriter = new MockLibraryWriter();
public void assertHonorsStrictResources(boolean strictResources)
throws UnableToCompleteException {
@@ -143,62 +134,6 @@
"Line 2: Unexpected element 'inherited'");
}
- public void testLoadFromLibraryGroup() throws UnableToCompleteException, IOException,
- IncompatibleLibraryVersionException {
- PrintWriterTreeLogger logger = new PrintWriterTreeLogger();
- logger.setMaxDetail(TreeLogger.INFO);
-
- // Create the library zip file.
- File zipFile = File.createTempFile("FooLib", ".gwtlib");
- zipFile.deleteOnExit();
-
- // Put data in the library and save it.
- ZipLibraryWriter zipLibraryWriter = new ZipLibraryWriter(zipFile.getPath());
- zipLibraryWriter.setLibraryName("FooLib");
- MockResource userXmlResource = new MockResource("com/google/gwt/user/User.gwt.xml") {
- @Override
- public CharSequence getContent() {
- return "<module></module>";
- }
- };
- zipLibraryWriter.addBuildResource(userXmlResource);
- zipLibraryWriter.write();
-
- // Read data back from disk.
- ZipLibrary zipLibrary = new ZipLibrary(zipFile.getPath());
-
- // Prepare the LibraryGroup and ResourceLoader.
- compilerContext = compilerContextBuilder.libraryGroup(
- LibraryGroup.fromLibraries(Lists.<Library> newArrayList(zipLibrary), false)).build();
- ResourceLoader resourceLoader = ResourceLoaders.forPathAndFallback(Lists.newArrayList(zipFile),
- ResourceLoaders.forClassLoader(Thread.currentThread()));
-
- // Will throw an exception if com.google.gwt.user.User can't be found and parsed.
- ModuleDefLoader.loadFromResources(logger, compilerContext, "com.google.gwt.user.User",
- resourceLoader, false);
- }
-
- /**
- * Tests that the tree representation for a module is correct.
- */
- public void testLibraryTree() throws Exception {
- TreeLogger logger = TreeLogger.NULL;
- ModuleDef six = ModuleDefLoader.loadFromClassPath(
- logger, compilerContext, "com.google.gwt.dev.cfg.testdata.dependents.Six");
-
- Collection<String> sixActualDependencies =
- six.getDirectDependencies("com.google.gwt.dev.cfg.testdata.dependents.Six");
- Collection<String> fiveActualDependencies =
- six.getDirectDependencies("com.google.gwt.dev.cfg.testdata.dependents.Five");
-
- assertEquals(ImmutableSet.of("com.google.gwt.core.Core",
- "com.google.gwt.dev.cfg.testdata.dependents.Five"), sixActualDependencies);
- assertEquals("Contains " + fiveActualDependencies, ImmutableSet.of(
- "com.google.gwt.core.Core", "com.google.gwt.dev.cfg.testdata.dependents.One",
- "com.google.gwt.dev.cfg.testdata.dependents.Two",
- "com.google.gwt.dev.cfg.testdata.dependents.Four"), fiveActualDependencies);
- }
-
/**
* Test of merging multiple modules in the same package space.
* This exercises the interaction of include, exclude, and skip attributes.
@@ -300,77 +235,8 @@
"com/google/gwt/dev/cfg/testdata/merging/resources/NotAResource.java"));
}
- public void testSeparateLibraryModuleReferences() throws UnableToCompleteException {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
- ModuleDefLoader.loadFromClassPath(TreeLogger.NULL, compilerContext,
- "com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne", false);
-
- // The library writer was given the module and it's direct fileset module xml files as build
- // resources.
- assertEquals(Sets.newHashSet(
- "com/google/gwt/dev/cfg/testdata/separate/filesetone/FileSetOne.gwt.xml",
- "com/google/gwt/dev/cfg/testdata/separate/libraryone/LibraryOne.gwt.xml"),
- mockLibraryWriter.getBuildResourcePaths());
- // The library writer was given LibraryTwo as a dependency library.
- assertEquals(Sets.newHashSet("com.google.gwt.core.Core",
- "com.google.gwt.dev.cfg.testdata.separate.librarytwo.LibraryTwo"),
- mockLibraryWriter.getDependencyLibraryNames());
- }
-
- public void testSeparateLibraryName() throws UnableToCompleteException {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
- ModuleDefLoader.loadFromClassPath(TreeLogger.NULL, compilerContext,
- "com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne", false);
-
- assertEquals("com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne",
- mockLibraryWriter.getLibraryName());
- }
-
- public void testSeparateModuleReferences() throws UnableToCompleteException {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
- ModuleDef libraryOneModule = ModuleDefLoader.loadFromClassPath(TreeLogger.NULL, compilerContext,
- "com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne", false);
-
- // The module sees itself and it's direct fileset module as "target" modules.
- assertEquals(Sets.newHashSet("com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne",
- "com.google.gwt.dev.cfg.testdata.separate.filesetone.FileSetOne"),
- libraryOneModule.getTargetLibraryCanonicalModuleNames());
- // The module sees the referenced library module as a "library" module.
- assertEquals(Sets.newHashSet("com.google.gwt.core.Core",
- "com.google.gwt.dev.cfg.testdata.separate.librarytwo.LibraryTwo"),
- libraryOneModule.getExternalLibraryCanonicalModuleNames());
- }
-
- public void testSeparateModuleResourcesLibraryOne() throws UnableToCompleteException {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
- ModuleDef libraryOneModule = ModuleDefLoader.loadFromClassPath(TreeLogger.NULL, compilerContext,
- "com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne", false);
-
- // Includes own source.
- assertNotNull(libraryOneModule.findSourceFile(
- "com/google/gwt/dev/cfg/testdata/separate/libraryone/client/LibraryOne.java"));
- // Cascades to include the subtree of fileset sources.
- assertNotNull(libraryOneModule.findSourceFile(
- "com/google/gwt/dev/cfg/testdata/separate/filesetone/client/FileSetOne.java"));
- // Does not include source from referenced libraries.
- assertNull(libraryOneModule.findSourceFile(
- "com/google/gwt/dev/cfg/testdata/separate/librarytwo/client/LibraryTwo.java"));
- }
-
- public void testSeparateRootFilesetFail() {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
- TreeLogger logger = TreeLogger.NULL;
- try {
- ModuleDefLoader.loadFromClassPath(logger,
- compilerContext, "com.google.gwt.dev.cfg.testdata.separate.filesetone.FileSetOne", false);
- fail("Expected a fileset loaded as the root of a module tree to fail, but it didn't.");
- } catch (UnableToCompleteException e) {
- // Expected behavior.
- }
- }
-
public void testWritesTargetLibraryProperties() throws UnableToCompleteException {
- compilerContext = compilerContextBuilder.compileMonolithic(false).build();
+ compilerContext = compilerContextBuilder.build();
ModuleDef libraryOneModule = ModuleDefLoader.loadFromClassPath(TreeLogger.NULL, compilerContext,
"com.google.gwt.dev.cfg.testdata.separate.libraryone.LibraryOne", false);
@@ -393,8 +259,6 @@
continue;
}
assertEquals(Sets.newHashSet(configurationProperty.getValues()), Sets.newHashSet("false"));
- assertEquals(Sets.newHashSet(configurationProperty.getTargetLibraryValues()),
- Sets.newHashSet("false"));
}
}
@@ -422,6 +286,6 @@
super.setUp();
ModuleDefLoader.getModulesCache().clear();
compilerContextBuilder = new CompilerContext.Builder();
- compilerContext = compilerContextBuilder.libraryWriter(mockLibraryWriter).build();
+ compilerContext = compilerContextBuilder.build();
}
}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/ModuleDefTest.java b/dev/core/test/com/google/gwt/dev/cfg/ModuleDefTest.java
index a7b1b5f..c52b394 100644
--- a/dev/core/test/com/google/gwt/dev/cfg/ModuleDefTest.java
+++ b/dev/core/test/com/google/gwt/dev/cfg/ModuleDefTest.java
@@ -23,7 +23,6 @@
import com.google.gwt.core.ext.linker.LinkerOrder;
import com.google.gwt.core.ext.linker.LinkerOrder.Order;
import com.google.gwt.core.ext.linker.Shardable;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
import junit.framework.TestCase;
@@ -218,68 +217,6 @@
}
}
- public void testGetTransitiveDeps() {
- ModuleDef module = new ModuleDef("Level1");
-
- module.addDirectDependency("Level1", "Level2Left");
- module.addDirectDependency("Level1", "Level2Right");
-
- module.addDirectDependency("Level2Left", "Level3LeftCircular");
-
- // Creates (Left <-> Middle <-> Right), circular references and a sprinkling of extra deps.
- {
- module.addDirectDependency("Level3LeftCircular", "BranchA");
- module.addDirectDependency("Level3LeftCircular", "Level3MiddleCircular");
- module.addDirectDependency("Level3LeftCircular", "BranchB");
-
- module.addDirectDependency("Level3MiddleCircular", "BranchC");
- module.addDirectDependency("Level3MiddleCircular", "Level3LeftCircular");
- module.addDirectDependency("Level3MiddleCircular", "Level3RightCircular");
- module.addDirectDependency("Level3MiddleCircular", "BranchD");
-
- module.addDirectDependency("Level3RightCircular", "BranchE");
- module.addDirectDependency("Level3RightCircular", "Level3MiddleCircular");
- module.addDirectDependency("Level3RightCircular", "BranchF");
- }
-
- module.addDirectDependency("BranchA", "LeafA");
- module.addDirectDependency("BranchB", "LeafB");
- module.addDirectDependency("BranchC", "LeafC");
- module.addDirectDependency("BranchD", "LeafD");
- module.addDirectDependency("BranchE", "LeafE");
- module.addDirectDependency("BranchF", "LeafF");
-
- assertEquals(Sets.newHashSet("Level1", "Level2Left", "Level2Right",
- "Level3LeftCircular", "Level3MiddleCircular", "Level3RightCircular",
- "BranchA", "BranchB", "BranchC", "BranchD", "BranchE", "BranchF",
- "LeafA", "LeafB", "LeafC", "LeafD", "LeafE", "LeafF"),
- module.getTransitiveDepModuleNames("Level1"));
-
- assertEquals(Sets.newHashSet("Level2Left", "Level3LeftCircular",
- "Level3MiddleCircular", "Level3RightCircular", "BranchA", "BranchB",
- "BranchC", "BranchD", "BranchE", "BranchF", "LeafA", "LeafB", "LeafC",
- "LeafD", "LeafE", "LeafF"),
- module.getTransitiveDepModuleNames("Level2Left"));
-
- assertEquals(Sets.newHashSet("Level2Right"),
- module.getTransitiveDepModuleNames("Level2Right"));
-
- assertEquals(Sets.newHashSet("Level3LeftCircular", "Level3MiddleCircular",
- "Level3RightCircular", "BranchA", "BranchB", "BranchC", "BranchD",
- "BranchE", "BranchF", "LeafA", "LeafB", "LeafC", "LeafD", "LeafE",
- "LeafF"), module.getTransitiveDepModuleNames("Level3LeftCircular"));
-
- assertEquals(Sets.newHashSet("Level3LeftCircular", "Level3MiddleCircular",
- "Level3RightCircular", "BranchA", "BranchB", "BranchC", "BranchD",
- "BranchE", "BranchF", "LeafA", "LeafB", "LeafC", "LeafD", "LeafE",
- "LeafF"), module.getTransitiveDepModuleNames("Level3MiddleCircular"));
-
- assertEquals(Sets.newHashSet("Level3LeftCircular", "Level3MiddleCircular",
- "Level3RightCircular", "BranchA", "BranchB", "BranchC", "BranchD",
- "BranchE", "BranchF", "LeafA", "LeafB", "LeafC", "LeafD", "LeafE",
- "LeafF"), module.getTransitiveDepModuleNames("Level3RightCircular"));
- }
-
public void testTwoPrimaries() throws UnableToCompleteException {
ModuleDef def = new ModuleDef("fake");
diff --git a/dev/core/test/com/google/gwt/dev/cfg/RuleGenerateWithTest.java b/dev/core/test/com/google/gwt/dev/cfg/RuleGenerateWithTest.java
deleted file mode 100644
index 704399d..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/RuleGenerateWithTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.cfg;
-
-import com.google.gwt.core.ext.BadPropertyValueException;
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.Generator.RunsLocal;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.SelectionProperty;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.javac.CompilationState;
-import com.google.gwt.dev.javac.CompilationStateBuilder;
-import com.google.gwt.dev.javac.StandardGeneratorContext;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import junit.framework.TestCase;
-
-import java.io.PrintWriter;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Tests for RuleGenerateWith.
- */
-public class RuleGenerateWithTest extends TestCase {
-
- /**
- * Test Generator that cares about properties Foo and Bar.
- */
- @RunsLocal(requiresProperties = {"Foo", "Bar"})
- public static class CaresAboutSomePropertiesGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String typeName)
- throws UnableToCompleteException {
- return null;
- }
- }
-
- /**
- * Test Generator that wants to create types for some combination of user.agent and flavor
- * property values.
- */
- @RunsLocal(requiresProperties = {"user.agent", "flavor"})
- public static class FooGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String typeName)
- throws UnableToCompleteException {
- try {
- SelectionProperty userAgentProperty =
- context.getPropertyOracle().getSelectionProperty(logger, "user.agent");
- String userAgentValue = userAgentProperty.getCurrentValue();
-
- String className = null;
- if (userAgentValue.equals("webkit")) {
- className = "FooWebkit";
- } else {
- SelectionProperty flavorProperty =
- context.getPropertyOracle().getSelectionProperty(logger, "flavor");
- String flavorValue = flavorProperty.getCurrentValue();
- className = "FooMozilla" + flavorValue;
- }
- if (className != null) {
- PrintWriter pw = context.tryCreate(logger, "com.google.gwt", className);
- if (pw != null) {
- pw.println("package com.google.gwt;");
- pw.println("public class " + className + " {");
- pw.println("}");
- pw.flush();
- }
- }
- return "com.google.gwt." + className;
- } catch (BadPropertyValueException e) {
- throw new UnableToCompleteException();
- }
- }
- }
-
- @RunsLocal(requiresProperties = RunsLocal.ALL)
- private class CaresAboutAllPropertiesGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String typeName)
- throws UnableToCompleteException {
- return null;
- }
- }
-
- private static class MockGeneratorContext extends StandardGeneratorContext {
-
- private Set<String> compilationUnitNames = Sets.newHashSet();
- private boolean globalCompile;
-
- public MockGeneratorContext(CompilerContext compilerContext, CompilationState compilationState,
- ArtifactSet allGeneratedArtifacts, boolean isProdMode, boolean globalCompile) {
- super(compilerContext, compilationState, allGeneratedArtifacts, isProdMode);
- this.globalCompile = globalCompile;
- }
-
- @Override
- public boolean isGlobalCompile() {
- return globalCompile;
- }
-
- @Override
- public boolean isProdMode() {
- return true;
- }
-
- @Override
- public void reset() {
- }
-
- @Override
- public PrintWriter tryCreate(TreeLogger logger, String packageName, String simpleTypeName) {
- compilationUnitNames.add(simpleTypeName);
- return super.tryCreate(logger, packageName, simpleTypeName);
- }
- }
-
- private class SimpleGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context, String typeName)
- throws UnableToCompleteException {
- return null;
- }
- }
-
- public void testCaresAboutAllProperties() {
- RuleGenerateWith rule = new RuleGenerateWith(CaresAboutAllPropertiesGenerator.class);
-
- assertFalse(rule.caresAboutProperties(Sets.<String> newHashSet()));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("SomeArbitraryString")));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("Foo", "Bar")));
- }
-
- public void testCaresAboutSomeProperties() {
- RuleGenerateWith rule = new RuleGenerateWith(CaresAboutSomePropertiesGenerator.class);
-
- assertFalse(rule.caresAboutProperties(Sets.<String>newHashSet()));
- assertFalse(rule.caresAboutProperties(Sets.newHashSet("Baz")));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("Foo")));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("Bar")));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("Foo", "Bar")));
- assertTrue(rule.caresAboutProperties(Sets.newHashSet("Foo", "Bar", "Baz")));
- }
-
- public void testDefaultRelevantPropertyNames() {
- SimpleGenerator simpleGenerator = new SimpleGenerator();
- assertEquals(RuleGenerateWith.ALL_PROPERTIES,
- RuleGenerateWith.getAccessedPropertyNames(simpleGenerator.getClass()));
- }
-
- public void testDefaultTypeStability() {
- RuleGenerateWith rule = new RuleGenerateWith(SimpleGenerator.class);
- assertTrue(rule.contentDependsOnTypes());
- }
-
- public void testGenerate() throws UnableToCompleteException {
- // Sets up environment.
- Map<String, String> runtimeRebindRuleSourcesByName =
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME;
- MockModuleDef moduleDef = new MockModuleDef();
- CompilerContext compilerContext = new CompilerContext.Builder().module(moduleDef).build();
-
- MockGeneratorContext generatorContext = new MockGeneratorContext(
- compilerContext, CompilationStateBuilder.buildFrom(
- TreeLogger.NULL, compilerContext, Sets.<Resource>newHashSet()), null, true, false);
- Properties moduleProperties = new Properties();
-
- BindingProperty userAgentProperty = moduleProperties.createBinding("user.agent");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "mozilla");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "webkit");
-
- BindingProperty flavorProperty = moduleProperties.createBinding("flavor");
- flavorProperty.addDefinedValue(flavorProperty.getRootCondition(), "Vanilla");
- flavorProperty.addDefinedValue(flavorProperty.getRootCondition(), "Chocolate");
-
- RuleGenerateWith rule = new RuleGenerateWith(FooGenerator.class);
-
- // Triggers generation with the rule.
- rule.generate(TreeLogger.NULL, moduleProperties, generatorContext, "com.google.gwt.Foo");
-
- // Expects rebind result classes were generated.
- assertEquals(Sets.newHashSet("FooMozillaVanilla", "FooWebkit", "FooMozillaChocolate"),
- generatorContext.compilationUnitNames);
-
- // Expects rebind rules were created that represent the discovery and accessing of user.agent
- // and flavor binding rules.
- String runtimeRebindRule0 = runtimeRebindRuleSourcesByName.get("RuntimeRebindRule0");
- assertTrue(runtimeRebindRule0.contains("com.google.gwt.FooMozillaChocolate::new()"));
- assertTrue(runtimeRebindRule0.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"user.agent\") == \"mozilla\""));
- assertTrue(runtimeRebindRule0.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"flavor\") == \"Chocolate\""));
-
- String runtimeRebindRule1 = runtimeRebindRuleSourcesByName.get("RuntimeRebindRule1");
- assertTrue(runtimeRebindRule1.contains("com.google.gwt.FooWebkit::new()"));
- assertTrue(runtimeRebindRule1.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"user.agent\") == \"webkit\""));
- assertTrue(runtimeRebindRule1.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"flavor\") == \"Chocolate\""));
-
- String runtimeRebindRule2 = runtimeRebindRuleSourcesByName.get("RuntimeRebindRule2");
- assertTrue(runtimeRebindRule2.contains("com.google.gwt.FooMozillaVanilla::new()"));
- assertTrue(runtimeRebindRule2.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"user.agent\") == \"mozilla\""));
- assertTrue(runtimeRebindRule2.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"flavor\") == \"Vanilla\""));
-
- String runtimeRebindRule3 = runtimeRebindRuleSourcesByName.get("RuntimeRebindRule3");
- assertTrue(runtimeRebindRule3.contains("com.google.gwt.FooWebkit::new()"));
- assertTrue(runtimeRebindRule3.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"user.agent\") == \"webkit\""));
- assertTrue(runtimeRebindRule3.contains(
- "@com.google.gwt.lang.RuntimePropertyRegistry::getPropertyValue(*)"
- + "(\"flavor\") == \"Vanilla\""));
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/cfg/ZipLibrariesTest.java b/dev/core/test/com/google/gwt/dev/cfg/ZipLibrariesTest.java
deleted file mode 100644
index b2792f1..0000000
--- a/dev/core/test/com/google/gwt/dev/cfg/ZipLibrariesTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright 2013 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.cfg;
-
-import com.google.gwt.dev.cfg.Libraries.IncompatibleLibraryVersionException;
-import com.google.gwt.dev.javac.CompilationErrorsIndexImpl;
-import com.google.gwt.dev.javac.CompilationStateTestBase;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.JdtCompilerTest;
-import com.google.gwt.dev.javac.testing.impl.MockJavaResource;
-import com.google.gwt.dev.javac.testing.impl.MockResource;
-import com.google.gwt.dev.jjs.ast.JDeclaredType;
-import com.google.gwt.dev.util.Util;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Tests for ZipLibrary and ZipLibraryWriter.
- */
-public class ZipLibrariesTest extends CompilationStateTestBase {
-
- public static final MockJavaResource BAR = new MockJavaResource("test.Bar") {
- @Override
- public CharSequence getContent() {
- StringBuilder sb = new StringBuilder();
- sb.append("package test;");
- sb.append("public class Bar extends Foo {");
- sb.append(" public String value() { return \"Bar\"; }");
- sb.append("}");
- return sb;
- }
- };
-
- public static final MockJavaResource SUPER_FOO = new MockJavaResource("test.Foo") {
- @Override
- public CharSequence getContent() {
- StringBuilder sb = new StringBuilder();
- sb.append("package test;");
- sb.append("public class Foo {");
- sb.append("}");
- return sb;
- }
-
- @Override
- public String getLocation() {
- return "/super/" + path;
- }
-
- @Override
- public boolean wasRerooted() {
- return true;
- }
- };
-
- private static class SimpleMockResource extends MockResource {
-
- public SimpleMockResource(String path) {
- super(path);
- }
-
- @Override
- public CharSequence getContent() {
- return "";
- }
- }
-
- public void testRoundTrip() throws IOException, IncompatibleLibraryVersionException {
- File zipFile = File.createTempFile("Test", ".gwtlib");
- zipFile.deleteOnExit();
-
- // Data
- String expectedLibraryName = "BazLib";
- final String expectedResourceContents =
- "<html><head><title>Index</title></head><body>Hi</body></html>";
- Set<String> expectedDependencyLibraryNames = Sets.newHashSet("FooLib", "BarLib");
- oracle.add(BAR, SUPER_FOO, JdtCompilerTest.OUTER_INNER);
- rebuildCompilationState();
- List<CompilationUnit> compilationUnits =
- Lists.newArrayList(state.getCompilationUnitMap().values());
- CompilationErrorsIndexImpl expectedCompilationErrorsIndex = new CompilationErrorsIndexImpl();
- expectedCompilationErrorsIndex.add("com.google.Foo", "/project/src/com/google/Foo.java",
- Lists.newArrayList("com.google.Bang"), Lists.newArrayList("Unresolved type 'Bang'"));
-
- // Put data in the library and save it.
- ZipLibraryWriter zipLibraryWriter = new ZipLibraryWriter(zipFile.getPath());
- zipLibraryWriter.setLibraryName(expectedLibraryName);
- // Include unusual path characters.
- zipLibraryWriter.addPublicResource(new SimpleMockResource("ui:binder:com.foo.baz.TableView"));
- // Include specific expected contents.
- zipLibraryWriter.addPublicResource(new MockResource("index.html") {
- @Override
- public CharSequence getContent() {
- return expectedResourceContents;
- }
- });
- zipLibraryWriter.addDependencyLibraryNames(expectedDependencyLibraryNames);
- for (CompilationUnit compilationUnit : compilationUnits) {
- zipLibraryWriter.addCompilationUnit(compilationUnit);
- }
- zipLibraryWriter.setCompilationErrorsIndex(expectedCompilationErrorsIndex);
- zipLibraryWriter.write();
-
- // Read data back from disk.
- ZipLibrary zipLibrary = new ZipLibrary(zipFile.getPath());
- CompilationUnit barCompilationUnit =
- zipLibrary.getCompilationUnitByTypeSourceName(BAR.getTypeName());
- CompilationUnit superFooCompilationUnit =
- zipLibrary.getCompilationUnitByTypeSourceName(SUPER_FOO.getTypeName());
-
- // Compare it.
- assertEquals(expectedLibraryName, zipLibrary.getLibraryName());
- assertEquals(expectedResourceContents,
- Util.readStreamAsString(zipLibrary.getPublicResourceByPath("index.html").openContents()));
- assertEquals(expectedDependencyLibraryNames, zipLibrary.getDependencyLibraryNames());
-
- // CompilationUnit
- List<JDeclaredType> barTypes = barCompilationUnit.getTypes();
- assertEquals(1, barTypes.size());
- assertEquals(BAR.getTypeName(), barTypes.get(0).getName());
- assertEquals(BAR.getLocation(), barCompilationUnit.getResourceLocation());
- assertEquals(BAR.getTypeName(), barCompilationUnit.getTypeName());
-
- // SuperSourceCompilationUnit
- List<JDeclaredType> superFoo = superFooCompilationUnit.getTypes();
- assertEquals(1, superFoo.size());
- assertEquals(SUPER_FOO.getTypeName(), superFoo.get(0).getName());
- assertEquals(SUPER_FOO.getLocation(), superFooCompilationUnit.getResourceLocation());
- assertEquals(SUPER_FOO.getTypeName(), superFooCompilationUnit.getTypeName());
-
- // Can find inner classes by source name.
- assertTrue(zipLibrary.getNestedSourceNamesByCompilationUnitName().get(
- JdtCompilerTest.OUTER_INNER.getTypeName()).contains(
- JdtCompilerTest.OUTER_INNER.getTypeName() + ".Inner"));
-
- // Can find inner classes by binary name.
- assertTrue(zipLibrary.getNestedBinaryNamesByCompilationUnitName().get(
- JdtCompilerTest.OUTER_INNER.getTypeName()).contains(
- JdtCompilerTest.OUTER_INNER.getTypeName() + "$Inner"));
-
- // The reloaded compilation errors index contains the same data as before writing to disk.
- assertEquals(expectedCompilationErrorsIndex, zipLibrary.getCompilationErrorsIndex());
- }
-
- public void testVersionNumberException() throws IOException {
- File zipFile = File.createTempFile("Test", ".gwtlib");
- zipFile.deleteOnExit();
-
- // Put data in the library and save it.
- ZipLibraryWriter zipLibraryWriter = new ZipLibraryWriter(zipFile.getPath());
- zipLibraryWriter.setLibraryName("BazLib");
- zipLibraryWriter.write();
-
- // Change the expected version number so that this next read should fail.
- ZipLibraries.versionNumber++;
-
- // Read data back from disk.
- try {
- new ZipLibrary(zipFile.getPath());
- fail("Expected zip library initialization to fail with a version "
- + "mismatch, but it didn't fail.");
- } catch (IncompatibleLibraryVersionException e) {
- // Expected behavior.
- }
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationUnitInvalidatorTest.java b/dev/core/test/com/google/gwt/dev/javac/CompilationUnitInvalidatorTest.java
index ff6a973..87a76a7 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationUnitInvalidatorTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationUnitInvalidatorTest.java
@@ -89,7 +89,7 @@
// Invoke the method under test
CompilationUnitInvalidator.retainValidUnits(TreeLogger.NULL, units, validClasses,
- compilerContext.getLocalCompilationErrorsIndex());
+ compilerContext.getCompilationErrorsIndex());
// Check that the compilation errors index was correctly populated.
UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
diff --git a/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java b/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
index 8ec0a07..4e76d09 100644
--- a/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
+++ b/dev/core/test/com/google/gwt/dev/javac/JavaCompilationSuite.java
@@ -58,7 +58,6 @@
suite.addTestSuite(CompilationStateBuilderTest.class);
suite.addTestSuite(CompilationUnitTypeOracleUpdaterFromByteCodeTest.class);
suite.addTestSuite(CompilationUnitTypeOracleUpdaterFromSourceTest.class);
- suite.addTestSuite(LibraryCompilationUnitTypeOracleUpdaterFromSourceTest.class);
suite.addTestSuite(CollectClassDataTest.class);
suite.addTestSuite(CollectReferencesVisitorTest.class);
diff --git a/dev/core/test/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdaterFromSourceTest.java b/dev/core/test/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdaterFromSourceTest.java
deleted file mode 100644
index 54a2c50..0000000
--- a/dev/core/test/com/google/gwt/dev/javac/LibraryCompilationUnitTypeOracleUpdaterFromSourceTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.javac;
-
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.TypeOracleException;
-import com.google.gwt.dev.javac.mediatortest.CircularA;
-import com.google.gwt.dev.javac.mediatortest.CircularB;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-
-import java.util.Set;
-
-/**
- * Tests for LibraryCompilationUnitTypeOracleUpdaterFromSource.<br />
- *
- * Shows the correctness of the lazy LibraryTypeOracle for the common TypeOracle tests as well as
- * the breadth of lazy loads and recalculation of type hierarchy after repeated lazy loads.
- */
-public class LibraryCompilationUnitTypeOracleUpdaterFromSourceTest extends
- CompilationUnitTypeOracleUpdaterFromSourceTest {
-
- protected static final CheckedJavaResource CU_CircularA =
- new CheckedJavaResource(CircularA.class) {
- @Override
- public void check(JClassType type) {
- }
- };
-
- protected static final CheckedJavaResource CU_CircularB =
- new CheckedJavaResource(CircularB.class) {
- @Override
- public void check(JClassType type) {
- }
- };
-
- public void testCircularLazyCascade() throws TypeOracleException {
- addTestResource(CU_Object);
- addTestResource(CU_CircularA);
- addTestResource(CU_CircularB);
- buildTypeOracle();
-
- // TypeOracle is initially empty, because it is lazy.
- assertEquals(0, typeOracle.getTypes().length);
-
- // But it will lazily load CircularA if asked.
- assertNotNull(typeOracle.findType(CU_CircularA.getTypeName()));
-
- // The lazy load also cascaded to load CU_CircularB and Object.
- assertEquals(3, typeOracle.getTypes().length);
-
- // Object sees CircularA and B subclasses.
- Set<JClassType> objectSubtypes =
- Sets.newHashSet(typeOracle.findType(CU_Object.getTypeName()).getSubtypes());
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_CircularA.getTypeName())));
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_CircularB.getTypeName())));
- }
-
- // Check that anonymous classes are not reflected in TypeOracle
- @Override
- public void testLocal() throws TypeOracleException {
- addTestResource(CU_Object);
- addTestResource(CU_EnclosingLocalClass);
- buildTypeOracle();
- // Unlike a regular TypeOracle, the lazy LibraryTypeOracle must be forced to load all types to
- // be able to prove that inner classes do not show up in the type list.
- ((com.google.gwt.dev.javac.typemodel.TypeOracle) typeOracle).ensureAllLoaded();
-
- assertEquals(2, typeOracle.getTypes().length);
- }
-
- public void testRepeatedRecalculatesTypeHierarchy() throws TypeOracleException {
- addTestResource(CU_Object);
- addTestResource(CU_String);
- addTestResource(CU_CircularA);
- addTestResource(CU_CircularB);
- buildTypeOracle();
-
- // Lazily load String type.
- typeOracle.findType(CU_String.getTypeName());
-
- // Object sees only String subclass
- Set<JClassType> objectSubtypes =
- Sets.newHashSet(typeOracle.findType(CU_Object.getTypeName()).getSubtypes());
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_String.getTypeName())));
-
- // Lazily load CircularA and CircularB types.
- typeOracle.findType(CU_CircularA.getTypeName());
- typeOracle.findType(CU_CircularB.getTypeName());
-
- // Object now additionally sees CircularA and B subclasses.
- objectSubtypes = Sets.newHashSet(typeOracle.findType(CU_Object.getTypeName()).getSubtypes());
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_String.getTypeName())));
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_CircularA.getTypeName())));
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_CircularB.getTypeName())));
- }
-
- public void testSimpleLazyCascade() throws TypeOracleException {
- addTestResource(CU_Object);
- addTestResource(CU_String);
- buildTypeOracle();
-
- // TypeOracle is initially empty, because it is lazy.
- assertEquals(0, typeOracle.getTypes().length);
-
- // But it will lazily load String if asked.
- assertNotNull(typeOracle.findType(CU_String.getTypeName()));
-
- // The lazy load also cascaded to load Object.
- assertEquals(2, typeOracle.getTypes().length);
-
- // Object sees String subclass
- Set<JClassType> objectSubtypes =
- Sets.newHashSet(typeOracle.findType(CU_Object.getTypeName()).getSubtypes());
- assertTrue(objectSubtypes.contains(typeOracle.findType(CU_String.getTypeName())));
- }
-
- @Override
- protected void buildTypeOracle() throws TypeOracleException {
- typeOracle = TypeOracleTestingUtils.buildLibraryTypeOracle(createTreeLogger(), resources);
- checkTypes(typeOracle.getTypes());
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java b/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
index 8465fff..9d9873d 100644
--- a/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
+++ b/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
@@ -19,15 +19,10 @@
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.MockLibrary;
import com.google.gwt.dev.javac.testing.impl.JavaResourceBase;
import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -93,42 +88,6 @@
generatedUnits);
}
- public static TypeOracle buildLibraryTypeOracle(TreeLogger logger, Set<Resource> resources) {
- return buildLibraryTypeOracle(logger, resources, Collections.<GeneratedUnit> emptySet());
- }
-
- public static TypeOracle buildLibraryTypeOracle(TreeLogger logger, Set<Resource> resources,
- Set<GeneratedUnit> generatedUnits) {
- try {
- // Compile resources to compilation units and place in an old library.
- CompilerContext oldCompilerContext = new CompilerContext();
- oldCompilerContext.getOptions().setStrict(true);
- CompilationState oldState =
- CompilationStateBuilder.buildFrom(logger, oldCompilerContext, resources);
- oldState.addGeneratedCompilationUnits(logger, generatedUnits);
- MockLibrary oldLibrary = new MockLibrary("OldLib");
- Collection<CompilationUnit> oldCompilationUnits =
- Lists.newArrayList(oldState.getCompilationUnits());
- CompilationUnitInvalidator.retainValidUnits(logger, oldCompilationUnits,
- oldState.getValidClasses(), new CompilationErrorsIndexImpl());
- for (CompilationUnit compilationUnit : oldCompilationUnits) {
- oldLibrary.addCompilationUnit(compilationUnit);
- }
-
- // Create and return a LibraryTypeOracle that doesn't have any compilation units loaded but
- // which can lazy load all of them out of a previously compiled library.
- LibraryGroup libraryGroup = LibraryGroup.fromLibraries(Lists.newArrayList(oldLibrary), false);
- CompilerContext newCompilerContext =
- new CompilerContext.Builder().compileMonolithic(false).libraryGroup(libraryGroup).build();
- newCompilerContext.getOptions().setStrict(true);
- CompilationState state = CompilationStateBuilder.buildFrom(logger, newCompilerContext,
- Sets.<Resource> newHashSet());
- return state.getTypeOracle();
- } catch (UnableToCompleteException e) {
- throw new RuntimeException(e);
- }
- }
-
public static TypeOracle buildTypeOracle(TreeLogger logger,
Set<Resource> resources) {
return buildTypeOracle(logger, resources,
diff --git a/dev/core/test/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompilerTest.java b/dev/core/test/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompilerTest.java
deleted file mode 100644
index 0959299..0000000
--- a/dev/core/test/com/google/gwt/dev/jjs/LibraryJavaToJavaScriptCompilerTest.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * 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.jjs;
-
-import com.google.gwt.core.ext.BadPropertyValueException;
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.Generator.RunsLocal;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.linker.ArtifactSet;
-import com.google.gwt.dev.CompilerContext;
-import com.google.gwt.dev.CompilerOptionsImpl;
-import com.google.gwt.dev.MinimalRebuildCache;
-import com.google.gwt.dev.PrecompileTaskOptions;
-import com.google.gwt.dev.cfg.BindingProperty;
-import com.google.gwt.dev.cfg.Condition;
-import com.google.gwt.dev.cfg.ConditionWhenPropertyIs;
-import com.google.gwt.dev.cfg.ConditionWhenTypeIs;
-import com.google.gwt.dev.cfg.ConfigurationProperty;
-import com.google.gwt.dev.cfg.DeferredBindingQuery;
-import com.google.gwt.dev.cfg.LibraryGroup;
-import com.google.gwt.dev.cfg.LibraryGroupTest;
-import com.google.gwt.dev.cfg.MockLibraryWriter;
-import com.google.gwt.dev.cfg.MockModuleDef;
-import com.google.gwt.dev.cfg.Properties;
-import com.google.gwt.dev.cfg.PropertyProvider;
-import com.google.gwt.dev.cfg.Rule;
-import com.google.gwt.dev.cfg.RuleFail;
-import com.google.gwt.dev.cfg.RuleGenerateWith;
-import com.google.gwt.dev.cfg.RuleReplaceWith;
-import com.google.gwt.dev.cfg.RuleReplaceWithFallback;
-import com.google.gwt.dev.cfg.RuntimeRebindRuleGenerator;
-import com.google.gwt.dev.javac.CompilationState;
-import com.google.gwt.dev.javac.CompilationStateBuilder;
-import com.google.gwt.dev.javac.StandardGeneratorContext;
-import com.google.gwt.dev.jdt.RebindPermutationOracle;
-import com.google.gwt.dev.jjs.ast.JClassType;
-import com.google.gwt.dev.jjs.ast.JConstructor;
-import com.google.gwt.dev.jjs.ast.JDeclaredType;
-import com.google.gwt.dev.jjs.ast.JProgram;
-import com.google.gwt.dev.jjs.ast.JType;
-import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.thirdparty.guava.common.collect.Lists;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.util.concurrent.AtomicLongMap;
-
-import junit.framework.TestCase;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Deque;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Tests for LibraryJavaToJavaScriptCompiler.
- */
-public class LibraryJavaToJavaScriptCompilerTest extends TestCase {
-
- /**
- * Test Generator that wants to create a FooShim%user.agent% type for every processed FooShim
- * type.
- */
- @RunsLocal(requiresProperties = {"user.agent"})
- public static class BrowserShimGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext generatorContext,
- String typeShortName) throws UnableToCompleteException {
- try {
- String userAgentValue = generatorContext.getPropertyOracle()
- .getSelectionProperty(logger, "user.agent").getCurrentValue();
- PrintWriter pw =
- generatorContext.tryCreate(logger, "com.google.gwt", userAgentValue + typeShortName);
- if (pw != null) {
- generatorContext.commit(logger, pw);
- }
- return typeShortName + userAgentValue;
- } catch (BadPropertyValueException e) {
- throw new UnableToCompleteException();
- }
- }
- }
-
- /**
- * Test Generator that wants to create a FooShim%locale% type for every processed FooShim
- * type.
- */
- @RunsLocal(requiresProperties = {"locale"})
- public static class LocaleMessageGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext generatorContext,
- String typeShortName) throws UnableToCompleteException {
- try {
- String localeValue = generatorContext.getPropertyOracle()
- .getSelectionProperty(logger, "locale").getCurrentValue();
- PrintWriter pw =
- generatorContext.tryCreate(logger, "com.google.gwt", localeValue + typeShortName);
- if (pw != null) {
- generatorContext.commit(logger, pw);
- }
- return typeShortName + localeValue;
- } catch (BadPropertyValueException e) {
- throw new UnableToCompleteException();
- }
- }
- }
-
- private static class ConditionWhenTypeEndsWith extends Condition {
-
- private final String suffix;
-
- public ConditionWhenTypeEndsWith(String suffix) {
- this.suffix = suffix;
- }
-
- @Override
- public String toSource() {
- return String.format("requestTypeName.endsWith(\"%s\")", suffix);
- }
-
- @Override
- public String toString() {
- return "<when-type-ends-with class='" + suffix + "'/>";
- }
-
- @Override
- protected boolean doEval(TreeLogger logger, DeferredBindingQuery query) {
- return query.getTestType().endsWith(suffix);
- }
-
- @Override
- protected String getEvalAfterMessage(String testType, boolean result) {
- if (result) {
- return "Yes, the requested type ended in " + suffix;
- } else {
- return "Suffix didn't match";
- }
- }
-
- @Override
- protected String getEvalBeforeMessage(String testType) {
- return toString();
- }
- }
-
- private static class MockGeneratorContext extends StandardGeneratorContext {
-
- private boolean dirty = false;
- private boolean globalCompile;
- private Map<String, StringWriter> stringWriterByTypeSourceName = Maps.newHashMap();
-
- public MockGeneratorContext(CompilerContext compilerContext, CompilationState compilationState,
- ArtifactSet allGeneratedArtifacts, boolean isProdMode, boolean globalCompile) {
- super(compilerContext, compilationState, allGeneratedArtifacts, isProdMode);
- this.globalCompile = globalCompile;
- }
-
- @Override
- public ArtifactSet finish(TreeLogger logger) throws UnableToCompleteException {
- dirty = false;
- // Don't actually compile generated source code;
- return new ArtifactSet();
- }
-
- @Override
- public boolean isDirty() {
- return dirty;
- }
-
- @Override
- public boolean isGlobalCompile() {
- return globalCompile;
- }
-
- @Override
- public boolean isProdMode() {
- return true;
- }
-
- @Override
- public void reset() {
- dirty = false;
- }
-
- @Override
- public PrintWriter tryCreate(TreeLogger logger, String packageName, String typeShortName) {
- if (!stringWriterByTypeSourceName.containsKey(packageName + "." + typeShortName)) {
- StringWriter stringWriter = new StringWriter();
- stringWriterByTypeSourceName.put(packageName + "." + typeShortName, stringWriter);
- dirty = true;
- return new PrintWriter(stringWriter);
- }
- return null;
- }
- }
-
- private class MockLibraryJavaToJavaScriptCompiler extends LibraryJavaToJavaScriptCompiler {
-
- private class MockLibraryPrecompiler extends LibraryPrecompiler {
-
- private Set<String> processedReboundTypeSourceNames = Sets.newHashSet();
- private Set<JDeclaredType> reboundTypes = Sets.<JDeclaredType>newHashSet(
- createInstantiableClassType("com.google.ErrorMessages"),
- createInstantiableClassType("com.google.EventShim"));
- private AtomicLongMap<String> runCountByGeneratorName = AtomicLongMap.create();
-
- public MockLibraryPrecompiler(RebindPermutationOracle rpo, String[] entryPointTypeNames) {
- super(rpo, entryPointTypeNames);
- }
-
- /**
- * Overridden to avoid the complexity of mocking out a UnitCache.
- */
- @Override
- protected JDeclaredType ensureFullTypeLoaded(JDeclaredType type) {
- return type;
- }
-
- /**
- * Overridden to avoid the need to mock out DistillerRebindPermutationOracle as well as to
- * dynamically expand the reboundTypes list to cause repeated generator runs.
- */
- @Override
- protected Set<JDeclaredType> gatherReboundTypes(RebindPermutationOracle rpo) {
- return reboundTypes;
- }
-
- @Override
- protected StandardGeneratorContext getGeneratorContext() {
- return mockGeneratorContext;
- }
-
- @Override
- protected void runGenerator(RuleGenerateWith generatorRule,
- Set<String> reboundTypeSourceNames) throws UnableToCompleteException {
- processedReboundTypeSourceNames.addAll(reboundTypeSourceNames);
- runCountByGeneratorName.incrementAndGet(generatorRule.getName());
- super.runGenerator(generatorRule, reboundTypeSourceNames);
- }
- }
-
- private StandardGeneratorContext mockGeneratorContext;
-
- public MockLibraryJavaToJavaScriptCompiler(TreeLogger logger, CompilerContext compilerContext,
- StandardGeneratorContext generatorContext) {
- super(logger, compilerContext);
- this.mockGeneratorContext = generatorContext;
- }
-
- private MockLibraryPrecompiler createPrecompiler() {
- return new MockLibraryPrecompiler(null, null);
- }
- }
-
- private static JClassType createInstantiableClassType(String typeBinaryName) {
- JClassType instantiableType = new JClassType(SourceOrigin.UNKNOWN, typeBinaryName, false, true);
- JConstructor defaultConstructor = new JConstructor(SourceOrigin.UNKNOWN, instantiableType);
- defaultConstructor.setOriginalTypes(instantiableType, Lists.<JType>newArrayList());
- instantiableType.addMethod(defaultConstructor);
- return instantiableType;
- }
-
- private MockLibraryJavaToJavaScriptCompiler compiler;
- private CompilerContext compilerContext;
- private MockGeneratorContext generatorContext;
- private MockLibraryJavaToJavaScriptCompiler.MockLibraryPrecompiler precompiler;
-
- public void testBuildFallbackRuntimeRebindRules() throws UnableToCompleteException {
- // Sets up environment.
- Map<String, String> runtimeRebindRuleSourcesByShortName =
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME;
- Set<JDeclaredType> reboundTypes =
- Sets.<JDeclaredType>newHashSet(createInstantiableClassType("CanvasElement"));
-
- // Runs fallback rebind rule creation for rebound types.
- precompiler.buildFallbackRuntimeRebindRules(reboundTypes);
-
- // Expects a worst case rebind rule was created that will at least attempt to create a
- // CanvasElement when a CanvasElement is requested.
- String runtimeRebindRule0 = runtimeRebindRuleSourcesByShortName.get("RuntimeRebindRule0");
- assertTrue(runtimeRebindRule0.contains("@CanvasElement::new()()"));
- assertTrue(runtimeRebindRule0.contains("requestTypeClass == @CanvasElement::class"));
- }
-
- public void testBuildLocalRuntimeRebindRules() throws UnableToCompleteException {
- // Sets up environment.
- Set<String> allRootTypes = Sets.newHashSet();
- compiler.jprogram = new JProgram(new MinimalRebuildCache());
- Map<String, String> runtimeRebindRuleSourcesByShortName =
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME;
- Deque<Rule> rules = Lists.newLinkedList();
- RuleFail ruleFail = new RuleFail();
- ruleFail.getRootCondition().getConditions().add(new ConditionWhenPropertyIs("foo", "bar"));
- rules.addFirst(ruleFail);
- rules.addFirst(new RuleGenerateWith(Generator.class));
- RuleReplaceWith ruleReplaceCanvas = new RuleReplaceWith("WebkitCanvasElement");
- ruleReplaceCanvas.getRootCondition()
- .getConditions().add(new ConditionWhenTypeIs("CanvasElement"));
- rules.addFirst(ruleReplaceCanvas);
- rules.addFirst(new RuleReplaceWithFallback("CanvasElement"));
-
- // Creates rebind rule classes for the non-generator rules in the provided list.
- precompiler.buildSimpleRuntimeRebindRules(rules);
-
- // Only 3 rebind rules were created because the generator rule was skipped.
- assertEquals(3, runtimeRebindRuleSourcesByShortName.size());
-
- // Expects to see the created fallback rule first.
- String runtimeRebindRule0 = runtimeRebindRuleSourcesByShortName.get("RuntimeRebindRule0");
- assertTrue(runtimeRebindRule0.contains("@CanvasElement::new()()"));
- assertTrue(runtimeRebindRule0.contains("requestTypeClass == @CanvasElement::class"));
-
- // Expects to see the created replace with rule second.
- String runtimeRebindRule1 = runtimeRebindRuleSourcesByShortName.get("RuntimeRebindRule1");
- assertTrue(runtimeRebindRule1.contains("@WebkitCanvasElement::new()()"));
- assertTrue(runtimeRebindRule1.contains("requestTypeClass == @CanvasElement::class"));
-
- // Expects to see the created fail rule third.
- String runtimeRebindRule2 = runtimeRebindRuleSourcesByShortName.get("RuntimeRebindRule2");
- assertTrue(runtimeRebindRule2.contains("Deferred binding request failed for type"));
- assertTrue(runtimeRebindRule2.contains(
- "RuntimePropertyRegistry::getPropertyValue(*)(\"foo\") == \"bar\""));
-
- // Now that runtime rebind rules have been generated, create a registrator for them.
- precompiler.buildRuntimeRebindRegistrator(allRootTypes);
-
- // JProgram was informed of the newly created PropertyProviderRegistrator type and its name
- // reflects the name of the module currently being processed.
- assertEquals("com.google.gwt.lang.mock_RuntimeRebindRegistrator",
- compiler.jprogram.getRuntimeRebindRegistratorTypeSourceName());
- // The allRootTypes list was augmented to know about this newly created type.
- assertTrue(
- allRootTypes.contains(compiler.jprogram.getRuntimeRebindRegistratorTypeSourceName()));
-
- String registratorSource = generatorContext.stringWriterByTypeSourceName.get(
- compiler.jprogram.getRuntimeRebindRegistratorTypeSourceName()).toString();
- // The generated registrator contains all of the RuntimeRebindRule class instantiation,
- // and registrations.
- assertTrue(registratorSource.contains(
- "RuntimeRebinder.registerRuntimeRebindRule(new RuntimeRebindRule0());"));
- assertTrue(registratorSource.contains(
- "RuntimeRebinder.registerRuntimeRebindRule(new RuntimeRebindRule1());"));
- assertTrue(registratorSource.contains(
- "RuntimeRebinder.registerRuntimeRebindRule(new RuntimeRebindRule2());"));
- }
-
- public void testBuildPropertyProviderRegistrator() throws UnableToCompleteException {
- // Sets up environment.
- Set<String> allRootTypes = Sets.newHashSet();
- Properties properties = new Properties();
- BindingProperty userAgentProperty = properties.createBinding("user.agent");
- userAgentProperty.setProvider(new PropertyProvider("return navigator.userAgent;"));
- userAgentProperty.addTargetLibraryDefinedValue(userAgentProperty.getRootCondition(), "mozilla");
- userAgentProperty.addTargetLibraryDefinedValue(userAgentProperty.getRootCondition(), "webkit");
- BindingProperty flavorProperty = properties.createBinding("flavor");
- flavorProperty.setProvider(new PropertyProvider("return window.properties.flavor;"));
- flavorProperty.addTargetLibraryDefinedValue(flavorProperty.getRootCondition(), "Vanilla");
- flavorProperty.addTargetLibraryDefinedValue(flavorProperty.getRootCondition(), "Chocolate");
- ConfigurationProperty emulateStackProperty =
- properties.createConfiguration("emulateStack", false);
- emulateStackProperty.setValue("TRUE");
- compiler.jprogram = new JProgram(new MinimalRebuildCache());
-
- // Builds property provider classes and a property provider registrator to register them.
- precompiler.buildPropertyProviderRegistrator(allRootTypes,
- Sets.newTreeSet(Lists.newArrayList(userAgentProperty, flavorProperty)),
- Sets.newTreeSet(Lists.newArrayList(emulateStackProperty)));
-
- // JProgram was informed of the newly created PropertyProviderRegistrator type and its source
- // name reflects the name of the module currently being processed.
- assertEquals("com.google.gwt.lang.mock_PropertyProviderRegistrator",
- compiler.jprogram.getPropertyProviderRegistratorTypeSourceName());
- // The allRootTypes list was augmented to know about this newly created type.
- assertTrue(
- allRootTypes.contains(compiler.jprogram.getPropertyProviderRegistratorTypeSourceName()));
-
- String registratorSource = generatorContext.stringWriterByTypeSourceName.get(
- compiler.jprogram.getPropertyProviderRegistratorTypeSourceName()).toString();
- // The generated registrator contains PropertyValueProvider class definitions, instantiation,
- // and registration for each binding property.
- assertTrue(registratorSource.contains("class PropertyValueProvider0"));
- assertTrue(registratorSource.contains("\"flavor\""));
- assertTrue(registratorSource.contains("/*-return window.properties.flavor;-*/"));
- assertTrue(registratorSource.contains(
- "registerPropertyValueProvider(" + "new PropertyValueProvider0())"));
- assertTrue(registratorSource.contains("class PropertyValueProvider1"));
- assertTrue(registratorSource.contains("\"user.agent\""));
- assertTrue(registratorSource.contains("/*-return navigator.userAgent;-*/;"));
- assertTrue(registratorSource.contains(
- "registerPropertyValueProvider(" + "new PropertyValueProvider1())"));
- }
-
- public void testRunGeneratorsToFixedPoint() throws UnableToCompleteException {
- // Sets up environment.
- Map<String, String> runtimeRebindRuleSourcesByShortName =
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME;
- MockLibraryWriter libraryWriter = new MockLibraryWriter();
- // A library group with a varied
- // user.agent/locale/BrowserShimGenerator/LocaleMessageGenerator configuration of properties
- // and generators.
- MockModuleDef module = new MockModuleDef();
- BindingProperty userAgentProperty = module.getProperties().createBinding("user.agent");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "mozilla");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "webkit");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "ie");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "webkit_phone");
- userAgentProperty.addDefinedValue(userAgentProperty.getRootCondition(), "webkit_tablet");
- BindingProperty flavorProperty = module.getProperties().createBinding("locale");
- flavorProperty.addDefinedValue(flavorProperty.getRootCondition(), "en");
- flavorProperty.addDefinedValue(flavorProperty.getRootCondition(), "fr");
- flavorProperty.addDefinedValue(flavorProperty.getRootCondition(), "ru");
- RuleGenerateWith browserShimGenerateRule = new RuleGenerateWith(BrowserShimGenerator.class);
- browserShimGenerateRule.getRootCondition()
- .getConditions().add(new ConditionWhenTypeEndsWith("Shim"));
- module.addRule(browserShimGenerateRule);
- RuleGenerateWith localeMessageGenerateRule = new RuleGenerateWith(LocaleMessageGenerator.class);
- localeMessageGenerateRule.getRootCondition()
- .getConditions().add(new ConditionWhenTypeEndsWith("Messages"));
- module.addRule(localeMessageGenerateRule);
- LibraryGroup libraryGroup = LibraryGroupTest.buildVariedPropertyGeneratorLibraryGroup(
- Sets.newHashSet("com.google.ChromeMessages"),
- Sets.newHashSet("com.google.WindowShim"));
- PrecompileTaskOptions options = new CompilerOptionsImpl();
- options.setFinalProperties(module.getProperties());
- compilerContext = new CompilerContext.Builder().libraryGroup(libraryGroup)
- .libraryWriter(libraryWriter).module(module).options(options).build();
- finishSetUpWithCompilerContext();
-
- // Analyzes properties and generators in the library group and watches output in the generator
- // context to figure out which generators to run and how many times.
- precompiler.runGeneratorsToFixedPoint(null);
-
- // Shows that rebinds processed by generators were not just the ones explicitly rebound in this
- // module but also ones previously processed in dependency libraries but reprocessed now because
- // of new property value changes.
- assertEquals(Sets.newHashSet("com.google.EventShim", // Explicitly rebound at top level
- "com.google.WindowShim", // Old lib rebind, reprocessed because of new property values.
- "com.google.ChromeMessages", // Old lib rebind, reprocessed because of new property values.
- "com.google.ErrorMessages" // Explicitly rebound at top level
- ), precompiler.processedReboundTypeSourceNames);
- // Rebinds for 3 locales * 2 locale rebound files + 5 user agents * 2 user agent rebound files.
- assertEquals(16, runtimeRebindRuleSourcesByShortName.size());
- }
-
- protected void finishSetUpWithCompilerContext() throws UnableToCompleteException {
- generatorContext = new MockGeneratorContext(compilerContext, CompilationStateBuilder.buildFrom(
- TreeLogger.NULL, compilerContext, Sets.<Resource>newHashSet()), null, true, false);
- compiler =
- new MockLibraryJavaToJavaScriptCompiler(TreeLogger.NULL, compilerContext, generatorContext);
- precompiler = compiler.createPrecompiler();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- RuntimeRebindRuleGenerator.RUNTIME_REBIND_RULE_SOURCES_BY_SHORT_NAME.clear();
- RuntimeRebindRuleGenerator.runtimeRebindRuleCount = 0;
- compilerContext = new CompilerContext.Builder().module(new MockModuleDef()).build();
- finishSetUpWithCompilerContext();
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java b/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
index c3291ac..4c68029 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/JJSTestBase.java
@@ -294,7 +294,7 @@
public boolean shouldJDTInlineCompileTimeConstants() {
return false;
}
- }).compileMonolithic(compileMonolithic).build();
+ }).build();
compilerContext.getOptions().setSourceLevel(sourceLevel);
compilerContext.getOptions().setStrict(true);
CompilationState state =
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/TypeRefDepsCheckerTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/TypeRefDepsCheckerTest.java
deleted file mode 100644
index 50a3647..0000000
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/TypeRefDepsCheckerTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.jjs.impl;
-
-import com.google.gwt.dev.cfg.DepsInfoProvider;
-import com.google.gwt.dev.util.UnitTestTreeLogger;
-import com.google.gwt.thirdparty.guava.common.base.CharMatcher;
-import com.google.gwt.thirdparty.guava.common.base.Charsets;
-import com.google.gwt.thirdparty.guava.common.collect.LinkedHashMultimap;
-import com.google.gwt.thirdparty.guava.common.collect.Maps;
-import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
-import com.google.gwt.thirdparty.guava.common.io.Files;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Verifies log and file output of TypeRefDepsChecker.
- */
-public class TypeRefDepsCheckerTest extends TestCase {
-
- private static class MockDepsInfoProvider implements DepsInfoProvider {
-
- private Map<String, String> gwtXmlFilePathByModuleName = Maps.newHashMap();
- private SetMultimap<String, String> sourceModuleNamesByTypeSourceName =
- LinkedHashMultimap.create();
- private SetMultimap<String, String> transitiveDepModuleNamesByModuleName =
- LinkedHashMultimap.create();
-
- public void addGwtXmlFile(String moduleName, String gwtXmlFilePath) {
- gwtXmlFilePathByModuleName.put(moduleName, gwtXmlFilePath);
- }
-
- public void addModuleDep(String fromModuleName, String toModuleName) {
- transitiveDepModuleNamesByModuleName.put(fromModuleName, toModuleName);
- }
-
- @Override
- public String getGwtXmlFilePath(String moduleName) {
- return gwtXmlFilePathByModuleName.get(moduleName);
- }
-
- @Override
- public Set<String> getSourceModuleNames(String typeSourceName) {
- return sourceModuleNamesByTypeSourceName.get(typeSourceName);
- }
-
- @Override
- public Set<String> getTransitiveDepModuleNames(String targetModuleName) {
- return transitiveDepModuleNamesByModuleName.get(targetModuleName);
- }
-
- public void registerType(String typeSourceName, String sourceModuleName) {
- sourceModuleNamesByTypeSourceName.put(typeSourceName, sourceModuleName);
- }
- }
-
- public void testMultipleFromMultipleTo() throws IOException {
- // Setup environment.
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expectWarn("Type 'FromType' wants to reference type 'ToType' but can't because module "
- + "'FromModule1' has no dependency (neither direct nor transitive) on "
- + "'ToModule1|ToModule2|ToModule3'.", null);
- builder.expectWarn("Type 'FromType' wants to reference type 'ToType' but can't because module "
- + "'FromModule3' has no dependency (neither direct nor transitive) on "
- + "'ToModule1|ToModule2|ToModule3'.", null);
- UnitTestTreeLogger logger = builder.createLogger();
- File missingDepsFile = java.nio.file.Files.createTempFile("missingDepsFile", "txt").toFile();
- MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
- depsInfo.addModuleDep("FooModule", "FromModule1");
- depsInfo.addModuleDep("FooModule", "FromModule2");
- depsInfo.addModuleDep("FooModule", "FromModule3");
- depsInfo.addModuleDep("FooModule", "ToModule1");
- depsInfo.addModuleDep("FooModule", "ToModule2");
- depsInfo.addModuleDep("FooModule", "ToModule3");
- // Notice that FromModule2 can see just ToModule2 while the rest are completely blind.
- depsInfo.addModuleDep("FromModule2", "ToModule2");
- depsInfo.addGwtXmlFile("FromModule1", "com/google/gwt/FromModule1.gwt.xml");
- depsInfo.addGwtXmlFile("FromModule2", "com/google/gwt/FromModule2.gwt.xml");
- depsInfo.addGwtXmlFile("FromModule3", "com/google/gwt/FromModule3.gwt.xml");
- depsInfo.addGwtXmlFile("ToModule1", "com/google/gwt/ToModule1.gwt.xml");
- depsInfo.addGwtXmlFile("ToModule2", "com/google/gwt/ToModule2.gwt.xml");
- depsInfo.addGwtXmlFile("ToModule3", "com/google/gwt/ToModule3.gwt.xml");
- depsInfo.registerType("FromType", "FromModule1");
- depsInfo.registerType("FromType", "FromModule2");
- depsInfo.registerType("FromType", "FromModule3");
- depsInfo.registerType("ToType", "ToModule1");
- depsInfo.registerType("ToType", "ToModule2");
- depsInfo.registerType("ToType", "ToModule3");
- TypeRefDepsChecker typeRefDepsChecker =
- new TypeRefDepsChecker(logger, null, depsInfo, true, missingDepsFile);
- typeRefDepsChecker.maybeRecordTypeRef("FromType", "ToType");
-
- // Run typeRefDepsChecker.
- typeRefDepsChecker.verifyTypeRefsInModules();
-
- // Verify results.
- logger.assertCorrectLogEntries();
- assertEquals(
- // Line 1.
- "FromModule1\tcom/google/gwt/FromModule1.gwt.xml\t"
- + "ToModule1|ToModule2|ToModule3\tcom/google/gwt/ToModule1.gwt.xml|"
- + "com/google/gwt/ToModule2.gwt.xml|com/google/gwt/ToModule3.gwt.xml\t"
- + "Type 'FromType' wants to reference type 'ToType'.\n"
- // Line 2.
- + "FromModule3\tcom/google/gwt/FromModule3.gwt.xml\t"
- + "ToModule1|ToModule2|ToModule3\tcom/google/gwt/ToModule1.gwt.xml|"
- + "com/google/gwt/ToModule2.gwt.xml|com/google/gwt/ToModule3.gwt.xml\t"
- + "Type 'FromType' wants to reference type 'ToType'.",
- CharMatcher.WHITESPACE.trimFrom(Files.toString(missingDepsFile, Charsets.UTF_8)));
- }
-
- public void testOptionsDisabled() {
- // Setup environment.
- UnitTestTreeLogger logger = new UnitTestTreeLogger.Builder().createLogger();
- MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
- // Notice that BarModule can not see BazModule.
- depsInfo.addModuleDep("FooModule", "BarModule");
- depsInfo.addModuleDep("FooModule", "BazModule");
- depsInfo.addGwtXmlFile("FooModule", "com/google/gwt/FooModule.gwt.xml");
- depsInfo.addGwtXmlFile("BarModule", "com/google/gwt/BarModule.gwt.xml");
- depsInfo.addGwtXmlFile("BazModule", "com/google/gwt/BazModule.gwt.xml");
- depsInfo.registerType("BangType", "BarModule");
- depsInfo.registerType("ZingType", "BazModule");
- TypeRefDepsChecker typeRefDepsChecker =
- new TypeRefDepsChecker(logger, null, depsInfo, false, null);
- // Make a type from BarModule depend on a type from BazModule.
- typeRefDepsChecker.maybeRecordTypeRef("BangType", "ZingType");
-
- // Run typeRefDepsChecker.
- typeRefDepsChecker.verifyTypeRefsInModules();
-
- // Verify results.
- logger.assertCorrectLogEntries();
- }
-
- public void testSimple() throws IOException {
- // Setup environment.
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expectWarn(
- "Type 'BangType' wants to reference type 'ZingType' but can't because module "
- + "'BarModule' has no dependency (neither direct nor transitive) on 'BazModule'.", null);
- UnitTestTreeLogger logger = builder.createLogger();
- File missingDepsFile = java.nio.file.Files.createTempFile("missingDepsFile", "txt").toFile();
- MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
- // Notice that BarModule can not see BazModule.
- depsInfo.addModuleDep("FooModule", "BarModule");
- depsInfo.addModuleDep("FooModule", "BazModule");
- depsInfo.addGwtXmlFile("FooModule", "com/google/gwt/FooModule.gwt.xml");
- depsInfo.addGwtXmlFile("BarModule", "com/google/gwt/BarModule.gwt.xml");
- depsInfo.addGwtXmlFile("BazModule", "com/google/gwt/BazModule.gwt.xml");
- depsInfo.registerType("BangType", "BarModule");
- depsInfo.registerType("ZingType", "BazModule");
- TypeRefDepsChecker typeRefDepsChecker =
- new TypeRefDepsChecker(logger, null, depsInfo, true, missingDepsFile);
- // Make a type from BarModule depend on a type from BazModule.
- typeRefDepsChecker.maybeRecordTypeRef("BangType", "ZingType");
-
- // Run typeRefDepsChecker.
- typeRefDepsChecker.verifyTypeRefsInModules();
-
- // Verify results.
- logger.assertCorrectLogEntries();
- assertEquals(
- "BarModule\tcom/google/gwt/BarModule.gwt.xml\tBazModule\tcom/google/gwt/BazModule.gwt.xml"
- + "\tType 'BangType' wants to reference type 'ZingType'.",
- CharMatcher.WHITESPACE.trimFrom(Files.toString(missingDepsFile, Charsets.UTF_8)));
- }
-}
diff --git a/dev/core/test/com/google/gwt/dev/resource/impl/ResourceOracleImplTest.java b/dev/core/test/com/google/gwt/dev/resource/impl/ResourceOracleImplTest.java
index 1bbbff9..5364a0d 100644
--- a/dev/core/test/com/google/gwt/dev/resource/impl/ResourceOracleImplTest.java
+++ b/dev/core/test/com/google/gwt/dev/resource/impl/ResourceOracleImplTest.java
@@ -508,7 +508,6 @@
resourceOracleImpl.setPathPrefixes(pathPrefixSet);
resourceOracleImpl.scanResources(logger);
- resourceOracleImpl.printOverlappingModuleIncludeWarnings(logger);
logger.assertCorrectLogEntries();
}