diff --git a/compiler/java/com/google/dart/compiler/DartCompilationError.java b/compiler/java/com/google/dart/compiler/DartCompilationError.java index 2b4de6e94c1..13e203f4973 100644 --- a/compiler/java/com/google/dart/compiler/DartCompilationError.java +++ b/compiler/java/com/google/dart/compiler/DartCompilationError.java @@ -162,17 +162,6 @@ public class DartCompilationError { this.source = location.getSource(); } - /** - * Instantiate a new instance representing a compilation error at the specified location. - * - * @param location the source range where the error occurred - * @param errorCode the error code to be associated with this error - * @param arguments the arguments used to build the error message - */ - public DartCompilationError(Location location, ErrorCode errorCode, Object... arguments) { - this((Source)null, location, errorCode, arguments); - } - /** * Instantiate a new instance representing a compilation error at the specified location. * diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java index e860694aaf9..e99ca30e93a 100644 --- a/compiler/java/com/google/dart/compiler/DartCompiler.java +++ b/compiler/java/com/google/dart/compiler/DartCompiler.java @@ -417,7 +417,7 @@ public class DartCompiler { } } } - + if (filesHaveChanged) { context.setFilesHaveChanged(); } @@ -500,7 +500,7 @@ public class DartCompiler { Tracer.end(logEvent); } } - + private void validateLibraryDirectives() { LibraryUnit appLibUnit = context.getAppLibraryUnit(); for (LibraryUnit lib : libraries.values()) { @@ -576,7 +576,7 @@ public class DartCompiler { private void setEntryPoint() { LibraryUnit lib = context.getAppLibraryUnit(); lib.setEntryNode(new LibraryNode(MAIN_ENTRY_POINT_NAME)); - // this ensures that if we find it, it's a top-level static element + // this ensures that if we find it, it's a top-level static element Element element = lib.getElement().lookupLocalElement(MAIN_ENTRY_POINT_NAME); switch (ElementKind.of(element)) { case NONE: @@ -587,13 +587,13 @@ public class DartCompiler { MethodElement methodElement = (MethodElement) element; Modifiers modifiers = methodElement.getModifiers(); if (modifiers.isGetter()) { - context.compilationError(new DartCompilationError(Location.NONE, + context.compilationError(new DartCompilationError(element.getNode(), DartCompilerErrorCode.ENTRY_POINT_METHOD_MAY_NOT_BE_GETTER, MAIN_ENTRY_POINT_NAME)); } else if (modifiers.isSetter()) { - context.compilationError(new DartCompilationError(Location.NONE, + context.compilationError(new DartCompilationError(element.getNode(), DartCompilerErrorCode.ENTRY_POINT_METHOD_MAY_NOT_BE_SETTER, MAIN_ENTRY_POINT_NAME)); } else if (methodElement.getParameters().size() > 0) { - context.compilationError(new DartCompilationError(Location.NONE, + context.compilationError(new DartCompilationError(element.getNode(), DartCompilerErrorCode.ENTRY_POINT_METHOD_CANNOT_HAVE_PARAMETERS, MAIN_ENTRY_POINT_NAME)); } else { @@ -602,7 +602,7 @@ public class DartCompiler { break; default: - context.compilationError(new DartCompilationError(Location.NONE, + context.compilationError(new DartCompilationError(element.getNode(), DartCompilerErrorCode.NOT_A_STATIC_METHOD, MAIN_ENTRY_POINT_NAME)); break; } @@ -711,7 +711,8 @@ public class DartCompiler { // when generating documentation. if (context.getApplicationUnit().getEntryNode() == null && !collectComments) { if (config.expectEntryPoint()) { - context.compilationError(new DartCompilationError(Location.NONE, + context.compilationError(new DartCompilationError( + context.getApplicationUnit().getSource(), Location.NONE, DartCompilerErrorCode.NO_ENTRY_POINT)); } return; @@ -1172,7 +1173,7 @@ public class DartCompiler { } return null; } - + public static LibraryUnit getCoreLib(LibraryUnit libraryUnit) { return findLibrary(libraryUnit, "corelib.dart", new HashSet()); } diff --git a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java index 4a7bf1268b1..3b6b9554b2e 100644 --- a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java +++ b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java @@ -8,7 +8,6 @@ import com.google.dart.compiler.DartCompilationError; import com.google.dart.compiler.DartCompilerErrorCode; import com.google.dart.compiler.ErrorCode; import com.google.dart.compiler.ast.DartNode; -import com.google.dart.compiler.parser.DartScanner.Location; /** * Abstract base class for sharing common utility methods between implementation @@ -91,13 +90,13 @@ abstract class AbstractParser { */ protected void reportError(DartScanner.Position position, ErrorCode errorCode, Object... arguments) { - DartCompilationError dartError = new DartCompilationError(ctx.getTokenLocation(), errorCode, - arguments); - if (dartError.getStartPosition() <= lastErrorPosition) { + DartScanner.Location location = ctx.getTokenLocation(); + if (location.getBegin().getPos() <= lastErrorPosition) { return; } + DartCompilationError dartError = new DartCompilationError(ctx.getSource(), location, errorCode, + arguments); lastErrorPosition = position.getPos(); - dartError.setSource(ctx.getSource()); ctx.error(dartError); } @@ -129,8 +128,4 @@ abstract class AbstractParser { next(); return result; } - - public void error(Location location, DartCompilerErrorCode code, Object... arguments) { - ctx.error(new DartCompilationError(location, code, arguments)); - } } diff --git a/compiler/java/com/google/dart/compiler/resolver/CoreTypeProviderImplementation.java b/compiler/java/com/google/dart/compiler/resolver/CoreTypeProviderImplementation.java index a18c7ad78ee..b14a6819fa6 100644 --- a/compiler/java/com/google/dart/compiler/resolver/CoreTypeProviderImplementation.java +++ b/compiler/java/com/google/dart/compiler/resolver/CoreTypeProviderImplementation.java @@ -62,7 +62,8 @@ public class CoreTypeProviderImplementation implements CoreTypeProvider { if (element == null) { Location location = null; DartCompilationError error = - new DartCompilationError(location, DartCompilerErrorCode.CANNOT_BE_RESOLVED, name); + new DartCompilationError(null, Location.NONE, + DartCompilerErrorCode.CANNOT_BE_RESOLVED, name); listener.compilationError(error); return Types.newDynamicType(); }