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

Side by Side 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: Add GeneralizingAstVisitor.visitSingleStringLiteral 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast; 8 library engine.ast;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 8541 matching lines...) Expand 10 before | Expand all | Expand 10 after
8552 @override 8552 @override
8553 R visitShowCombinator(ShowCombinator node) => visitCombinator(node); 8553 R visitShowCombinator(ShowCombinator node) => visitCombinator(node);
8554 8554
8555 @override 8555 @override
8556 R visitSimpleFormalParameter(SimpleFormalParameter node) => visitNormalFormalP arameter(node); 8556 R visitSimpleFormalParameter(SimpleFormalParameter node) => visitNormalFormalP arameter(node);
8557 8557
8558 @override 8558 @override
8559 R visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node); 8559 R visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node);
8560 8560
8561 @override 8561 @override
8562 R visitSimpleStringLiteral(SimpleStringLiteral node) => visitStringLiteral(nod e); 8562 R visitSimpleStringLiteral(SimpleStringLiteral node) => visitSingleStringLiter al(node);
8563
8564 R visitSingleStringLiteral(SingleStringLiteral node) => visitStringLiteral(nod e);
8563 8565
8564 R visitStatement(Statement node) => visitNode(node); 8566 R visitStatement(Statement node) => visitNode(node);
8565 8567
8566 @override 8568 @override
8567 R visitStringInterpolation(StringInterpolation node) => visitStringLiteral(nod e); 8569 R visitStringInterpolation(StringInterpolation node) => visitSingleStringLiter al(node);
8568 8570
8569 R visitStringLiteral(StringLiteral node) => visitLiteral(node); 8571 R visitStringLiteral(StringLiteral node) => visitLiteral(node);
8570 8572
8571 @override 8573 @override
8572 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => visitCon structorInitializer(node); 8574 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => visitCon structorInitializer(node);
8573 8575
8574 @override 8576 @override
8575 R visitSuperExpression(SuperExpression node) => visitExpression(node); 8577 R visitSuperExpression(SuperExpression node) => visitExpression(node);
8576 8578
8577 @override 8579 @override
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
10434 * 10436 *
10435 * @param string the value of the literal 10437 * @param string the value of the literal
10436 */ 10438 */
10437 void set value(String string) { 10439 void set value(String string) {
10438 _value = string; 10440 _value = string;
10439 } 10441 }
10440 10442
10441 @override 10443 @override
10442 void visitChildren(AstVisitor visitor) { 10444 void visitChildren(AstVisitor visitor) {
10443 } 10445 }
10446
10447 /**
10448 * Return the offset of the after-last contents character.
10449 */
10450 int get contentsEnd {
10451 int end = _contents.end;
10452 String lexeme = _contents.lexeme;
10453 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) ||
10454 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) {
10455 end -= 3;
10456 } else {
10457 end -= 1;
10458 }
10459 return end;
10460 }
10461
10462 /**
10463 * Return the offset of the first contents character.
10464 */
10465 int get contentsOffset {
10466 int offset = _contents.offset;
10467 String lexeme = _contents.lexeme;
10468 if (lexeme.codeUnitAt(0) == 0x72) {
10469 offset += 1;
10470 }
10471 if (StringUtilities.startsWith3(lexeme, offset, 0x22, 0x22, 0x22) ||
10472 StringUtilities.startsWith3(lexeme, offset, 0x27, 0x27, 0x27)) {
10473 offset += 3;
10474 } else {
10475 offset += 1;
10476 }
10477 return offset;
10478 }
10444 } 10479 }
10445 10480
10446 /** 10481 /**
10447 * Instances of the class `IsExpression` represent an is expression. 10482 * Instances of the class `IsExpression` represent an is expression.
10448 * 10483 *
10449 * <pre> 10484 * <pre>
10450 * isExpression ::= 10485 * isExpression ::=
10451 * [Expression] 'is' '!'? [TypeName] 10486 * [Expression] 'is' '!'? [TypeName]
10452 * </pre> 10487 * </pre>
10453 */ 10488 */
(...skipping 5481 matching lines...) Expand 10 before | Expand all | Expand 10 after
15935 * 15970 *
15936 * multiLineStringLiteral ::= 15971 * multiLineStringLiteral ::=
15937 * "'''" characters "'''" 15972 * "'''" characters "'''"
15938 * | '"""' characters '"""' 15973 * | '"""' characters '"""'
15939 * 15974 *
15940 * singleLineStringLiteral ::= 15975 * singleLineStringLiteral ::=
15941 * "'" characters "'" 15976 * "'" characters "'"
15942 * '"' characters '"' 15977 * '"' characters '"'
15943 * </pre> 15978 * </pre>
15944 */ 15979 */
15945 class SimpleStringLiteral extends StringLiteral { 15980 class SimpleStringLiteral extends SingleStringLiteral {
15946 /** 15981 /**
15947 * The token representing the literal. 15982 * The token representing the literal.
15948 */ 15983 */
15949 Token literal; 15984 Token literal;
15950 15985
15951 /** 15986 /**
15952 * The value of the literal. 15987 * The value of the literal.
15953 */ 15988 */
15954 String _value; 15989 String _value;
15955 15990
(...skipping 12 matching lines...) Expand all
15968 this._value = StringUtilities.intern(value); 16003 this._value = StringUtilities.intern(value);
15969 } 16004 }
15970 16005
15971 @override 16006 @override
15972 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this); 16007 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this);
15973 16008
15974 @override 16009 @override
15975 Token get beginToken => literal; 16010 Token get beginToken => literal;
15976 16011
15977 @override 16012 @override
16013 int get contentsOffset {
16014 int contentsOffset = 0;
16015 if (isRaw) {
16016 contentsOffset += 1;
16017 }
16018 if (isMultiline) {
16019 contentsOffset += 3;
16020 } else {
16021 contentsOffset += 1;
16022 }
16023 return offset + contentsOffset;
16024 }
16025
16026 @override
16027 int get contentsEnd {
16028 return contentsOffset + value.length;
16029 }
16030
16031 @override
15978 Token get endToken => literal; 16032 Token get endToken => literal;
15979 16033
15980 /** 16034 /**
15981 * Return the toolkit specific, non-Dart, element associated with this literal , or `null`. 16035 * Return the toolkit specific, non-Dart, element associated with this literal , or `null`.
15982 * 16036 *
15983 * @return the element associated with this literal 16037 * @return the element associated with this literal
15984 */ 16038 */
15985 Element get toolkitElement => _toolkitElement; 16039 Element get toolkitElement => _toolkitElement;
15986 16040
15987 /** 16041 /**
15988 * Return the value of the literal. 16042 * Return the value of the literal.
15989 * 16043 *
15990 * @return the value of the literal 16044 * @return the value of the literal
15991 */ 16045 */
15992 String get value => _value; 16046 String get value => _value;
15993 16047
15994 /** 16048 /**
15995 * Return the offset of the first value character.
15996 *
15997 * @return the offset of the first value character
15998 */
15999 int get valueOffset {
16000 int valueOffset = 0;
16001 if (isRaw) {
16002 valueOffset += 1;
16003 }
16004 if (isMultiline) {
16005 valueOffset += 3;
16006 } else {
16007 valueOffset += 1;
16008 }
16009 return offset + valueOffset;
16010 }
16011
16012 /**
16013 * Return `true` if this string literal is a multi-line string. 16049 * Return `true` if this string literal is a multi-line string.
16014 * 16050 *
16015 * @return `true` if this string literal is a multi-line string 16051 * @return `true` if this string literal is a multi-line string
16016 */ 16052 */
16017 bool get isMultiline { 16053 bool get isMultiline {
16018 String lexeme = literal.lexeme; 16054 String lexeme = literal.lexeme;
16019 if (lexeme.length < 6) { 16055 if (lexeme.length < 6) {
16020 return false; 16056 return false;
16021 } 16057 }
16022 return StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || StringUtilitie s.endsWith3(lexeme, 0x27, 0x27, 0x27); 16058 return StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || StringUtilitie s.endsWith3(lexeme, 0x27, 0x27, 0x27);
16023 } 16059 }
16024 16060
16025 /**
16026 * Return `true` if this string literal is a raw string.
16027 *
16028 * @return `true` if this string literal is a raw string
16029 */
16030 bool get isRaw => literal.lexeme.codeUnitAt(0) == 0x72; 16061 bool get isRaw => literal.lexeme.codeUnitAt(0) == 0x72;
16031 16062
16032 @override 16063 @override
16033 bool get isSynthetic => literal.isSynthetic; 16064 bool get isSynthetic => literal.isSynthetic;
16034 16065
16035 /** 16066 /**
16036 * Set the toolkit specific, non-Dart, element associated with this literal. 16067 * Set the toolkit specific, non-Dart, element associated with this literal.
16037 * 16068 *
16038 * @param element the toolkit specific element to be associated with this lite ral 16069 * @param element the toolkit specific element to be associated with this lite ral
16039 */ 16070 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
16088 16119
16089 /** 16120 /**
16090 * Instances of the class `StringInterpolation` represent a string interpolation literal. 16121 * Instances of the class `StringInterpolation` represent a string interpolation literal.
16091 * 16122 *
16092 * <pre> 16123 * <pre>
16093 * stringInterpolation ::= 16124 * stringInterpolation ::=
16094 * ''' [InterpolationElement]* ''' 16125 * ''' [InterpolationElement]* '''
16095 * | '"' [InterpolationElement]* '"' 16126 * | '"' [InterpolationElement]* '"'
16096 * </pre> 16127 * </pre>
16097 */ 16128 */
16098 class StringInterpolation extends StringLiteral { 16129 class StringInterpolation extends SingleStringLiteral {
16099 /** 16130 /**
16100 * The elements that will be composed to produce the resulting string. 16131 * The elements that will be composed to produce the resulting string.
16101 */ 16132 */
16102 NodeList<InterpolationElement> _elements; 16133 NodeList<InterpolationElement> _elements;
16103 16134
16104 /** 16135 /**
16105 * Initialize a newly created string interpolation expression. 16136 * Initialize a newly created string interpolation expression.
16106 * 16137 *
16107 * @param elements the elements that will be composed to produce the resulting string 16138 * @param elements the elements that will be composed to produce the resulting string
16108 */ 16139 */
(...skipping 20 matching lines...) Expand all
16129 16160
16130 @override 16161 @override
16131 void visitChildren(AstVisitor visitor) { 16162 void visitChildren(AstVisitor visitor) {
16132 _elements.accept(visitor); 16163 _elements.accept(visitor);
16133 } 16164 }
16134 16165
16135 @override 16166 @override
16136 void appendStringValue(JavaStringBuilder builder) { 16167 void appendStringValue(JavaStringBuilder builder) {
16137 throw new IllegalArgumentException(); 16168 throw new IllegalArgumentException();
16138 } 16169 }
16170
16171 @override
16172 int get contentsOffset {
16173 InterpolationString element = _elements.first;
16174 return element.contentsOffset;
16175 }
16176
16177 @override
16178 int get contentsEnd {
16179 InterpolationString element = _elements.last;
16180 return element.contentsEnd;
16181 }
16182
16183 @override
16184 bool get isRaw => false;
16139 } 16185 }
16140 16186
16141 /** 16187 /**
16142 * Instances of the class `StringLiteral` represent a string literal expression. 16188 * Instances of the class `StringLiteral` represent a string literal expression.
16143 * 16189 *
16144 * <pre> 16190 * <pre>
16145 * stringLiteral ::= 16191 * stringLiteral ::=
16146 * [SimpleStringLiteral] 16192 * [SimpleStringLiteral]
16147 * | [AdjacentStrings] 16193 * | [AdjacentStrings]
16148 * | [StringInterpolation] 16194 * | [StringInterpolation]
(...skipping 20 matching lines...) Expand all
16169 * Append the value of the given string literal to the given string builder. 16215 * Append the value of the given string literal to the given string builder.
16170 * 16216 *
16171 * @param builder the builder to which the string's value is to be appended 16217 * @param builder the builder to which the string's value is to be appended
16172 * @throws IllegalArgumentException if the string is not a constant string wit hout any string 16218 * @throws IllegalArgumentException if the string is not a constant string wit hout any string
16173 * interpolation 16219 * interpolation
16174 */ 16220 */
16175 void appendStringValue(JavaStringBuilder builder); 16221 void appendStringValue(JavaStringBuilder builder);
16176 } 16222 }
16177 16223
16178 /** 16224 /**
16225 * Instances of the class [SingleStringLiteral] represent a single string
16226 * literal expression.
16227 *
16228 * <pre>
16229 * singleStringLiteral ::=
16230 * [SimpleStringLiteral]
16231 * | [StringInterpolation]
16232 * </pre>
16233 */
16234 abstract class SingleStringLiteral extends StringLiteral {
16235 /**
16236 * Return the offset of the first contents character.
16237 */
16238 int get contentsOffset;
16239
16240 /**
16241 * Return the offset of the after-last contents character.
16242 */
16243 int get contentsEnd;
16244
16245 /**
16246 * Return `true` if this string literal is a raw string.
16247 */
16248 bool get isRaw;
16249 }
16250
16251 /**
16179 * Instances of the class `SuperConstructorInvocation` represent the invocation of a 16252 * Instances of the class `SuperConstructorInvocation` represent the invocation of a
16180 * superclass' constructor from within a constructor's initialization list. 16253 * superclass' constructor from within a constructor's initialization list.
16181 * 16254 *
16182 * <pre> 16255 * <pre>
16183 * superInvocation ::= 16256 * superInvocation ::=
16184 * 'super' ('.' [SimpleIdentifier])? [ArgumentList] 16257 * 'super' ('.' [SimpleIdentifier])? [ArgumentList]
16185 * </pre> 16258 * </pre>
16186 */ 16259 */
16187 class SuperConstructorInvocation extends ConstructorInitializer { 16260 class SuperConstructorInvocation extends ConstructorInitializer {
16188 /** 16261 /**
(...skipping 3399 matching lines...) Expand 10 before | Expand all | Expand 10 after
19588 _elements[index] = node; 19661 _elements[index] = node;
19589 } 19662 }
19590 void clear() { 19663 void clear() {
19591 _elements = <E> []; 19664 _elements = <E> [];
19592 } 19665 }
19593 int get length => _elements.length; 19666 int get length => _elements.length;
19594 void set length(int value) { 19667 void set length(int value) {
19595 throw new UnsupportedError("Cannot resize NodeList."); 19668 throw new UnsupportedError("Cannot resize NodeList.");
19596 } 19669 }
19597 } 19670 }
OLDNEW
« 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