Removes CompilationUnit.isCompiled().
- CompilationState retains a full map of all units, including error units.
- Only transitively valid units are passed into TypeOracle.
http://gwt-code-reviews.appspot.com/759801/show
Review by: kplatfoot
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8525 8db76d5a-ed1c-0410-87a9-c151d255dfc7
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 f0437ef..c224fc3 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
@@ -136,13 +136,13 @@
Collection<CompilationUnit> units) {
for (CompilationUnit unit : units) {
unitMap.put(unit.getTypeName(), unit);
- if (unit.isCompiled()) {
- for (CompiledClass compiledClass : unit.getCompiledClasses()) {
- classFileMap.put(compiledClass.getInternalName(), compiledClass);
- classFileMapBySource.put(compiledClass.getSourceName(), compiledClass);
- }
+ for (CompiledClass compiledClass : unit.getCompiledClasses()) {
+ classFileMap.put(compiledClass.getInternalName(), compiledClass);
+ classFileMapBySource.put(compiledClass.getSourceName(), compiledClass);
}
}
+ CompilationUnitInvalidator.retainValidUnits(logger, units,
+ compileMoreLater.getValidDependencies());
mediator.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 d3ee035..aa3a8e7 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -41,7 +41,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Map.Entry;
/**
* Manages a centralized cache for compiled units.
@@ -87,21 +86,18 @@
CompilationUnit unit = builder.build(compiledClasses, dependencies,
jsniMethods.values(), methodArgs,
cud.compilationResult().getProblems());
- if (!unit.isError()) {
- addValidUnit(unit);
-
- // Cache the valid unit for future compiles.
- ContentId contentId = builder.getContentId();
- unitCache.put(contentId, unit);
- if (builder instanceof ResourceCompilationUnitBuilder) {
- ResourceCompilationUnitBuilder rcub = (ResourceCompilationUnitBuilder) builder;
- ResourceTag resourceTag = new ResourceTag(rcub.getLastModifed(),
- contentId);
- resourceContentCache.put(builder.getLocation(), resourceTag);
- keepAliveLatestVersion.put(resourceTag, unit);
- } else if (builder instanceof GeneratedCompilationUnitBuilder) {
- keepAliveRecentlyGenerated.put(unit.getTypeName(), unit);
- }
+ addValidUnit(unit);
+ // Cache the valid unit for future compiles.
+ ContentId contentId = builder.getContentId();
+ unitCache.put(contentId, unit);
+ if (builder instanceof ResourceCompilationUnitBuilder) {
+ ResourceCompilationUnitBuilder rcub = (ResourceCompilationUnitBuilder) builder;
+ ResourceTag resourceTag = new ResourceTag(rcub.getLastModifed(),
+ contentId);
+ resourceContentCache.put(builder.getLocation(), resourceTag);
+ keepAliveLatestVersion.put(resourceTag, unit);
+ } else if (builder instanceof GeneratedCompilationUnitBuilder) {
+ keepAliveRecentlyGenerated.put(unit.getTypeName(), unit);
}
resultUnits.put(unit.getTypeName(), unit);
}
@@ -123,12 +119,6 @@
private transient Map<String, CompilationUnit> resultUnits;
private final Set<ContentId> validDependencies = new HashSet<ContentId>();
- /**
- * Provides compilation unit for unknown classes encountered by the
- * compiler if desired.
- */
- private AdditionalTypeProviderDelegate delegate;
-
public CompileMoreLater(AdditionalTypeProviderDelegate delegate) {
compiler.setAdditionalTypeProviderDelegate(delegate);
}
@@ -145,9 +135,10 @@
}
void addValidUnit(CompilationUnit unit) {
- assert unit.isCompiled();
compiler.addCompiledUnit(unit);
- validDependencies.add(unit.getContentId());
+ if (!unit.isError()) {
+ validDependencies.add(unit.getContentId());
+ }
}
void compile(TreeLogger logger,
@@ -220,19 +211,6 @@
return instance;
}
- private static void invalidateUnitsWithInvalidRefs(TreeLogger logger,
- Map<String, CompilationUnit> resultUnits, Set<ContentId> set) {
- Set<CompilationUnit> validResultUnits = new HashSet<CompilationUnit>(
- resultUnits.values());
- CompilationUnitInvalidator.retainValidUnits(logger, validResultUnits, set);
- for (Entry<String, CompilationUnit> entry : resultUnits.entrySet()) {
- CompilationUnit unit = entry.getValue();
- if (unit.isCompiled() && !validResultUnits.contains(unit)) {
- entry.setValue(new InvalidCompilationUnit(unit));
- }
- }
- }
-
/**
* JsProgram for collecting JSNI methods.
*/
@@ -301,7 +279,8 @@
if (tag != null && tag.getLastModified() == resource.getLastModified()) {
ContentId contentId = tag.getContentId();
CompilationUnit existingUnit = unitCache.get(contentId);
- if (existingUnit != null && existingUnit.isCompiled()) {
+ // Always try to recompile error units.
+ if (existingUnit != null && !existingUnit.isError()) {
resultUnits.put(existingUnit.getTypeName(), existingUnit);
}
}
@@ -327,10 +306,8 @@
}
compileMoreLater.compile(logger, builders, resultUnits);
- // Invalidate units with invalid refs.
- invalidateUnitsWithInvalidRefs(logger, resultUnits,
- Collections.<ContentId> emptySet());
- return new CompilationState(logger, resultUnits.values(), compileMoreLater);
+ return new CompilationState(logger, resultUnits.values(),
+ compileMoreLater);
} finally {
compilationStateBuilderProcess.end();
}
@@ -352,7 +329,8 @@
ContentId contentId = new ContentId(generatedUnit.getTypeName(),
generatedUnit.getStrongHash());
CompilationUnit existingUnit = unitCache.get(contentId);
- if (existingUnit != null && existingUnit.isCompiled()) {
+ // Always try to recompile error units.
+ if (existingUnit != null && !existingUnit.isError()) {
resultUnits.put(existingUnit.getTypeName(), existingUnit);
}
}
@@ -375,8 +353,6 @@
}
compileMoreLater.compile(logger, builders, resultUnits);
- invalidateUnitsWithInvalidRefs(logger, resultUnits,
- compileMoreLater.getValidDependencies());
return resultUnits.values();
}
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
index e508d2e..b7983ea 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
@@ -300,11 +300,6 @@
}
/**
- * Returns <code>true</code> if this unit is compiled and valid.
- */
- public abstract boolean isCompiled();
-
- /**
* Returns <code>true</code> if this unit had errors.
*/
public abstract boolean isError();
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
index 758c12f..851806c 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
@@ -66,11 +66,6 @@
}
@Override
- public boolean isCompiled() {
- return !hasErrors;
- }
-
- @Override
public boolean isError() {
return hasErrors;
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
index 1ec0d4f..24134bc 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
@@ -68,7 +68,7 @@
Set<CompilationUnit> currentlyValidUnits = new HashSet<CompilationUnit>();
Set<ContentId> currentlyValidRefs = new HashSet<ContentId>(knownValidRefs);
for (CompilationUnit unit : units) {
- if (unit.isCompiled()) {
+ if (!unit.isError()) {
currentlyValidUnits.add(unit);
currentlyValidRefs.add(unit.getContentId());
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/InvalidCompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/InvalidCompilationUnit.java
deleted file mode 100644
index c0fbeef..0000000
--- a/dev/core/src/com/google/gwt/dev/javac/InvalidCompilationUnit.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2009 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 org.eclipse.jdt.core.compiler.CategorizedProblem;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A compilation unit with errors.
- */
-class InvalidCompilationUnit extends CompilationUnit {
-
- private final CompilationUnit unit;
-
- public InvalidCompilationUnit(CompilationUnit unit) {
- this.unit = unit;
- }
-
- @Override
- public String getDisplayLocation() {
- return unit.getDisplayLocation();
- }
-
- @Override
- public List<JsniMethod> getJsniMethods() {
- return unit.getJsniMethods();
- }
-
- @Override
- public long getLastModified() {
- return unit.getLastModified();
- }
-
- @Override
- public MethodArgNamesLookup getMethodArgs() {
- return unit.getMethodArgs();
- }
-
- @Override
- @Deprecated
- public String getSource() {
- return unit.getSource();
- }
-
- @Override
- public String getTypeName() {
- return unit.getTypeName();
- }
-
- @Override
- public boolean isCompiled() {
- return false;
- }
-
- @Override
- public boolean isError() {
- return false;
- }
-
- @Override
- @Deprecated
- public boolean isGenerated() {
- return unit.isGenerated();
- }
-
- @Override
- @Deprecated
- public boolean isSuperSource() {
- return unit.isSuperSource();
- }
-
- @Override
- Collection<CompiledClass> getCompiledClasses() {
- return unit.getCompiledClasses();
- }
-
- @Override
- ContentId getContentId() {
- return unit.getContentId();
- }
-
- @Override
- Set<ContentId> getDependencies() {
- return unit.getDependencies();
- }
-
- @Override
- CategorizedProblem[] getProblems() {
- return unit.getProblems();
- }
-
-}
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 9020b00..192c94f 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
@@ -428,7 +428,6 @@
}
public void addCompiledUnit(CompilationUnit unit) {
- assert unit.isCompiled();
addPackages(Shared.getPackageName(unit.getTypeName()).replace('.', '/'));
addBinaryTypes(unit.getCompiledClasses());
contentIdMap.put(unit.getDisplayLocation(), unit.getContentId());
diff --git a/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java b/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
index 328fe17..b197ea2 100644
--- a/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
+++ b/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
@@ -79,6 +79,11 @@
public class TypeOracleMediator {
/**
+ * Turn on to trace class processing.
+ */
+ private static final boolean TRACE_CLASSES = false;
+
+ /**
* Pairs of bits to convert from ASM Opcodes.* to Shared.* bitfields.
*/
private static final int[] ASM_TO_SHARED_MODIFIERS = new int[] {
@@ -301,9 +306,6 @@
CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase", "Visit Class Files");
classMap = new HashMap<String, CollectClassData>();
for (CompilationUnit unit : units) {
- if (!unit.isCompiled()) {
- continue;
- }
Collection<CompiledClass> compiledClasses = unit.getCompiledClasses();
for (CompiledClass compiledClass : compiledClasses) {
CollectClassData cv = processClass(compiledClass);
@@ -323,9 +325,6 @@
allMethodArgs = new MethodArgNamesLookup();
Set<JRealClassType> unresolvedTypes = new HashSet<JRealClassType>();
for (CompilationUnit unit : units) {
- if (!unit.isCompiled()) {
- continue;
- }
Collection<CompiledClass> compiledClasses = unit.getCompiledClasses();
for (CompiledClass compiledClass : compiledClasses) {
String internalName = compiledClass.getInternalName();
@@ -564,7 +563,7 @@
ClassReader reader = new ClassReader(classBytes);
CollectClassData mcv = new CollectClassData();
ClassVisitor cv = mcv;
- if (false) {
+ if (TRACE_CLASSES) {
cv = new TraceClassVisitor(cv, new PrintWriter(System.out));
}
reader.accept(cv, 0);
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
index eff8673..05589b7 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
@@ -84,7 +84,6 @@
static void assertUnitsChecked(Collection<CompilationUnit> units) {
for (CompilationUnit unit : units) {
- assertTrue(unit.isCompiled());
assertFalse(unit.isError());
assertTrue(unit.getCompiledClasses().size() > 0);
}
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 229dead..746b105 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -704,10 +704,6 @@
} else if (unit.isError()) {
errMsg = "The test class '" + typeName
+ "' had compile errors; check log for details";
- } else if (!unit.isCompiled()) {
- errMsg = "The test class '"
- + typeName
- + "' depends on a unit that had compile errors; check log for details";
} else {
errMsg = "Unexpected error: the test class '"
+ typeName