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

Side by Side Diff: pkg/analyzer/lib/src/generated/ast.dart

Issue 680863002: Remove JavaStringBuilder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/constant.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 * @return the strings that are implicitly concatenated 62 * @return the strings that are implicitly concatenated
63 */ 63 */
64 NodeList<StringLiteral> get strings => _strings; 64 NodeList<StringLiteral> get strings => _strings;
65 65
66 @override 66 @override
67 void visitChildren(AstVisitor visitor) { 67 void visitChildren(AstVisitor visitor) {
68 _strings.accept(visitor); 68 _strings.accept(visitor);
69 } 69 }
70 70
71 @override 71 @override
72 void appendStringValue(JavaStringBuilder builder) { 72 void appendStringValue(StringBuffer buffer) {
73 for (StringLiteral stringLiteral in strings) { 73 for (StringLiteral stringLiteral in strings) {
74 stringLiteral.appendStringValue(builder); 74 stringLiteral.appendStringValue(buffer);
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 /** 79 /**
80 * The abstract class `AnnotatedNode` defines the behavior of nodes that can be annotated with 80 * The abstract class `AnnotatedNode` defines the behavior of nodes that can be annotated with
81 * both a comment and metadata. 81 * both a comment and metadata.
82 */ 82 */
83 abstract class AnnotatedNode extends AstNode { 83 abstract class AnnotatedNode extends AstNode {
84 /** 84 /**
(...skipping 4434 matching lines...) Expand 10 before | Expand all | Expand 10 after
4519 */ 4519 */
4520 class ConstantEvaluator extends GeneralizingAstVisitor<Object> { 4520 class ConstantEvaluator extends GeneralizingAstVisitor<Object> {
4521 /** 4521 /**
4522 * The value returned for expressions (or non-expression nodes) that are not c ompile-time constant 4522 * The value returned for expressions (or non-expression nodes) that are not c ompile-time constant
4523 * expressions. 4523 * expressions.
4524 */ 4524 */
4525 static Object NOT_A_CONSTANT = new Object(); 4525 static Object NOT_A_CONSTANT = new Object();
4526 4526
4527 @override 4527 @override
4528 Object visitAdjacentStrings(AdjacentStrings node) { 4528 Object visitAdjacentStrings(AdjacentStrings node) {
4529 JavaStringBuilder builder = new JavaStringBuilder(); 4529 StringBuffer buffer = new StringBuffer();
4530 for (StringLiteral string in node.strings) { 4530 for (StringLiteral string in node.strings) {
4531 Object value = string.accept(this); 4531 Object value = string.accept(this);
4532 if (identical(value, NOT_A_CONSTANT)) { 4532 if (identical(value, NOT_A_CONSTANT)) {
4533 return value; 4533 return value;
4534 } 4534 }
4535 builder.append(value); 4535 buffer.write(value);
4536 } 4536 }
4537 return builder.toString(); 4537 return buffer.toString();
4538 } 4538 }
4539 4539
4540 @override 4540 @override
4541 Object visitBinaryExpression(BinaryExpression node) { 4541 Object visitBinaryExpression(BinaryExpression node) {
4542 Object leftOperand = node.leftOperand.accept(this); 4542 Object leftOperand = node.leftOperand.accept(this);
4543 if (identical(leftOperand, NOT_A_CONSTANT)) { 4543 if (identical(leftOperand, NOT_A_CONSTANT)) {
4544 return leftOperand; 4544 return leftOperand;
4545 } 4545 }
4546 Object rightOperand = node.rightOperand.accept(this); 4546 Object rightOperand = node.rightOperand.accept(this);
4547 if (identical(rightOperand, NOT_A_CONSTANT)) { 4547 if (identical(rightOperand, NOT_A_CONSTANT)) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 Object visitPropertyAccess(PropertyAccess node) => _getConstantValue(null); 4790 Object visitPropertyAccess(PropertyAccess node) => _getConstantValue(null);
4791 4791
4792 @override 4792 @override
4793 Object visitSimpleIdentifier(SimpleIdentifier node) => _getConstantValue(null) ; 4793 Object visitSimpleIdentifier(SimpleIdentifier node) => _getConstantValue(null) ;
4794 4794
4795 @override 4795 @override
4796 Object visitSimpleStringLiteral(SimpleStringLiteral node) => node.value; 4796 Object visitSimpleStringLiteral(SimpleStringLiteral node) => node.value;
4797 4797
4798 @override 4798 @override
4799 Object visitStringInterpolation(StringInterpolation node) { 4799 Object visitStringInterpolation(StringInterpolation node) {
4800 JavaStringBuilder builder = new JavaStringBuilder(); 4800 StringBuffer buffer = new StringBuffer();
4801 for (InterpolationElement element in node.elements) { 4801 for (InterpolationElement element in node.elements) {
4802 Object value = element.accept(this); 4802 Object value = element.accept(this);
4803 if (identical(value, NOT_A_CONSTANT)) { 4803 if (identical(value, NOT_A_CONSTANT)) {
4804 return value; 4804 return value;
4805 } 4805 }
4806 builder.append(value); 4806 buffer.write(value);
4807 } 4807 }
4808 return builder.toString(); 4808 return buffer.toString();
4809 } 4809 }
4810 4810
4811 @override 4811 @override
4812 Object visitSymbolLiteral(SymbolLiteral node) { 4812 Object visitSymbolLiteral(SymbolLiteral node) {
4813 // TODO(brianwilkerson) This isn't optimal because a Symbol is not a String. 4813 // TODO(brianwilkerson) This isn't optimal because a Symbol is not a String.
4814 JavaStringBuilder builder = new JavaStringBuilder(); 4814 StringBuffer buffer = new StringBuffer();
4815 for (Token component in node.components) { 4815 for (Token component in node.components) {
4816 if (builder.length > 0) { 4816 if (buffer.length > 0) {
4817 builder.appendChar(0x2E); 4817 buffer.writeCharCode(0x2E);
scheglov 2014/10/26 19:13:53 buffer.write('.') here and everywhere else?
Brian Wilkerson 2014/10/26 20:16:36 As long as there isn't a performance penalty, then
4818 } 4818 }
4819 builder.append(component.lexeme); 4819 buffer.write(component.lexeme);
4820 } 4820 }
4821 return builder.toString(); 4821 return buffer.toString();
4822 } 4822 }
4823 4823
4824 /** 4824 /**
4825 * Return the constant value of the static constant represented by the given e lement. 4825 * Return the constant value of the static constant represented by the given e lement.
4826 * 4826 *
4827 * @param element the element whose value is to be returned 4827 * @param element the element whose value is to be returned
4828 * @return the constant value of the static constant 4828 * @return the constant value of the static constant
4829 */ 4829 */
4830 Object _getConstantValue(Element element) { 4830 Object _getConstantValue(Element element) {
4831 // TODO(brianwilkerson) Implement this 4831 // TODO(brianwilkerson) Implement this
(...skipping 5986 matching lines...) Expand 10 before | Expand all | Expand 10 after
10818 * 10818 *
10819 * @return the components of the identifier 10819 * @return the components of the identifier
10820 */ 10820 */
10821 NodeList<SimpleIdentifier> get components => _components; 10821 NodeList<SimpleIdentifier> get components => _components;
10822 10822
10823 @override 10823 @override
10824 Token get endToken => _components.endToken; 10824 Token get endToken => _components.endToken;
10825 10825
10826 @override 10826 @override
10827 String get name { 10827 String get name {
10828 JavaStringBuilder builder = new JavaStringBuilder(); 10828 StringBuffer buffer = new StringBuffer();
10829 bool needsPeriod = false; 10829 bool needsPeriod = false;
10830 for (SimpleIdentifier identifier in _components) { 10830 for (SimpleIdentifier identifier in _components) {
10831 if (needsPeriod) { 10831 if (needsPeriod) {
10832 builder.append("."); 10832 buffer.write(".");
10833 } else { 10833 } else {
10834 needsPeriod = true; 10834 needsPeriod = true;
10835 } 10835 }
10836 builder.append(identifier.name); 10836 buffer.write(identifier.name);
10837 } 10837 }
10838 return builder.toString(); 10838 return buffer.toString();
10839 } 10839 }
10840 10840
10841 @override 10841 @override
10842 int get precedence => 15; 10842 int get precedence => 15;
10843 10843
10844 @override 10844 @override
10845 Element get propagatedElement => null; 10845 Element get propagatedElement => null;
10846 10846
10847 @override 10847 @override
10848 Element get staticElement => null; 10848 Element get staticElement => null;
(...skipping 5248 matching lines...) Expand 10 before | Expand all | Expand 10 after
16097 void set value(String string) { 16097 void set value(String string) {
16098 _value = StringUtilities.intern(_value); 16098 _value = StringUtilities.intern(_value);
16099 } 16099 }
16100 16100
16101 @override 16101 @override
16102 void visitChildren(AstVisitor visitor) { 16102 void visitChildren(AstVisitor visitor) {
16103 // There are no children to visit. 16103 // There are no children to visit.
16104 } 16104 }
16105 16105
16106 @override 16106 @override
16107 void appendStringValue(JavaStringBuilder builder) { 16107 void appendStringValue(StringBuffer buffer) {
16108 builder.append(value); 16108 buffer.write(value);
16109 } 16109 }
16110 } 16110 }
16111 16111
16112 /** 16112 /**
16113 * Instances of the class `Statement` defines the behavior common to nodes that represent a 16113 * Instances of the class `Statement` defines the behavior common to nodes that represent a
16114 * statement. 16114 * statement.
16115 * 16115 *
16116 * <pre> 16116 * <pre>
16117 * statement ::= 16117 * statement ::=
16118 * [Block] 16118 * [Block]
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
16174 16174
16175 @override 16175 @override
16176 Token get endToken => _elements.endToken; 16176 Token get endToken => _elements.endToken;
16177 16177
16178 @override 16178 @override
16179 void visitChildren(AstVisitor visitor) { 16179 void visitChildren(AstVisitor visitor) {
16180 _elements.accept(visitor); 16180 _elements.accept(visitor);
16181 } 16181 }
16182 16182
16183 @override 16183 @override
16184 void appendStringValue(JavaStringBuilder builder) { 16184 void appendStringValue(StringBuffer buffer) {
16185 throw new IllegalArgumentException(); 16185 throw new IllegalArgumentException();
16186 } 16186 }
16187 16187
16188 @override 16188 @override
16189 int get contentsOffset { 16189 int get contentsOffset {
16190 InterpolationString element = _elements.first; 16190 InterpolationString element = _elements.first;
16191 return element.contentsOffset; 16191 return element.contentsOffset;
16192 } 16192 }
16193 16193
16194 @override 16194 @override
(...skipping 30 matching lines...) Expand all
16225 * 16225 *
16226 * <pre> 16226 * <pre>
16227 * stringLiteral ::= 16227 * stringLiteral ::=
16228 * [SimpleStringLiteral] 16228 * [SimpleStringLiteral]
16229 * | [AdjacentStrings] 16229 * | [AdjacentStrings]
16230 * | [StringInterpolation] 16230 * | [StringInterpolation]
16231 * </pre> 16231 * </pre>
16232 */ 16232 */
16233 abstract class StringLiteral extends Literal { 16233 abstract class StringLiteral extends Literal {
16234 /** 16234 /**
16235 * Return the value of the string literal, or `null` if the string is not a co nstant string 16235 * Return the value of the string literal, or `null` if the string is not a
16236 * without any string interpolation. 16236 * constant string without any string interpolation.
16237 *
16238 * @return the value of the string literal
16239 */ 16237 */
16240 String get stringValue { 16238 String get stringValue {
16241 JavaStringBuilder builder = new JavaStringBuilder(); 16239 StringBuffer buffer = new StringBuffer();
16242 try { 16240 try {
16243 appendStringValue(builder); 16241 appendStringValue(buffer);
16244 } on IllegalArgumentException catch (exception) { 16242 } on IllegalArgumentException catch (exception) {
16245 return null; 16243 return null;
16246 } 16244 }
16247 return builder.toString(); 16245 return buffer.toString();
16248 } 16246 }
16249 16247
16250 /** 16248 /**
16251 * Append the value of the given string literal to the given string builder. 16249 * Append the value of this string literal to the given [buffer]. Throw an
16252 * 16250 * [IllegalArgumentException] if the string is not a constant string without
16253 * @param builder the builder to which the string's value is to be appended 16251 * any string interpolation.
16254 * @throws IllegalArgumentException if the string is not a constant string wit hout any string
16255 * interpolation
16256 */ 16252 */
16257 void appendStringValue(JavaStringBuilder builder); 16253 void appendStringValue(StringBuffer buffer);
16258 } 16254 }
16259 16255
16260 /** 16256 /**
16261 * Instances of the class [SingleStringLiteral] represent a single string 16257 * Instances of the class [SingleStringLiteral] represent a single string
16262 * literal expression. 16258 * literal expression.
16263 * 16259 *
16264 * <pre> 16260 * <pre>
16265 * singleStringLiteral ::= 16261 * singleStringLiteral ::=
16266 * [SimpleStringLiteral] 16262 * [SimpleStringLiteral]
16267 * | [StringInterpolation] 16263 * | [StringInterpolation]
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
19708 _elements[index] = node; 19704 _elements[index] = node;
19709 } 19705 }
19710 void clear() { 19706 void clear() {
19711 _elements = <E> []; 19707 _elements = <E> [];
19712 } 19708 }
19713 int get length => _elements.length; 19709 int get length => _elements.length;
19714 void set length(int value) { 19710 void set length(int value) {
19715 throw new UnsupportedError("Cannot resize NodeList."); 19711 throw new UnsupportedError("Cannot resize NodeList.");
19716 } 19712 }
19717 } 19713 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/constant.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698