Index: compiler/java/com/google/dart/compiler/parser/AbstractParser.java |
diff --git a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java |
index 8889e15367dbeb82bcb8373f55e343d92c5310cf..759b19bb5b79b1fcfc2d2b2418a12eddedac43bb 100644 |
--- a/compiler/java/com/google/dart/compiler/parser/AbstractParser.java |
+++ b/compiler/java/com/google/dart/compiler/parser/AbstractParser.java |
@@ -6,6 +6,7 @@ package com.google.dart.compiler.parser; |
import com.google.dart.compiler.DartCompilationError; |
import com.google.dart.compiler.ErrorCode; |
+import com.google.dart.compiler.parser.DartScanner.Location; |
/** |
* Abstract base class for sharing common utility methods between implementation |
@@ -108,6 +109,23 @@ abstract class AbstractParser { |
lastErrorPosition = position.getPos(); |
ctx.error(dartError); |
} |
+ |
+ /** |
+ * Even though you pass a 'Position' to {@link #reportError} above, it only uses that to |
+ * prevent logging more than one error at that position. This method actually uses the passed |
+ * position to create the error event. |
+ */ |
+ protected void reportErrorAtPosition(DartScanner.Position startPosition, |
+ DartScanner.Position endPosition, |
+ ErrorCode errorCode, Object... arguments) { |
+ DartScanner.Location location = ctx.getTokenLocation(); |
+ if (location.getBegin().getPos() <= lastErrorPosition) { |
+ return; |
+ } |
+ DartCompilationError dartError = new DartCompilationError(ctx.getSource(), |
+ new Location(startPosition, endPosition), errorCode, arguments); |
+ ctx.error(dartError); |
+ } |
protected void reportUnexpectedToken(DartScanner.Position position, Token expected, |
Token actual) { |