Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 11293018: Update semantic highlighting only if there are no parse errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index cfc5fbfd2b33688ec86bc198dfb940e25a659a3d..4e5892ba64d95ae6bb24e907dd5cace3062a9d48 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -11,6 +11,7 @@ import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompilerListener;
import com.google.dart.compiler.DartSource;
import com.google.dart.compiler.ErrorCode;
+import com.google.dart.compiler.ErrorSeverity;
import com.google.dart.compiler.InternalCompilerException;
import com.google.dart.compiler.LibrarySource;
import com.google.dart.compiler.PackageLibraryManager;
@@ -370,6 +371,7 @@ public class DartParser extends CompletionHooksParserBase {
DartParserCommentsHelper.addComments(unit, source, sourceCode, commentLocs);
}
// done
+ unit.setHasParseErrors(errorCount != 0);
return done(unit);
} catch (StringInterpolationParseError exception) {
throw new InternalCompilerException("Failed to parse " + source.getUri(), exception);
@@ -5357,8 +5359,11 @@ public class DartParser extends CompletionHooksParserBase {
*
* @return whether the current error should be reported
*/
- private boolean incErrorCount() {
- errorCount++;
+ private boolean incErrorCount(ErrorCode errorCode) {
+ // count only errors, but not warnings (such as "abstract")
+ if (errorCode.getErrorSeverity() == ErrorSeverity.ERROR) {
+ errorCount++;
+ }
if (errorCount >= MAX_DEFAULT_ERRORS) {
if (errorCount == MAX_DEFAULT_ERRORS) {
@@ -5383,7 +5388,7 @@ public class DartParser extends CompletionHooksParserBase {
@Override
protected void reportError(int position, ErrorCode errorCode, Object... arguments) {
// TODO(devoncarew): we're not correctly identifying dart:html as a core library
- if (incErrorCount()) {
+ if (incErrorCount(errorCode)) {
super.reportError(position, errorCode, arguments);
}
}
@@ -5391,13 +5396,13 @@ public class DartParser extends CompletionHooksParserBase {
@Override
protected void reportErrorAtPosition(int startPosition, int endPosition,
ErrorCode errorCode, Object... arguments) {
- if (incErrorCount()) {
+ if (incErrorCount(errorCode)) {
super.reportErrorAtPosition(startPosition, endPosition, errorCode, arguments);
}
}
private void reportError(DartCompilationError dartError) {
- if (incErrorCount()) {
+ if (incErrorCount(dartError.getErrorCode())) {
ctx.error(dartError);
errorHistory.add(dartError.hashCode());
}

Powered by Google App Engine
This is Rietveld 408576698