Revision: 8458
Author: [email protected]
Date: Mon Aug 2 12:33:56 2010
Log: Removes the unnecessary ErrorCompilationUnit.
http://gwt-code-reviews.appspot.com/730801/show
Review by: kplatfoot
http://code.google.com/p/google-web-toolkit/source/detail?r=8458
Deleted:
/trunk/dev/core/src/com/google/gwt/dev/javac/ErrorCompilationUnit.java
Modified:
/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/JdtCompiler.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/ErrorCompilationUnit.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 ErrorCompilationUnit extends CompilationUnit {
-
- private final CompilationUnit unit;
-
- public ErrorCompilationUnit(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 true;
- }
-
- @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/CompilationStateBuilder.java
Thu Jun 17 10:13:10 2010
+++
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
Mon Aug 2 12:33:56 2010
@@ -85,9 +85,7 @@
CompilationUnit unit = builder.build(compiledClasses, dependencies,
jsniMethods.values(), methodArgs,
cud.compilationResult().getProblems());
- if (cud.compilationResult().hasErrors()) {
- unit = new ErrorCompilationUnit(unit);
- } else {
+ if (!unit.isError()) {
addValidUnit(unit);
// Cache the valid unit for future compiles.
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Mon
Jan 11 17:58:07 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java Mon
Aug 2 12:33:56 2010
@@ -302,16 +302,12 @@
/**
* Returns <code>true</code> if this unit is compiled and valid.
*/
- public boolean isCompiled() {
- return true;
- }
+ public abstract boolean isCompiled();
/**
* Returns <code>true</code> if this unit had errors.
*/
- public boolean isError() {
- return false;
- }
+ public abstract boolean isError();
/**
* Returns <code>true</code> if this unit was generated by a
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
Mon Jan 11 17:58:07 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationUnitImpl.java
Mon Aug 2 12:33:56 2010
@@ -27,9 +27,10 @@
private final Set<ContentId> dependencies;
private final List<CompiledClass> exposedCompiledClasses;
+ private final boolean hasErrors;
private final List<JsniMethod> jsniMethods;
- private final CategorizedProblem[] problems;
private final MethodArgNamesLookup methodArgs;
+ private final CategorizedProblem[] problems;
public CompilationUnitImpl(List<CompiledClass> compiledClasses,
Set<ContentId> dependencies,
@@ -40,6 +41,15 @@
this.jsniMethods = Lists.create(jsniMethods.toArray(new
JsniMethod[jsniMethods.size()]));
this.methodArgs = methodArgs;
this.problems = problems;
+ boolean hasAnyErrors = false;
+ if (problems != null) {
+ for (CategorizedProblem problem : problems) {
+ if (problem.isError()) {
+ hasAnyErrors = true;
+ }
+ }
+ }
+ this.hasErrors = hasAnyErrors;
for (CompiledClass cc : compiledClasses) {
cc.initUnit(this);
}
@@ -54,6 +64,16 @@
public MethodArgNamesLookup getMethodArgs() {
return methodArgs;
}
+
+ @Override
+ public boolean isCompiled() {
+ return !hasErrors;
+ }
+
+ @Override
+ public boolean isError() {
+ return hasErrors;
+ }
/**
* Returns all contained classes.
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Thu Jul
29 04:13:58 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java Mon Aug
2 12:33:56 2010
@@ -112,9 +112,6 @@
compiler.computeDependencies(cud),
Collections.<JsniMethod> emptyList(), new MethodArgNamesLookup(),
cud.compilationResult().getProblems());
- if (cud.compilationResult().hasErrors()) {
- unit = new ErrorCompilationUnit(unit);
- }
results.add(unit);
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors