Revision: 9940
Author: [email protected]
Date: Tue Apr 5 06:11:45 2011
Log: Supress errors when building the Type Oracle.
This patch supresses errors (turns them into TRACE and DEBUG level log
messages)
during the TypeOracle build. When building the AST, if an error is
encountered, the
CompilationState (or global CompilationStateBuilder cache) is consulted to
find any errors in a type that has a problem, or any dependencies of that
type.
Review at http://gwt-code-reviews.appspot.com/1385810
http://code.google.com/p/google-web-toolkit/source/detail?r=9940
Added:
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
Modified:
/trunk/dev/core/src/com/google/gwt/dev/DevModeBase.java
/trunk/dev/core/src/com/google/gwt/dev/Precompile.java
/trunk/dev/core/src/com/google/gwt/dev/cfg/ConditionWhenTypeAssignableTo.java
/trunk/dev/core/src/com/google/gwt/dev/cfg/DeferredBindingQuery.java
/trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
/trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
/trunk/dev/core/src/com/google/gwt/dev/javac/Dependencies.java
/trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
/trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
/trunk/dev/core/src/com/google/gwt/dev/util/Util.java
/trunk/dev/core/test/com/google/gwt/dev/cfg/ConditionTest.java
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
/trunk/dev/core/test/com/google/gwt/dev/javac/MemoryUnitCacheTest.java
/trunk/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
/trunk/dev/core/test/com/google/gwt/dev/jjs/impl/RunAsyncNameTest.java
/trunk/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
/trunk/user/src/com/google/gwt/junit/JUnitShell.java
=======================================
--- /dev/null
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
Tue Apr 5 06:11:45 2011
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * 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.core.ext.TreeLogger.HelpInfo;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.dev.util.Messages;
+import com.google.gwt.dev.util.Util;
+
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+
+/**
+ * Handles some details of reporting errors in {@link CompilationUnit}s to
the
+ * console.
+ */
+public class CompilationProblemReporter {
+
+ /**
+ * Used to lazily retrieve source if needed for reporting an error.
+ */
+ public interface SourceFetcher {
+ String getSource();
+ }
+
+ /**
+ * Provides a meaningful error message when a type is missing from the
{@link
+ * import com.google.gwt.core.ext.typeinfo.TypeOracle} or
+ * {@link com.google.gwt.dev.shell.CompilingClassLoader}.
+ *
+ * @param logger logger for logging errors to the console
+ * @param missingType The qualified source name of the type to report
+ * @param unitMap if available, pass
+ * {@link CompilationState#getCompilationUnitMap()}.
+ */
+ public static void logMissingTypeErrorWithHints(TreeLogger logger,
String missingType,
+ CompilationState compilationState) {
+ logDependentErrors(logger, missingType, compilationState);
+ logger = logger.branch(TreeLogger.ERROR, "Unable to find type '" +
missingType + "'", null);
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ URL sourceURL = Util.findSourceInClassPath(cl, missingType);
+ if (sourceURL != null) {
+ if (missingType.indexOf(".client.") != -1) {
+ Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
+ Messages.HINT_CHECK_MODULE_INHERITANCE.log(logger, null);
+ } else {
+ // Give the best possible hint here.
+ //
+ if (Util.findSourceInClassPath(cl, missingType) == null) {
+ Messages.HINT_CHECK_MODULE_NONCLIENT_SOURCE_DECL.log(logger,
null);
+ } else {
+ Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
+ }
+ }
+ } else if (!missingType.equals("java.lang.Object")) {
+ Messages.HINT_CHECK_TYPENAME.log(logger, missingType, null);
+ Messages.HINT_CHECK_CLASSPATH_SOURCE_ENTRIES.log(logger, null);
+ }
+
+ /*
+ * For missing JRE emulated classes (e.g. Object), or the main GWT
+ * libraries, there are special warnings.
+ */
+ if (missingType.indexOf("java.lang.") == 0 ||
missingType.indexOf("com.google.gwt.core.") == 0) {
+ Messages.HINT_CHECK_INHERIT_CORE.log(logger, null);
+ } else if (missingType.indexOf("com.google.gwt.user.") == 0) {
+ Messages.HINT_CHECK_INHERIT_USER.log(logger, null);
+ }
+ }
+
+ public static void reportAllErrors(TreeLogger logger, CompilationState
compilationState,
+ boolean suppressErrors) {
+ for (CompilationUnit unit : compilationState.getCompilationUnits()) {
+ if (unit.isError()) {
+ reportErrors(logger, unit, suppressErrors);
+ }
+ }
+ }
+
+ /**
+ * Report an error in a compilation unit to the console.
+ *
+ * @param logger logger for reporting errors to the console
+ * @param problems problems to report on the console.
+ * @param fileName Name of the source file for the unit where the problem
+ * originated.
+ * @param isError <code>true</code> if this is considered a fatal
compilation
+ * error.
+ * @param supressErrors Controls the log level for logging errors. See
+ * {@link #reportErrors(TreeLogger, CompilationUnit, boolean)}.
+ * @return a branch of the logger parameter for logging further problems.
+ */
+ public static TreeLogger reportErrors(TreeLogger logger,
CategorizedProblem[] problems,
+ String fileName, boolean isError, SourceFetcher fetcher, String
typeName,
+ boolean suppressErrors) {
+ if (problems == null || problems.length == 0) {
+ return null;
+ }
+ TreeLogger.Type warnLogLevel;
+ TreeLogger.Type errorLogLevel;
+ if (suppressErrors) {
+ errorLogLevel = TreeLogger.TRACE;
+ warnLogLevel = TreeLogger.DEBUG;
+ } else {
+ errorLogLevel = TreeLogger.ERROR;
+ warnLogLevel = TreeLogger.WARN;
+ }
+
+ TreeLogger branch = null;
+ // Log the errors and GWT warnings.
+ for (CategorizedProblem problem : problems) {
+ TreeLogger.Type logLevel;
+ if (problem.isError()) {
+ // Log errors.
+ logLevel = errorLogLevel;
+ // Only log GWT-specific warnings.
+ } else if (problem.isWarning() && problem instanceof GWTProblem) {
+ logLevel = warnLogLevel;
+ } else {
+ // Ignore all other problems.
+ continue;
+ }
+ // Append 'Line #: msg' to the error message.
+ StringBuffer msgBuf = new StringBuffer();
+ int line = problem.getSourceLineNumber();
+ if (line > 0) {
+ msgBuf.append("Line ");
+ msgBuf.append(line);
+ msgBuf.append(": ");
+ }
+ msgBuf.append(problem.getMessage());
+
+ HelpInfo helpInfo = null;
+ if (problem instanceof GWTProblem) {
+ GWTProblem gwtProblem = (GWTProblem) problem;
+ helpInfo = gwtProblem.getHelpInfo();
+ }
+ if (branch == null) {
+ Type branchType = isError ? errorLogLevel : warnLogLevel;
+ String branchString = isError ? "Errors" : "Warnings";
+ branch = logger.branch(branchType, branchString + " in '" +
fileName + "'", null);
+ }
+ branch.log(logLevel, msgBuf.toString(), null, helpInfo);
+ }
+
+ if (branch != null && fetcher != null) {
+ CompilationProblemReporter.maybeDumpSource(branch, fileName,
fetcher, typeName);
+ }
+
+ return branch;
+ }
+
+ /**
+ * Logs errors to the console.
+ *
+ * @param logger logger for reporting errors to the console
+ * @param unit Compilation unit that may have errors
+ * @param supressErrors Controls he log level for logging errors. If
+ * <code>false</code> is passed, compilation errors are logged
at
+ * TreeLogger.ERROR and warnings logged at TreeLogger.WARN. If
+ * <code>true</code> is passed, compilation errors are logged at
+ * TreeLogger.TRACE and TreeLogger.DEBUG.
+ * @return <code>true</code> if an error was logged.
+ */
+ @SuppressWarnings("deprecation")
+ public static boolean reportErrors(TreeLogger logger, final
CompilationUnit unit,
+ boolean suppressErrors) {
+ CategorizedProblem[] problems = unit.getProblems();
+ if (problems == null || problems.length == 0) {
+ return false;
+ }
+ TreeLogger branch =
+ CompilationProblemReporter.reportErrors(logger,
unit.getProblems(), unit
+ .getResourceLocation(), unit.isError(), new SourceFetcher() {
+
+ public String getSource() {
+ return unit.getSource();
+ }
+
+ }, unit.getTypeName(), suppressErrors);
+ return branch != null;
+ }
+
+ private static void addUnitToVisit(Map<String, CompilationUnit> unitMap,
String typeName,
+ Queue<CompilationUnit> toVisit) {
+ CompilationUnit found = unitMap.get(typeName);
+ if (found != null) {
+ toVisit.add(found);
+ }
+ }
+
+ private static boolean isCompilationUnitOnDisk(String loc) {
+ try {
+ if (new File(loc).exists()) {
+ return true;
+ }
+
+ URL url = new URL(loc);
+ String s = url.toExternalForm();
+ if (s.startsWith("file:") || s.startsWith("jar:file:") ||
s.startsWith("zip:file:")) {
+ return true;
+ }
+ } catch (MalformedURLException e) {
+ // Probably not really on disk.
+ }
+ return false;
+ }
+
+ private static void logDependentErrors(TreeLogger logger, String
missingType,
+ CompilationState compilationState) {
+ final Set<CompilationUnit> visited = new HashSet<CompilationUnit>();
+ final Queue<CompilationUnit> toVisit = new
LinkedList<CompilationUnit>();
+
+ Map<String, CompilationUnit> unitMap = compilationState.unitMap;
+
+ /*
+ * Traverses CompilationUnits enqueued in toVisit(), calling {@link
+ * #addUnitsToVisit(String)} as it encounters dependencies on the
node. Each
+ * CompilationUnit is visited only once, and only if it is reachable
via the
+ * {@link Dependencies} graph.
+ */
+ addUnitToVisit(unitMap, missingType, toVisit);
+
+ while (!toVisit.isEmpty()) {
+ CompilationUnit unit = toVisit.remove();
+ if (visited.contains(unit)) {
+ continue;
+ }
+ visited.add(unit);
+ CompilationProblemReporter.reportErrors(logger, unit, false);
+
+ Dependencies deps = unit.getDependencies();
+ for (String ref : deps.getApiRefs()) {
+ addUnitToVisit(unitMap, ref, toVisit);
+ }
+ }
+ }
+
+ /**
+ * Give the developer a chance to see the in-memory source that failed.
+ */
+ private static void maybeDumpSource(TreeLogger logger, String location,
SourceFetcher fetcher,
+ String typeName) {
+
+ if (location.startsWith("/mock/")) {
+ // Unit test mocks, don't dump to disk.
+ return;
+ }
+
+ if (CompilationProblemReporter.isCompilationUnitOnDisk(location)) {
+ // Don't write another copy.
+ return;
+ }
+
+ if (!logger.isLoggable(TreeLogger.INFO)) {
+ // Don't bother dumping source if they can't see the related message.
+ return;
+ }
+
+ File tmpSrc;
+ Throwable caught = null;
+ try {
+ // The tempFile prefix must be at least 3 characters
+ while (typeName.length() < 3) {
+ typeName = "_" + typeName;
+ }
+ tmpSrc = File.createTempFile(typeName, ".java");
+ Util.writeStringAsFile(tmpSrc, fetcher.getSource());
+ String dumpPath = tmpSrc.getAbsolutePath();
+ logger.log(TreeLogger.INFO, "See snapshot: " + dumpPath, null);
+ return;
+ } catch (IOException e) {
+ caught = e;
+ }
+ logger.log(TreeLogger.INFO, "Unable to dump source to disk", caught);
+ }
+}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/DevModeBase.java Mon Apr 4
04:54:01 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/DevModeBase.java Tue Apr 5
03:08:39 2011
@@ -104,8 +104,10 @@
ModuleDef moduleDef = loadModule(logger, moduleName, true);
assert (moduleDef != null);
+ CompilationState compilationState =
+ moduleDef.getCompilationState(logger, !options.isStrict());
ShellModuleSpaceHost host =
- doCreateShellModuleSpaceHost(logger,
moduleDef.getCompilationState(logger), moduleDef);
+ doCreateShellModuleSpaceHost(logger, compilationState,
moduleDef);
return host;
} catch (RuntimeException e) {
logger.log(TreeLogger.ERROR, "Exception initializing module", e);
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/Precompile.java Mon Mar 21
12:22:19 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/Precompile.java Tue Apr 5
03:08:39 2011
@@ -416,7 +416,7 @@
File genDir) {
Event validateEvent =
SpeedTracerLogger.start(CompilerEventType.VALIDATE);
try {
- CompilationState compilationState =
module.getCompilationState(logger);
+ CompilationState compilationState =
module.getCompilationState(logger, !jjsOptions.isStrict());
if (jjsOptions.isStrict() && compilationState.hasErrors()) {
abortDueToStrictMode(logger);
}
@@ -502,7 +502,7 @@
new GraphicsInitThread().start();
try {
- CompilationState compilationState =
module.getCompilationState(logger);
+ CompilationState compilationState =
module.getCompilationState(logger, !jjsOptions.isStrict());
if (jjsOptions.isStrict() && compilationState.hasErrors()) {
abortDueToStrictMode(logger);
}
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/cfg/ConditionWhenTypeAssignableTo.java
Wed Aug 11 09:22:23 2010
+++
/trunk/dev/core/src/com/google/gwt/dev/cfg/ConditionWhenTypeAssignableTo.java
Tue Apr 5 03:08:39 2011
@@ -19,7 +19,7 @@
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dev.util.Util;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
/**
* A deferred binding condition to determine whether the type being
rebound is
@@ -49,7 +49,8 @@
String testType = query.getTestType();
JClassType fromType = typeOracle.findType(testType);
if (fromType == null) {
- Util.logMissingTypeErrorWithHints(logger, testType);
+ CompilationProblemReporter.logMissingTypeErrorWithHints(logger,
testType,
+ query.getCompilationState());
throw new UnableToCompleteException();
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/cfg/DeferredBindingQuery.java
Tue Mar 8 09:11:26 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/cfg/DeferredBindingQuery.java
Tue Apr 5 03:08:39 2011
@@ -18,6 +18,7 @@
import com.google.gwt.core.ext.PropertyOracle;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationState;
import java.util.Set;
@@ -30,8 +31,7 @@
private final Set<String> linkerNames;
private final PropertyOracle propertyOracle;
private final String testType;
- private final TypeOracle typeOracle;
-
+ private final CompilationState compilationState;
/**
* Construct a query for contexts where a type is not available. Such a
query
* also does not need a type oracle.
@@ -44,17 +44,21 @@
/**
* Construct a fully general query, including a query type and type
oracle.
*/
- public DeferredBindingQuery(PropertyOracle propertyOracle,
- Set<String> linkerNames, TypeOracle typeOracle, String testType) {
+ public DeferredBindingQuery(PropertyOracle propertyOracle, Set<String>
linkerNames,
+ CompilationState compilationState, String testType) {
assert propertyOracle != null;
assert linkerNames != null;
this.propertyOracle = propertyOracle;
this.linkerNames = linkerNames;
- this.typeOracle = typeOracle;
this.testType = testType;
+ this.compilationState = compilationState;
}
+ public CompilationState getCompilationState() {
+ return compilationState;
+ }
+
public int getFallbackEvaluationCost() {
return fallbackEvalCost;
}
@@ -72,7 +76,7 @@
}
public TypeOracle getTypeOracle() {
- return typeOracle;
+ return compilationState.getTypeOracle();
}
public void setFallbackEvaluationCost(int cost) {
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java Fri Jan 7
11:13:03 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java Tue Apr 5
03:08:39 2011
@@ -23,6 +23,7 @@
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.CompilationStateBuilder;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.resource.ResourceOracle;
import com.google.gwt.dev.resource.impl.DefaultFilters;
@@ -318,12 +319,16 @@
public String getCanonicalName() {
return name;
}
-
- public synchronized CompilationState getCompilationState(TreeLogger
logger)
+
+ public CompilationState getCompilationState(TreeLogger logger) throws
UnableToCompleteException {
+ return getCompilationState(logger, false);
+ }
+
+ public synchronized CompilationState getCompilationState(TreeLogger
logger, boolean suppressErrors)
throws UnableToCompleteException {
doRefresh();
- CompilationState compilationState = CompilationStateBuilder.buildFrom(
- logger, lazySourceOracle.getResources());
+ CompilationState compilationState =
+ CompilationStateBuilder.buildFrom(logger,
lazySourceOracle.getResources(), null, suppressErrors);
checkForSeedTypes(logger, compilationState);
return compilationState;
}
@@ -499,7 +504,8 @@
boolean seedTypesMissing = false;
TypeOracle typeOracle = compilationState.getTypeOracle();
if (typeOracle.findType("java.lang.Object") == null) {
- Util.logMissingTypeErrorWithHints(logger, "java.lang.Object");
+
CompilationProblemReporter.logMissingTypeErrorWithHints(logger, "java.lang.Object",
+ compilationState);
seedTypesMissing = true;
} else {
TreeLogger branch = logger.branch(TreeLogger.TRACE,
@@ -508,7 +514,8 @@
for (int i = 0; i < typeNames.length; i++) {
String typeName = typeNames[i];
if (typeOracle.findType(typeName) == null) {
- Util.logMissingTypeErrorWithHints(branch, typeName);
+ CompilationProblemReporter.logMissingTypeErrorWithHints(branch,
typeName,
+ compilationState);
seedTypesMissing = true;
}
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java Tue Mar 8
09:11:26 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/cfg/Rule.java Tue Apr 5
03:08:39 2011
@@ -49,7 +49,7 @@
throws UnableToCompleteException {
DeferredBindingQuery query = new DeferredBindingQuery(
context.getPropertyOracle(), context.getActiveLinkerNames(),
- context.getTypeOracle(), typeName);
+ context.getCompilationState(), typeName);
boolean result = rootCondition.isTrue(logger, query);
fallbackEvalCost = query.getFallbackEvaluationCost();
return result;
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
Fri Mar 25 16:48:01 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
Tue Apr 5 03:08:39 2011
@@ -143,6 +143,8 @@
private final Map<String, CompiledClass> allValidClasses = new
HashMap<String, CompiledClass>();
private final GwtAstBuilder astBuilder = new GwtAstBuilder();
+
+ private final boolean suppressErrors;
private transient LinkedBlockingQueue<CompilationUnitBuilder>
buildQueue;
@@ -157,15 +159,16 @@
private final JSORestrictionsChecker.CheckerState jsoState =
new JSORestrictionsChecker.CheckerState();
- public CompileMoreLater(AdditionalTypeProviderDelegate delegate) {
+ public CompileMoreLater(AdditionalTypeProviderDelegate delegate,
boolean suppressErrors) {
compiler.setAdditionalTypeProviderDelegate(delegate);
+ this.suppressErrors = suppressErrors;
}
public Collection<CompilationUnit> addGeneratedTypes(TreeLogger logger,
Collection<GeneratedUnit> generatedUnits) {
Event event =
SpeedTracerLogger.start(DevModeEventType.CSB_ADD_GENERATED_TYPES);
try {
- return doBuildGeneratedTypes(logger, generatedUnits, this);
+ return doBuildGeneratedTypes(logger, generatedUnits, this,
suppressErrors);
} finally {
event.end();
}
@@ -184,7 +187,8 @@
Collection<CompilationUnit> compile(TreeLogger logger,
Collection<CompilationUnitBuilder> builders,
- Map<CompilationUnitBuilder, CompilationUnit> cachedUnits,
EventType eventType) {
+ Map<CompilationUnitBuilder, CompilationUnit> cachedUnits,
EventType eventType,
+ boolean suppressErrors) {
// Initialize the set of valid classes to the initially cached units.
for (CompilationUnit unit : cachedUnits.values()) {
for (CompiledClass cc : unit.getCompiledClasses()) {
@@ -291,8 +295,16 @@
// Sort, then report all errors (re-report for cached units).
Collections.sort(resultUnits, CompilationUnit.COMPARATOR);
logger = logger.branch(TreeLogger.DEBUG, "Validating newly compiled
units");
+ int errorCount = 0;
for (CompilationUnit unit : resultUnits) {
- CompilationUnitInvalidator.reportErrors(logger, unit);
+ if (CompilationProblemReporter.reportErrors(logger, unit,
suppressErrors)) {
+ errorCount++;
+ }
+ }
+ if (suppressErrors && errorCount > 0
&& !logger.isLoggable(TreeLogger.TRACE)) {
+ logger.log(TreeLogger.INFO, "Ignored " + errorCount + " unit"
+ + (errorCount > 1 ? "s" : "")
+ + " with compilation errors in first pass. Specify -logLevel
DEBUG to see all errors");
}
return resultUnits;
}
@@ -301,23 +313,24 @@
private static final CompilationStateBuilder instance = new
CompilationStateBuilder();
public static CompilationState buildFrom(TreeLogger logger,
Set<Resource> resources) {
- Event event =
SpeedTracerLogger.start(DevModeEventType.CSB_BUILD_FROM_ORACLE);
- try {
- return instance.doBuildFrom(logger, resources, null);
- } finally {
- event.end();
- }
+ return buildFrom(logger, resources, null, false);
}
public static CompilationState buildFrom(TreeLogger logger,
Set<Resource> resources,
- AdditionalTypeProviderDelegate delegate) {
+ AdditionalTypeProviderDelegate delegate) {
+ return buildFrom(logger, resources, delegate, false);
+ }
+
+ public static CompilationState buildFrom(TreeLogger logger,
Set<Resource> resources,
+ AdditionalTypeProviderDelegate delegate, boolean suppressErrors) {
Event event =
SpeedTracerLogger.start(DevModeEventType.CSB_BUILD_FROM_ORACLE);
try {
- return instance.doBuildFrom(logger, resources, delegate);
+ return instance.doBuildFrom(logger, resources, delegate,
suppressErrors);
} finally {
event.end();
}
}
+
public static CompilationStateBuilder get() {
return instance;
@@ -337,13 +350,6 @@
* explicit call to {@link #init(TreeLogger, File)}.
*/
private UnitCache unitCache = new MemoryUnitCache();
-
- /**
- * Build a new compilation state from a source oracle.
- */
- public CompilationState doBuildFrom(TreeLogger logger, Set<Resource>
resources) {
- return doBuildFrom(logger, resources, null);
- }
/**
* Build a new compilation state from a source oracle. Allow the caller
to
@@ -352,7 +358,7 @@
* TODO: maybe use a finer brush than to synchronize the whole thing.
*/
public synchronized CompilationState doBuildFrom(TreeLogger logger,
Set<Resource> resources,
- AdditionalTypeProviderDelegate compilerDelegate) {
+ AdditionalTypeProviderDelegate compilerDelegate, boolean
suppressErrors) {
// Units we definitely want to build.
List<CompilationUnitBuilder> builders = new
ArrayList<CompilationUnitBuilder>();
@@ -361,7 +367,7 @@
Map<CompilationUnitBuilder, CompilationUnit> cachedUnits =
new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
- CompileMoreLater compileMoreLater = new
CompileMoreLater(compilerDelegate);
+ CompileMoreLater compileMoreLater = new
CompileMoreLater(compilerDelegate, suppressErrors);
// For each incoming Java source file...
for (Resource resource : resources) {
@@ -386,9 +392,13 @@
Collection<CompilationUnit> resultUnits =
compileMoreLater.compile(logger, builders, cachedUnits,
- CompilerEventType.JDT_COMPILER_CSB_FROM_ORACLE);
+ CompilerEventType.JDT_COMPILER_CSB_FROM_ORACLE,
suppressErrors);
return new CompilationState(logger, resultUnits, compileMoreLater);
}
+
+ public CompilationState doBuildFrom(TreeLogger logger, Set<Resource>
resources, boolean suppressErrors) {
+ return doBuildFrom(logger, resources, null, suppressErrors);
+ }
/**
* Compile new generated units into an existing state.
@@ -396,7 +406,8 @@
* TODO: maybe use a finer brush than to synchronize the whole thing.
*/
synchronized Collection<CompilationUnit>
doBuildGeneratedTypes(TreeLogger logger,
- Collection<GeneratedUnit> generatedUnits, CompileMoreLater
compileMoreLater) {
+ Collection<GeneratedUnit> generatedUnits, CompileMoreLater
compileMoreLater,
+ boolean suppressErrors) {
// Units we definitely want to build.
List<CompilationUnitBuilder> builders = new
ArrayList<CompilationUnitBuilder>();
@@ -423,6 +434,6 @@
builders.add(builder);
}
return compileMoreLater.compile(logger, builders, cachedUnits,
- CompilerEventType.JDT_COMPILER_CSB_GENERATED);
+ CompilerEventType.JDT_COMPILER_CSB_GENERATED, suppressErrors);
}
}
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
Thu Mar 24 15:47:57 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitInvalidator.java
Tue Apr 5 03:08:39 2011
@@ -16,11 +16,7 @@
package com.google.gwt.dev.javac;
import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.HelpInfo;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.dev.util.Util;
-
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
+
import java.util.Collection;
import java.util.HashSet;
@@ -36,16 +32,6 @@
* other invalidate units.
*/
public class CompilationUnitInvalidator {
-
- @SuppressWarnings("deprecation")
- public static void reportErrors(TreeLogger logger, CompilationUnit unit)
{
- TreeLogger branch = reportErrors(logger, unit.getProblems(),
- unit.getResourceLocation(), unit.isError());
- if (branch != null) {
- Util.maybeDumpSource(branch, unit.getResourceLocation(),
unit.getSource(),
- unit.getTypeName());
- }
- }
public static void retainValidUnits(TreeLogger logger,
Collection<CompilationUnit> units, Map<String, CompiledClass>
validClasses) {
@@ -93,49 +79,4 @@
units.retainAll(currentlyValidUnits);
}
-
- private static TreeLogger reportErrors(TreeLogger logger,
- CategorizedProblem[] problems, String fileName, boolean isError) {
- if (problems == null || problems.length == 0) {
- return null;
- }
- TreeLogger branch = null;
- // Log the errors and GWT warnings.
- for (CategorizedProblem problem : problems) {
- TreeLogger.Type logLevel;
- if (problem.isError()) {
- // Log errors.
- logLevel = TreeLogger.ERROR;
- // Only log GWT-specific warnings.
- } else if (problem.isWarning() && problem instanceof GWTProblem) {
- logLevel = TreeLogger.WARN;
- } else {
- // Ignore all other problems.
- continue;
- }
- // Append 'Line #: msg' to the error message.
- StringBuffer msgBuf = new StringBuffer();
- int line = problem.getSourceLineNumber();
- if (line > 0) {
- msgBuf.append("Line ");
- msgBuf.append(line);
- msgBuf.append(": ");
- }
- msgBuf.append(problem.getMessage());
-
- HelpInfo helpInfo = null;
- if (problem instanceof GWTProblem) {
- GWTProblem gwtProblem = (GWTProblem) problem;
- helpInfo = gwtProblem.getHelpInfo();
- }
- if (branch == null) {
- Type branchType = isError ? TreeLogger.ERROR : TreeLogger.WARN;
- String branchString = isError ? "Errors" : "Warnings";
- branch = logger.branch(branchType, branchString + " in '" +
fileName
- + "'", null);
- }
- branch.log(logLevel, msgBuf.toString(), null, helpInfo);
- }
- return branch;
- }
-}
+}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/Dependencies.java Thu Mar
24 15:47:57 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/Dependencies.java Tue Apr
5 03:08:39 2011
@@ -82,6 +82,13 @@
}
this.apiRefs = apiRefs;
}
+
+ /**
+ * Returns the list of API references used by {@link TypeOracle} to
determine type availability.
+ */
+ List<String> getApiRefs() {
+ return apiRefs;
+ }
/**
* Returns the list of deps that cannot be resolved at all.
@@ -115,7 +122,7 @@
}
}
}
-
+
/**
* Validate that all of my existing dependencies can be found in the
global
* set of valid classes, and resolve to structurally identical APIs.
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
Wed Feb 16 11:06:56 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
Tue Apr 5 03:08:39 2011
@@ -521,6 +521,9 @@
return this;
}
+ public CompilationState getCompilationState() {
+ return compilationState;
+ }
/**
* Gets all committed Java units.
*/
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
Mon Mar 28 09:42:49 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
Tue Apr 5 03:08:39 2011
@@ -40,6 +40,8 @@
import com.google.gwt.dev.Permutation;
import com.google.gwt.dev.cfg.ConfigurationProperty;
import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
+import com.google.gwt.dev.javac.CompilationProblemReporter.SourceFetcher;
import com.google.gwt.dev.jdt.RebindPermutationOracle;
import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd;
import com.google.gwt.dev.jjs.CorrelationFactory.DummyCorrelationFactory;
@@ -139,7 +141,6 @@
import com.google.gwt.soyc.SoycDashboard;
import com.google.gwt.soyc.io.ArtifactsOutputDirectory;
-import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
@@ -835,6 +836,17 @@
return stats;
}
+ /**
+ * Look through the list of compiled units for errors and log them to the
+ * console.
+ *
+ * @param logger logger to use for compilation errors
+ * @param cuds compiled units to analyze for errors.
+ * @param itemizeErrors log each error or simply log one message if the
build
+ * failed.
+ * @throws UnableToCompleteException if a compilation error is found in
the
+ * cuds argument.
+ */
static void checkForErrors(TreeLogger logger,
CompilationUnitDeclaration[] cuds, boolean itemizeErrors)
throws UnableToCompleteException {
@@ -843,40 +855,21 @@
if (cuds.length == 0) {
compilationFailed = true;
}
- Set<IProblem> problemSet = new HashSet<IProblem>();
for (CompilationUnitDeclaration cud : cuds) {
- CompilationResult result = cud.compilationResult();
+ final CompilationResult result = cud.compilationResult();
if (result.hasErrors()) {
compilationFailed = true;
// Early out if we don't need to itemize.
if (!itemizeErrors) {
break;
}
- TreeLogger branch = logger.branch(TreeLogger.ERROR, "Errors in "
- + String.valueOf(result.getFileName()), null);
- IProblem[] errors = result.getErrors();
- for (IProblem problem : errors) {
- if (problemSet.contains(problem)) {
- continue;
- }
-
- problemSet.add(problem);
-
- // Strip the initial code from each error.
- //
- String msg = problem.toString();
- msg = msg.substring(msg.indexOf(' '));
-
- // Append 'file (line): msg' to the error message.
- //
- int line = problem.getSourceLineNumber();
- StringBuffer msgBuf = new StringBuffer();
- msgBuf.append("Line ");
- msgBuf.append(line);
- msgBuf.append(": ");
- msgBuf.append(msg);
- branch.log(TreeLogger.ERROR, msgBuf.toString(), null);
- }
+ String typeName = new String(cud.getMainTypeName());
+ CompilationProblemReporter.reportErrors(logger,
result.getErrors(), new String(cud
+ .getFileName()), true, new SourceFetcher() {
+ public String getSource() {
+ return new String(result.getCompilationUnit().getContents());
+ }
+ }, typeName, false);
}
}
checkForErrorsEvent.end();
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
Fri Jan 28 06:04:41 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
Tue Apr 5 03:08:39 2011
@@ -27,6 +27,7 @@
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.CompilationUnit;
import com.google.gwt.dev.javac.CompiledClass;
@@ -1231,6 +1232,12 @@
}
classBytes = newBytes;
}
+
+ if (unit != null && unit.isError()) {
+ // Compile worked, but the unit had some kind of error (JSNI?)
+ CompilationProblemReporter.reportErrors(logger, unit, false);
+ }
+
return classBytes;
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/util/Util.java Sun Feb 6
16:09:46 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/util/Util.java Tue Apr 5
03:08:39 2011
@@ -462,24 +462,6 @@
throw new RuntimeException(e.getTargetException());
}
}
-
- public static boolean isCompilationUnitOnDisk(String loc) {
- try {
- if (new File(loc).exists()) {
- return true;
- }
-
- URL url = new URL(loc);
- String s = url.toExternalForm();
- if (s.startsWith("file:") || s.startsWith("jar:file:")
- || s.startsWith("zip:file:")) {
- return true;
- }
- } catch (MalformedURLException e) {
- // Probably not really on disk.
- }
- return false;
- }
public static boolean isValidJavaIdent(String token) {
if (token.length() == 0) {
@@ -514,43 +496,6 @@
// }
// return (String[]) lines.toArray(new String[lines.size()]);
// }
-
- public static void logMissingTypeErrorWithHints(TreeLogger logger,
- String missingType) {
- logger = logger.branch(TreeLogger.ERROR, "Unable to find type '"
- + missingType + "'", null);
-
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
- URL sourceURL = findSourceInClassPath(cl, missingType);
- if (sourceURL != null) {
- if (missingType.indexOf(".client.") != -1) {
- Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
- Messages.HINT_CHECK_MODULE_INHERITANCE.log(logger, null);
- } else {
- // Give the best possible hint here.
- //
- if (findSourceInClassPath(cl, missingType) == null) {
- Messages.HINT_CHECK_MODULE_NONCLIENT_SOURCE_DECL.log(logger,
null);
- } else {
- Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
- }
- }
- } else if (!missingType.equals("java.lang.Object")) {
- Messages.HINT_CHECK_TYPENAME.log(logger, missingType, null);
- Messages.HINT_CHECK_CLASSPATH_SOURCE_ENTRIES.log(logger, null);
- }
-
- // For Object in particular, there's a special warning.
- //
- if (missingType.indexOf("java.lang.") == 0) {
- Messages.HINT_CHECK_INHERIT_CORE.log(logger, null);
- } else if (missingType.indexOf("com.google.gwt.core.") == 0) {
- Messages.HINT_CHECK_INHERIT_CORE.log(logger, null);
- } else if (missingType.indexOf("com.google.gwt.user.") == 0) {
- Messages.HINT_CHECK_INHERIT_USER.log(logger, null);
- }
- }
/**
* Attempts to make a path relative to a particular directory.
@@ -612,64 +557,6 @@
File f = makeRelativeFile(from, new File(to));
return (f != null ? f.getPath() : null);
}
-
- /**
- * Give the developer a chance to see the in-memory source that failed.
- */
- public static void maybeDumpSource(TreeLogger logger, String location,
- String source, String typeName) {
-
- if (location.startsWith("/mock/")) {
- // Unit test mocks, don't dump to disk.
- return;
- }
-
- if (isCompilationUnitOnDisk(location)) {
- // Don't write another copy.
- return;
- }
-
- if (!logger.isLoggable(TreeLogger.INFO)) {
- // Don't bother dumping source if they can't see the related message.
- return;
- }
-
- File tmpSrc;
- Throwable caught = null;
- try {
- // The tempFile prefix must be at least 3 characters
- while (typeName.length() < 3) {
- typeName = "_" + typeName;
- }
- tmpSrc = File.createTempFile(typeName, ".java");
- writeStringAsFile(tmpSrc, source);
- String dumpPath = tmpSrc.getAbsolutePath();
- logger.log(TreeLogger.INFO, "See snapshot: " + dumpPath, null);
- return;
- } catch (IOException e) {
- caught = e;
- }
- logger.log(TreeLogger.INFO, "Unable to dump source to disk", caught);
- }
-
- // public static byte[][] readFileAndSplit(File file) {
- // RandomAccessFile f = null;
- // try {
- // f = new RandomAccessFile(file, "r");
- // int length = f.readInt();
- // byte[][] results = new byte[length][];
- // for (int i = 0; i < length; i++) {
- // int nextLength = f.readInt();
- // results[i] = new byte[nextLength];
- // f.read(results[i]);
- // }
- // return results;
- // } catch (IOException e) {
- // return null;
- // } finally {
- // Utility.close(f);
- // }
- // }
public static byte[] readFileAsBytes(File file) {
FileInputStream fileInputStream = null;
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/cfg/ConditionTest.java Thu Mar
4 12:16:00 2010
+++ /trunk/dev/core/test/com/google/gwt/dev/cfg/ConditionTest.java Tue Apr
5 03:08:39 2011
@@ -18,7 +18,7 @@
import com.google.gwt.core.ext.PropertyOracle;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.TypeOracleTestingUtils;
import junit.framework.TestCase;
@@ -32,7 +32,7 @@
*/
public class ConditionTest extends TestCase {
private PropertyOracle propertyOracle;
- private TypeOracle typeOracle;
+ private CompilationState compilationState;
private static Set<String> activeLinkerNames = new LinkedHashSet<String>(
Arrays.asList("linker1", "linker2", "xs"));
@@ -51,7 +51,7 @@
propertyOracle = new StaticPropertyOracle(new BindingProperty[]
{binding1},
new String[] {"true"}, new ConfigurationProperty[] {conf1});
- typeOracle =
TypeOracleTestingUtils.buildStandardTypeOracleWith(TreeLogger.NULL);
+ compilationState =
TypeOracleTestingUtils.buildStandardCompilationStateWith(TreeLogger.NULL);
}
public void testBasics() throws UnableToCompleteException {
@@ -107,6 +107,6 @@
private boolean isTrue(Condition cond, String testType)
throws UnableToCompleteException {
return cond.isTrue(TreeLogger.NULL, new DeferredBindingQuery(
- propertyOracle, activeLinkerNames, typeOracle, testType));
+ propertyOracle, activeLinkerNames, compilationState, testType));
}
}
=======================================
---
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
Thu Mar 24 15:47:57 2011
+++
/trunk/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
Tue Apr 5 03:08:39 2011
@@ -102,7 +102,7 @@
JavaResourceBase.getStandardResources());
protected CompilationState state = isolatedBuilder.doBuildFrom(
- createTreeLogger(), oracle.getResources());
+ createTreeLogger(), oracle.getResources(), false);
protected void addGeneratedUnits(MockResource... sourceFiles) {
state.addGeneratedCompilationUnits(createTreeLogger(),
@@ -111,7 +111,7 @@
protected void rebuildCompilationState() {
state = isolatedBuilder.doBuildFrom(createTreeLogger(),
- oracle.getResources());
+ oracle.getResources(), false);
}
protected void validateCompilationState(String... generatedTypeNames) {
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/javac/MemoryUnitCacheTest.java
Thu Mar 24 15:47:57 2011
+++ /trunk/dev/core/test/com/google/gwt/dev/javac/MemoryUnitCacheTest.java
Tue Apr 5 03:08:39 2011
@@ -70,4 +70,20 @@
result = cache.find("/mock/com/example.Bar");
assertNull(result);
}
-}
+
+ public void testUnitsWithSameTypeName() {
+ MemoryUnitCache cache = new MemoryUnitCache();
+ CompilationUnit result;
+
+ MockCompilationUnit foo1 = new
MockCompilationUnit("com.example.Foo", "source1", "location1");
+ cache.add(foo1);
+ MockCompilationUnit foo2 = new
MockCompilationUnit("com.example.Foo", "source2", "location2");
+ cache.add(foo2);
+ result = cache.find("location1");
+ assertEquals("com.example.Foo", result.getTypeName());
+ assertEquals(foo1.getContentId(), result.getContentId());
+ result = cache.find("location2");
+ assertEquals("com.example.Foo", result.getTypeName());
+ assertEquals(foo2.getContentId(), result.getContentId());
+ }
+}
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
Fri Mar 25 16:48:01 2011
+++ /trunk/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
Tue Apr 5 03:08:39 2011
@@ -29,12 +29,18 @@
private final ContentId contentId;
private final long lastModified;
+ private final String resourceLocation;
private final String source;
private final String typeName;
public MockCompilationUnit(String typeName, String source) {
+ this(typeName, source, "/mock/" + Shared.toPath(typeName));
+ }
+
+ public MockCompilationUnit(String typeName, String source, String
resourceLocation) {
this.typeName = typeName;
this.source = source;
+ this.resourceLocation = resourceLocation;
contentId = new ContentId(typeName, source);
lastModified = nextTimestamp.getAndIncrement();
}
@@ -61,7 +67,7 @@
@Override
public String getResourceLocation() {
- return "/mock/" + Shared.toPath(typeName);
+ return resourceLocation;
}
@Override
=======================================
---
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
Thu Aug 12 11:58:29 2010
+++
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
Tue Apr 5 03:08:39 2011
@@ -31,12 +31,22 @@
*/
public class TypeOracleTestingUtils {
- public static TypeOracleMediator buildMediator(TreeLogger logger,
- Set<Resource> resources, Set<GeneratedUnit> generatedUnits) {
- CompilationState state = CompilationStateBuilder.buildFrom(logger,
- resources);
+ public static CompilationState buildCompilationState(TreeLogger logger,
Set<Resource> resources,
+ Set<GeneratedUnit> generatedUnits) {
+ CompilationState state = CompilationStateBuilder.buildFrom(logger,
resources);
state.addGeneratedCompilationUnits(logger, generatedUnits);
- return state.getMediator();
+ return state;
+ }
+
+ public static CompilationState
buildStandardCompilationStateWith(TreeLogger logger,
+ Resource... resources) {
+ return buildCompilationState(logger, standardBuildersPlus(new
HashSet<Resource>(Arrays
+ .asList(resources))), Collections.<GeneratedUnit> emptySet());
+ }
+
+ public static TypeOracleMediator buildMediator(TreeLogger logger,
Set<Resource> resources,
+ Set<GeneratedUnit> generatedUnits) {
+ return buildCompilationState(logger, resources,
generatedUnits).getMediator();
}
public static TypeOracleMediator buildMediatorWith(TreeLogger logger,
=======================================
--- /trunk/dev/core/test/com/google/gwt/dev/jjs/impl/RunAsyncNameTest.java
Mon Jun 7 12:20:31 2010
+++ /trunk/dev/core/test/com/google/gwt/dev/jjs/impl/RunAsyncNameTest.java
Tue Apr 5 03:08:39 2011
@@ -58,9 +58,9 @@
{
UnitTestTreeLogger.Builder builder = new
UnitTestTreeLogger.Builder();
builder.setLowestLogLevel(TreeLogger.ERROR);
- builder.expectError("Errors in /mock/test/EntryPoint.java", null);
+ builder.expectError("Errors in '/mock/test/EntryPoint.java'", null);
builder.expectError(
- "Line 5: Only class literals may be used to name a call to
GWT.runAsync()",
+ "Line 5: Only class literals may be used to name a call to
GWT.runAsync()",
null);
builder.expectError("Cannot proceed due to previous errors", null);
logger = builder.createLogger();
=======================================
---
/trunk/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
Wed Dec 15 07:54:33 2010
+++
/trunk/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
Tue Apr 5 03:08:39 2011
@@ -22,9 +22,9 @@
import com.google.gwt.core.ext.typeinfo.JConstructor;
import com.google.gwt.core.ext.typeinfo.JPackage;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
import com.google.gwt.dev.javac.CompilationUnit;
import com.google.gwt.dev.javac.CompilationUnitBuilder;
-import com.google.gwt.dev.javac.CompilationUnitInvalidator;
import com.google.gwt.dev.javac.JdtCompiler;
import com.google.gwt.dev.javac.TypeOracleMediatorFromSource;
import com.google.gwt.dev.resource.Resource;
@@ -193,7 +193,7 @@
TreeLogger branch = logger.branch(TreeLogger.TRACE,
"Checking for compile errors");
for (CompilationUnit unit : units) {
- CompilationUnitInvalidator.reportErrors(branch, unit);
+ CompilationProblemReporter.reportErrors(branch, unit, false);
anyError |= unit.isError();
}
if (anyError) {
=======================================
--- /trunk/user/src/com/google/gwt/junit/JUnitShell.java Mon Apr 4
04:54:01 2011
+++ /trunk/user/src/com/google/gwt/junit/JUnitShell.java Tue Apr 5
03:08:39 2011
@@ -31,6 +31,7 @@
import com.google.gwt.dev.cfg.Property;
import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.CompilationUnit;
+import com.google.gwt.dev.javac.CompilationProblemReporter;
import com.google.gwt.dev.shell.CheckForUpdates;
import com.google.gwt.dev.shell.jetty.JettyLauncher;
import com.google.gwt.dev.util.arg.ArgHandlerDeployDir;
@@ -719,7 +720,7 @@
* the type oracle, there's no way this test can possibly run. Bail early
* instead of failing on the client.
*/
- private static JUnitFatalLaunchException checkTestClassInCurrentModule(
+ private static JUnitFatalLaunchException
checkTestClassInCurrentModule(TreeLogger logger,
CompilationState compilationState, String moduleName, TestCase
testCase) {
TypeOracle typeOracle = compilationState.getTypeOracle();
String typeName = testCase.getClass().getName();
@@ -735,6 +736,7 @@
errMsg = "The test class '" + typeName + "' was not found in
module '"
+ moduleName + "'; no compilation unit for that type was seen";
} else if (unit.isError()) {
+ CompilationProblemReporter.logMissingTypeErrorWithHints(logger,
typeName, compilationState);
errMsg = "The test class '" + typeName
+ "' had compile errors; check log for details";
} else {
@@ -1341,11 +1343,11 @@
if (!sameTest) {
currentModule = compileStrategy.maybeCompileModule(moduleName,
syntheticModuleName, strategy, batchingStrategy, getTopLogger());
- currentCompilationState =
currentModule.getCompilationState(getTopLogger());
+ currentCompilationState =
currentModule.getCompilationState(getTopLogger(), true);
}
assert (currentModule != null);
- JUnitFatalLaunchException launchException =
checkTestClassInCurrentModule(
+ JUnitFatalLaunchException launchException =
checkTestClassInCurrentModule(getTopLogger(),
currentCompilationState, moduleName, testCase);
if (launchException != null) {
testResult.addError(testCase, launchException);
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors