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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/utils.dart

Issue 2841863002: Change accessors and AstFactory to use tokens rather than file offsets. (Closed)
Patch Set: Address code review comments, rebase 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/utils.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/utils.dart b/pkg/front_end/lib/src/fasta/kernel/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0b5f3f497bf45bd31854ea3e07f32c69432e94d1
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/kernel/utils.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:front_end/src/fasta/scanner/token.dart';
+import 'package:kernel/ast.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;
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698