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

Unified Diff: pkg/compiler/lib/src/compiler.dart

Issue 1661853005: Introduce getPrefixEndToken to avoid too big context in messages. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 10 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: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 4b37788a616c93a2e1671d05a55dca05c3f41390..0c1b32f038721adf8790e8725f21a5f53079b515 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -1795,6 +1795,16 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
uri = currentElement.compilationUnit.script.resourceUri;
assert(invariant(currentElement, () {
+ bool sameToken(Token token, Token sought) {
+ if (token == sought) return true;
+ if (token.stringValue == '>>' ||
+ token.stringValue == '>>>') {
+ // `>>` and `>>>` are converted to `>` in the parser when needed.
+ return sought.stringValue == '>';
ahe 2016/02/08 14:40:13 Also look at character offset?
Johnni Winther 2016/02/09 11:59:58 Done.
+ }
+ return false;
+ }
+
/// Check that [begin] and [end] can be found between [from] and [to].
validateToken(Token from, Token to) {
if (from == null || to == null) return true;
@@ -1802,10 +1812,10 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
bool foundEnd = false;
Token token = from;
while (true) {
- if (token == begin) {
+ if (sameToken(token, begin)) {
foundBegin = true;
}
- if (token == end) {
+ if (sameToken(token, end)) {
foundEnd = true;
}
if (foundBegin && foundEnd) {
@@ -1859,7 +1869,7 @@ class _CompilerDiagnosticReporter extends DiagnosticReporter {
}
SourceSpan spanFromNode(Node node) {
- return spanFromTokens(node.getBeginToken(), node.getEndToken());
+ return spanFromTokens(node.getBeginToken(), node.getPrefixEndToken());
}
SourceSpan spanFromElement(Element element) {
« no previous file with comments | « no previous file | pkg/compiler/lib/src/diagnostics/source_span.dart » ('j') | pkg/compiler/lib/src/tree/nodes.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698