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

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

Issue 632203002: More string literals getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check strings start instead of end 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/pubspec.yaml » ('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 dd0bcb03a71f5fb271e0e5e922ea116b645ef41c..ee18c22b1d307d0715bfe653bfb726c38e373351 100644
--- a/pkg/analyzer/lib/src/generated/ast.dart
+++ b/pkg/analyzer/lib/src/generated/ast.dart
@@ -16045,22 +16045,39 @@ class SimpleStringLiteral extends SingleStringLiteral {
*/
String get value => _value;
- /**
- * Return `true` if this string literal is a multi-line string.
- *
- * @return `true` if this string literal is a multi-line string
- */
+ @override
bool get isMultiline {
String lexeme = literal.lexeme;
if (lexeme.length < 6) {
Paul Berry 2014/10/07 16:30:55 Change this to "if (lexeme.length < 3)". Otherwis
scheglov 2014/10/07 18:11:09 Pushed this change into another analyzer CL: https
return false;
}
- return StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27);
+ // skip 'r'
+ int offset = 0;
+ if (lexeme.codeUnitAt(0) == 0x72) {
Paul Berry 2014/10/07 16:30:55 Nit: for readability it would be nice to change th
+ offset = 1;
+ }
+ // check prefix
+ return StringUtilities.startsWith3(lexeme, offset, 0x22, 0x22, 0x22) ||
+ StringUtilities.startsWith3(lexeme, offset, 0x27, 0x27, 0x27);
}
+ @override
bool get isRaw => literal.lexeme.codeUnitAt(0) == 0x72;
@override
+ bool get isSingleQuoted {
+ String lexeme = literal.lexeme;
+ if (lexeme.isEmpty) {
+ return false;
+ }
+ int codeZero = lexeme.codeUnitAt(0);
+ if (codeZero == 0x72) {
+ return lexeme.length > 1 && lexeme.codeUnitAt(1) == 0x27;
+ }
+ return codeZero == 0x27;
+ }
+
+ @override
bool get isSynthetic => literal.isSynthetic;
/**
@@ -16181,7 +16198,26 @@ class StringInterpolation extends SingleStringLiteral {
}
@override
+ bool get isMultiline {
+ InterpolationString element = _elements.first;
+ String lexeme = element._contents.lexeme;
+ if (lexeme.length < 3) {
+ return false;
+ }
+ return StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) ||
+ StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27);
+ }
+
+ @override
bool get isRaw => false;
+
+
+ @override
+ bool get isSingleQuoted {
+ InterpolationString lastString = _elements.first;
+ String lexeme = lastString._contents.lexeme;
+ return StringUtilities.startsWithChar(lexeme, 0x27);
+ }
}
/**
@@ -16243,9 +16279,20 @@ abstract class SingleStringLiteral extends StringLiteral {
int get contentsEnd;
/**
+ * Return `true` if this string literal is a multi-line string.
+ */
+ bool get isMultiline;
+
+ /**
* Return `true` if this string literal is a raw string.
*/
bool get isRaw;
+
+ /**
+ * Return `true` if this string literal uses single qoutes (' or ''').
+ * Return `false` if this string literal uses double qoutes (" or """).
+ */
+ bool get isSingleQuoted;
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698