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

Unified Diff: pkg/analyzer/lib/src/generated/ast.dart

Issue 630163004: Add SingleStringLiteral with accessors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/ast.dart
diff --git a/pkg/analyzer/lib/src/generated/ast.dart b/pkg/analyzer/lib/src/generated/ast.dart
index 9d15d52bb1925fedd2589dbd3fca55b310232174..fb42f9c634796a76debe933e0a5f08564cffc68b 100644
--- a/pkg/analyzer/lib/src/generated/ast.dart
+++ b/pkg/analyzer/lib/src/generated/ast.dart
@@ -10441,6 +10441,39 @@ class InterpolationString extends InterpolationElement {
@override
void visitChildren(AstVisitor visitor) {
}
+
+ /**
+ * Return the offset of the after-last contents character.
+ */
+ int get contentsEnd {
+ int end = _contents.end;
+ String lexeme = _contents.lexeme;
+ if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) ||
+ StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) {
+ end -= 3;
+ } else {
+ end -= 1;
+ }
+ return end;
+ }
+
+ /**
+ * Return the offset of the first contents character.
+ */
+ int get contentsOffset {
+ int offset = _contents.offset;
+ String lexeme = _contents.lexeme;
+ if (lexeme.codeUnitAt(0) == 0x72) {
+ offset += 1;
+ }
+ if (StringUtilities.startsWith3(lexeme, offset, 0x22, 0x22, 0x22) ||
+ StringUtilities.startsWith3(lexeme, offset, 0x27, 0x27, 0x27)) {
+ offset += 3;
+ } else {
+ offset += 1;
+ }
+ return offset;
+ }
}
/**
@@ -15942,7 +15975,7 @@ class SimpleIdentifier extends Identifier {
* '"' characters '"'
* </pre>
*/
-class SimpleStringLiteral extends StringLiteral {
+class SimpleStringLiteral extends SingleStringLiteral {
/**
* The token representing the literal.
*/
@@ -15975,6 +16008,25 @@ class SimpleStringLiteral extends StringLiteral {
Token get beginToken => literal;
@override
+ int get contentsOffset {
+ int contentsOffset = 0;
+ if (isRaw) {
+ contentsOffset += 1;
+ }
+ if (isMultiline) {
+ contentsOffset += 3;
+ } else {
+ contentsOffset += 1;
+ }
+ return offset + contentsOffset;
+ }
+
+ @override
+ int get contentsEnd {
+ return contentsOffset + value.length;
+ }
+
+ @override
Token get endToken => literal;
/**
@@ -15992,24 +16044,6 @@ class SimpleStringLiteral extends StringLiteral {
String get value => _value;
/**
- * Return the offset of the first value character.
- *
- * @return the offset of the first value character
- */
- int get valueOffset {
- int valueOffset = 0;
- if (isRaw) {
- valueOffset += 1;
- }
- if (isMultiline) {
- valueOffset += 3;
- } else {
- valueOffset += 1;
- }
- return offset + valueOffset;
- }
-
- /**
* Return `true` if this string literal is a multi-line string.
*
* @return `true` if this string literal is a multi-line string
@@ -16022,11 +16056,6 @@ class SimpleStringLiteral extends StringLiteral {
return StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27);
}
- /**
- * Return `true` if this string literal is a raw string.
- *
- * @return `true` if this string literal is a raw string
- */
bool get isRaw => literal.lexeme.codeUnitAt(0) == 0x72;
@override
@@ -16095,7 +16124,7 @@ abstract class Statement extends AstNode {
* | '"' [InterpolationElement]* '"'
* </pre>
*/
-class StringInterpolation extends StringLiteral {
+class StringInterpolation extends SingleStringLiteral {
/**
* The elements that will be composed to produce the resulting string.
*/
@@ -16136,6 +16165,21 @@ class StringInterpolation extends StringLiteral {
void appendStringValue(JavaStringBuilder builder) {
throw new IllegalArgumentException();
}
+
+ @override
+ int get contentsOffset {
+ InterpolationString element = _elements.first;
+ return element.contentsOffset;
+ }
+
+ @override
+ int get contentsEnd {
+ InterpolationString element = _elements.last;
+ return element.contentsEnd;
+ }
+
+ @override
+ bool get isRaw => false;
}
/**
@@ -16176,6 +16220,33 @@ abstract class StringLiteral extends Literal {
}
/**
+ * Instances of the class [SingleStringLiteral] represent a single string
+ * literal expression.
+ *
+ * <pre>
+ * singleStringLiteral ::=
+ * [SimpleStringLiteral]
+ * | [StringInterpolation]
+ * </pre>
+ */
+abstract class SingleStringLiteral extends StringLiteral {
Brian Wilkerson 2014/10/06 21:59:26 GeneralizingAstVisitor should have a visitSingleSt
scheglov 2014/10/07 00:53:34 Done.
+ /**
+ * Return the offset of the first contents character.
+ */
+ int get contentsOffset;
+
+ /**
+ * Return the offset of the after-last contents character.
+ */
+ int get contentsEnd;
+
+ /**
+ * Return `true` if this string literal is a raw string.
+ */
+ bool get isRaw;
+}
+
+/**
* Instances of the class `SuperConstructorInvocation` represent the invocation of a
* superclass' constructor from within a constructor's initialization list.
*
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698