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; |
/** |