Revision: 8525
Author: [email protected]
Date: Thu Aug 12 07:56:03 2010
Log: 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
http://code.google.com/p/google-web-toolkit/source/detail?r=8525
Deleted:
/trunk/dev/core/src/com/google/gwt/dev/javac/InvalidCompilationUnit.java
Modified:
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
/trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
/trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
/trunk/user/src/com/google/gwt/junit/JUnitShell.java
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/InvalidCompilationUnit.java
Mon Jan 11 17:58:07 2010
+++ /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();
- }
-
-}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java Wed
Aug 11 07:24:43 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationState.java Thu
Aug 12 07:56:03 2010
@@ -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);
}
}
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
Fri Aug 6 12:01:02 2010
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
Thu Aug 12 07:56:03 2010
@@ -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,
@@ -219,19 +210,6 @@
public static CompilationStateBuilder get() {
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();
}
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Mon
Aug 2 12:33:56 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Thu
Aug 12 07:56:03 2010
@@ -298,11 +298,6 @@
public final int hashCode() {
return super.hashCode();
}
-
- /**
- * Returns <code>true</code> if this unit is compiled and valid.
- */
- public abstract boolean isCompiled();
/**
* Returns <code>true</code> if this unit had errors.
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
Mon Aug 2 12:33:56 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
Thu Aug 12 07:56:03 2010
@@ -64,11 +64,6 @@
public MethodArgNamesLookup getMethodArgs() {
return methodArgs;
}
-
- @Override
- public boolean isCompiled() {
- return !hasErrors;
- }
@Override
public boolean isError() {
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
Fri Dec 4 14:22:11 2009
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
Thu Aug 12 07:56:03 2010
@@ -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());
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Wed Aug
11 07:24:43 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Thu Aug
12 07:56:03 2010
@@ -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());
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
Wed Aug 11 07:24:43 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/TypeOracleMediator.java
Thu Aug 12 07:56:03 2010
@@ -78,6 +78,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.
*/
@@ -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);
=======================================
---
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
Thu Nov 19 13:48:07 2009
+++
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
Thu Aug 12 07:56:03 2010
@@ -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);
}
=======================================
--- /trunk/user/src/com/google/gwt/junit/JUnitShell.java Wed Aug 4
05:46:33 2010
+++ /trunk/user/src/com/google/gwt/junit/JUnitShell.java Thu Aug 12
07:56:03 2010
@@ -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
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors