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

Unified Diff: pkg/analyzer/lib/dart/ast/token.dart

Issue 2357803002: Add SyntacticEntity, an interface shared by AstNode and Token. (Closed)
Patch Set: Remove redundant comment Created 4 years, 3 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/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/dart/ast/ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/dart/ast/token.dart
diff --git a/pkg/analyzer/lib/dart/ast/token.dart b/pkg/analyzer/lib/dart/ast/token.dart
index 687111a2c3a71fd5c2ad2a2864fb87cfe119bb1a..05a146bdcdb66f2118594f8cf1847b348dfb7a51 100644
--- a/pkg/analyzer/lib/dart/ast/token.dart
+++ b/pkg/analyzer/lib/dart/ast/token.dart
@@ -214,21 +214,41 @@ class Keyword {
}
/**
+ * Interface representing a syntactic entity (either a token or an AST node)
+ * which has a location and extent in the source file.
+ */
+abstract class SyntacticEntity {
Brian Wilkerson 2016/09/21 13:21:41 Seems like this ought to be in a library of it's o
+ /**
+ * Return the offset from the beginning of the file to the character after the
+ * last character of the syntactic entity.
+ */
+ int get end;
+
+ /**
+ * Return the number of characters in the syntactic entity's source range.
+ */
+ int get length;
+
+ /**
+ * Return the offset from the beginning of the file to the first character in
+ * the syntactic entity.
+ */
+ int get offset;
+}
+
+/**
* A token that was scanned from the input. Each token knows which tokens
* precede and follow it, acting as a link in a doubly linked list of tokens.
*
* Clients may not extend, implement or mix-in this class.
*/
-abstract class Token {
+abstract class Token implements SyntacticEntity {
/**
* Initialize a newly created token to have the given [type] and [offset].
*/
factory Token(TokenType type, int offset) = SimpleToken;
- /**
- * Return the offset from the beginning of the file to the character after the
- * last character of the token.
- */
+ @override
int get end;
/**
@@ -254,9 +274,7 @@ abstract class Token {
*/
Keyword get keyword;
- /**
- * Return the number of characters in the node's source range.
- */
+ @override
int get length;
/**
@@ -269,10 +287,7 @@ abstract class Token {
*/
Token get next;
- /**
- * Return the offset from the beginning of the file to the first character in
- * the token.
- */
+ @override
int get offset;
/**
« no previous file with comments | « pkg/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/dart/ast/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698