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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/token.dart

Issue 2841863002: Change accessors and AstFactory to use tokens rather than file offsets. (Closed)
Patch Set: Created 3 years, 8 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/front_end/lib/src/fasta/scanner/token.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/token.dart b/pkg/front_end/lib/src/fasta/scanner/token.dart
index a3e91fa9126044ce5f53578a6f33148b0f8e9b19..b458cbf6208b438d732e302a2ca9db845819dad6 100644
--- a/pkg/front_end/lib/src/fasta/scanner/token.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/token.dart
@@ -7,6 +7,8 @@ library fasta.scanner.token;
import '../../scanner/token.dart' as analyzer;
import '../../scanner/token.dart' show TokenType;
+import 'package:kernel/ast.dart' show TreeNode;
ahe 2017/04/25 17:39:59 It feels a bit much to import package:kernel here
Paul Berry 2017/04/25 22:00:55 What's bothering you, the import of kernel or the
ahe 2017/04/26 08:34:36 Both, I think.
+
import 'precedence.dart'
show AS_INFO, BAD_INPUT_INFO, EOF_INFO, IS_INFO, KEYWORD_INFO;
@@ -14,6 +16,11 @@ import 'token_constants.dart' show IDENTIFIER_TOKEN;
import 'string_canonicalizer.dart';
+/// A null-aware alternative to `token.offset`. If [token] is `null`, returns
+/// `TreeNode.noOffset`.
+int offsetForToken(Token token) =>
+ token == null ? TreeNode.noOffset : token.offset;
+
/**
* A token that doubles as a linked list.
*/

Powered by Google App Engine
This is Rietveld 408576698