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

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

Issue 189433006: Support for DartBlockBody, DartExpressionBody, DartOmit in java2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years, 9 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 | « pkg/analyzer/lib/src/generated/index.dart ('k') | pkg/analyzer/lib/src/generated/source.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.parser; 8 library engine.parser;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 8520 matching lines...) Expand 10 before | Expand all | Expand 10 after
8531 */ 8531 */
8532 bool _isEqualTokens(Token first, Token second) { 8532 bool _isEqualTokens(Token first, Token second) {
8533 if (first == null) { 8533 if (first == null) {
8534 return second == null; 8534 return second == null;
8535 } else if (second == null) { 8535 } else if (second == null) {
8536 return false; 8536 return false;
8537 } 8537 }
8538 return first.lexeme == second.lexeme; 8538 return first.lexeme == second.lexeme;
8539 } 8539 }
8540 } 8540 }
8541
8542 /**
8543 * Instances of the class {link ToFormattedSourceVisitor} write a source represe ntation of a visited
8544 * AST node (and all of it's children) to a writer.
8545 */
8546 class ToFormattedSourceVisitor implements AstVisitor<Object> {
8547 static String COMMENTS_KEY = "List of comments before statement";
8548
8549 /**
8550 * The writer to which the source is to be written.
8551 */
8552 PrintWriter _writer;
8553
8554 int _indentLevel = 0;
8555
8556 String _indentString = "";
8557
8558 /**
8559 * Initialize a newly created visitor to write source code representing the vi sited nodes to the
8560 * given writer.
8561 *
8562 * @param writer the writer to which the source is to be written
8563 */
8564 ToFormattedSourceVisitor(PrintWriter writer) {
8565 this._writer = writer;
8566 }
8567
8568 Object visitAdjacentStrings(AdjacentStrings node) {
8569 _visitNodeListWithSeparator(node.strings, " ");
8570 return null;
8571 }
8572
8573 Object visitAnnotation(Annotation node) {
8574 _writer.print('@');
8575 _visitNode(node.name);
8576 _visitNodeWithPrefix(".", node.constructorName);
8577 _visitNode(node.arguments);
8578 return null;
8579 }
8580
8581 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) {
8582 _writer.print('?');
8583 _visitNode(node.identifier);
8584 return null;
8585 }
8586
8587 Object visitArgumentList(ArgumentList node) {
8588 _writer.print('(');
8589 _visitNodeListWithSeparator(node.arguments, ", ");
8590 _writer.print(')');
8591 return null;
8592 }
8593
8594 Object visitAsExpression(AsExpression node) {
8595 _visitNode(node.expression);
8596 _writer.print(" as ");
8597 _visitNode(node.type);
8598 return null;
8599 }
8600
8601 Object visitAssertStatement(AssertStatement node) {
8602 _writer.print("assert(");
8603 _visitNode(node.condition);
8604 _writer.print(");");
8605 return null;
8606 }
8607
8608 Object visitAssignmentExpression(AssignmentExpression node) {
8609 _visitNode(node.leftHandSide);
8610 _writer.print(' ');
8611 _writer.print(node.operator.lexeme);
8612 _writer.print(' ');
8613 _visitNode(node.rightHandSide);
8614 return null;
8615 }
8616
8617 Object visitBinaryExpression(BinaryExpression node) {
8618 _visitNode(node.leftOperand);
8619 _writer.print(' ');
8620 _writer.print(node.operator.lexeme);
8621 _writer.print(' ');
8622 _visitNode(node.rightOperand);
8623 return null;
8624 }
8625
8626 Object visitBlock(Block node) {
8627 _writer.print('{');
8628 {
8629 _indentInc();
8630 _visitNodeListWithSeparatorAndPrefix("\n", node.statements, "\n");
8631 _indentDec();
8632 }
8633 _nl2();
8634 _writer.print('}');
8635 return null;
8636 }
8637
8638 Object visitBlockFunctionBody(BlockFunctionBody node) {
8639 _visitNode(node.block);
8640 return null;
8641 }
8642
8643 Object visitBooleanLiteral(BooleanLiteral node) {
8644 _writer.print(node.literal.lexeme);
8645 return null;
8646 }
8647
8648 Object visitBreakStatement(BreakStatement node) {
8649 _writer.print("break");
8650 _visitNodeWithPrefix(" ", node.label);
8651 _writer.print(";");
8652 return null;
8653 }
8654
8655 Object visitCascadeExpression(CascadeExpression node) {
8656 _visitNode(node.target);
8657 _visitNodeList(node.cascadeSections);
8658 return null;
8659 }
8660
8661 Object visitCatchClause(CatchClause node) {
8662 _visitNodeWithPrefix("on ", node.exceptionType);
8663 if (node.catchKeyword != null) {
8664 if (node.exceptionType != null) {
8665 _writer.print(' ');
8666 }
8667 _writer.print("catch (");
8668 _visitNode(node.exceptionParameter);
8669 _visitNodeWithPrefix(", ", node.stackTraceParameter);
8670 _writer.print(") ");
8671 } else {
8672 _writer.print(" ");
8673 }
8674 _visitNode(node.body);
8675 return null;
8676 }
8677
8678 Object visitClassDeclaration(ClassDeclaration node) {
8679 _visitNode(node.documentationComment);
8680 _visitTokenWithSuffix(node.abstractKeyword, " ");
8681 _writer.print("class ");
8682 _visitNode(node.name);
8683 _visitNode(node.typeParameters);
8684 _visitNodeWithPrefix(" ", node.extendsClause);
8685 _visitNodeWithPrefix(" ", node.withClause);
8686 _visitNodeWithPrefix(" ", node.implementsClause);
8687 _writer.print(" {");
8688 {
8689 _indentInc();
8690 _visitNodeListWithSeparatorAndPrefix("\n", node.members, "\n\n");
8691 _indentDec();
8692 }
8693 _nl2();
8694 _writer.print("}");
8695 return null;
8696 }
8697
8698 Object visitClassTypeAlias(ClassTypeAlias node) {
8699 _writer.print("typedef ");
8700 _visitNode(node.name);
8701 _visitNode(node.typeParameters);
8702 _writer.print(" = ");
8703 if (node.abstractKeyword != null) {
8704 _writer.print("abstract ");
8705 }
8706 _visitNode(node.superclass);
8707 _visitNodeWithPrefix(" ", node.withClause);
8708 _visitNodeWithPrefix(" ", node.implementsClause);
8709 _writer.print(";");
8710 return null;
8711 }
8712
8713 Object visitComment(Comment node) {
8714 Token token = node.beginToken;
8715 while (token != null) {
8716 bool firstLine = true;
8717 for (String line in StringUtils.split(token.lexeme, "\n")) {
8718 if (firstLine) {
8719 firstLine = false;
8720 } else {
8721 line = " ${line.trim()}";
8722 line = StringUtils.replace(line, "/*", "/ *");
8723 }
8724 _writer.print(line);
8725 _nl2();
8726 }
8727 if (identical(token, node.endToken)) {
8728 break;
8729 }
8730 }
8731 return null;
8732 }
8733
8734 Object visitCommentReference(CommentReference node) => null;
8735
8736 Object visitCompilationUnit(CompilationUnit node) {
8737 ScriptTag scriptTag = node.scriptTag;
8738 NodeList<Directive> directives = node.directives;
8739 _visitNode(scriptTag);
8740 // directives
8741 String prefix = scriptTag == null ? "" : " ";
8742 _visitNodeListWithSeparatorAndPrefix(prefix, directives, "\n");
8743 _nl();
8744 // declarations
8745 prefix = scriptTag == null && directives.isEmpty ? "" : "\n";
8746 _visitNodeListWithSeparatorAndPrefix(prefix, node.declarations, "\n\n");
8747 return null;
8748 }
8749
8750 Object visitConditionalExpression(ConditionalExpression node) {
8751 _visitNode(node.condition);
8752 _writer.print(" ? ");
8753 _visitNode(node.thenExpression);
8754 _writer.print(" : ");
8755 _visitNode(node.elseExpression);
8756 return null;
8757 }
8758
8759 Object visitConstructorDeclaration(ConstructorDeclaration node) {
8760 _visitNode(node.documentationComment);
8761 _visitTokenWithSuffix(node.externalKeyword, " ");
8762 _visitTokenWithSuffix(node.constKeyword, " ");
8763 _visitTokenWithSuffix(node.factoryKeyword, " ");
8764 _visitNode(node.returnType);
8765 _visitNodeWithPrefix(".", node.name);
8766 _visitNode(node.parameters);
8767 _visitNodeListWithSeparatorAndPrefix(" : ", node.initializers, ", ");
8768 _visitNodeWithPrefix(" = ", node.redirectedConstructor);
8769 if (node.body is! EmptyFunctionBody) {
8770 _writer.print(' ');
8771 }
8772 _visitNode(node.body);
8773 return null;
8774 }
8775
8776 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
8777 _visitTokenWithSuffix(node.keyword, ".");
8778 _visitNode(node.fieldName);
8779 _writer.print(" = ");
8780 _visitNode(node.expression);
8781 return null;
8782 }
8783
8784 Object visitConstructorName(ConstructorName node) {
8785 _visitNode(node.type);
8786 _visitNodeWithPrefix(".", node.name);
8787 return null;
8788 }
8789
8790 Object visitContinueStatement(ContinueStatement node) {
8791 _writer.print("continue");
8792 _visitNodeWithPrefix(" ", node.label);
8793 _writer.print(";");
8794 return null;
8795 }
8796
8797 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
8798 _visitTokenWithSuffix(node.keyword, " ");
8799 _visitNodeWithSuffix(node.type, " ");
8800 _visitNode(node.identifier);
8801 return null;
8802 }
8803
8804 Object visitDefaultFormalParameter(DefaultFormalParameter node) {
8805 _visitNode(node.parameter);
8806 if (node.separator != null) {
8807 _writer.print(" ");
8808 _writer.print(node.separator.lexeme);
8809 _visitNodeWithPrefix(" ", node.defaultValue);
8810 }
8811 return null;
8812 }
8813
8814 Object visitDoStatement(DoStatement node) {
8815 _writer.print("do ");
8816 _visitNode(node.body);
8817 _writer.print(" while (");
8818 _visitNode(node.condition);
8819 _writer.print(");");
8820 return null;
8821 }
8822
8823 Object visitDoubleLiteral(DoubleLiteral node) {
8824 _writer.print(node.literal.lexeme);
8825 return null;
8826 }
8827
8828 Object visitEmptyFunctionBody(EmptyFunctionBody node) {
8829 _writer.print(';');
8830 return null;
8831 }
8832
8833 Object visitEmptyStatement(EmptyStatement node) {
8834 _writer.print(';');
8835 return null;
8836 }
8837
8838 Object visitExportDirective(ExportDirective node) {
8839 _writer.print("export ");
8840 _visitNode(node.uri);
8841 _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " ");
8842 _writer.print(';');
8843 return null;
8844 }
8845
8846 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
8847 _writer.print("=> ");
8848 _visitNode(node.expression);
8849 if (node.semicolon != null) {
8850 _writer.print(';');
8851 }
8852 return null;
8853 }
8854
8855 Object visitExpressionStatement(ExpressionStatement node) {
8856 _visitNode(node.expression);
8857 _writer.print(';');
8858 return null;
8859 }
8860
8861 Object visitExtendsClause(ExtendsClause node) {
8862 _writer.print("extends ");
8863 _visitNode(node.superclass);
8864 return null;
8865 }
8866
8867 Object visitFieldDeclaration(FieldDeclaration node) {
8868 _visitNode(node.documentationComment);
8869 _visitTokenWithSuffix(node.staticKeyword, " ");
8870 _visitNode(node.fields);
8871 _writer.print(";");
8872 return null;
8873 }
8874
8875 Object visitFieldFormalParameter(FieldFormalParameter node) {
8876 _visitTokenWithSuffix(node.keyword, " ");
8877 _visitNodeWithSuffix(node.type, " ");
8878 _writer.print("this.");
8879 _visitNode(node.identifier);
8880 _visitNode(node.parameters);
8881 return null;
8882 }
8883
8884 Object visitForEachStatement(ForEachStatement node) {
8885 DeclaredIdentifier loopVariable = node.loopVariable;
8886 _writer.print("for (");
8887 if (loopVariable == null) {
8888 _visitNode(node.identifier);
8889 } else {
8890 _visitNode(loopVariable);
8891 }
8892 _writer.print(" in ");
8893 _visitNode(node.iterator);
8894 _writer.print(") ");
8895 _visitNode(node.body);
8896 return null;
8897 }
8898
8899 Object visitFormalParameterList(FormalParameterList node) {
8900 String groupEnd = null;
8901 _writer.print('(');
8902 NodeList<FormalParameter> parameters = node.parameters;
8903 int size = parameters.length;
8904 for (int i = 0; i < size; i++) {
8905 FormalParameter parameter = parameters[i];
8906 if (i > 0) {
8907 _writer.print(", ");
8908 }
8909 if (groupEnd == null && parameter is DefaultFormalParameter) {
8910 if (identical(parameter.kind, ParameterKind.NAMED)) {
8911 groupEnd = "}";
8912 _writer.print('{');
8913 } else {
8914 groupEnd = "]";
8915 _writer.print('[');
8916 }
8917 }
8918 parameter.accept(this);
8919 }
8920 if (groupEnd != null) {
8921 _writer.print(groupEnd);
8922 }
8923 _writer.print(')');
8924 return null;
8925 }
8926
8927 Object visitForStatement(ForStatement node) {
8928 Expression initialization = node.initialization;
8929 _writer.print("for (");
8930 if (initialization != null) {
8931 _visitNode(initialization);
8932 } else {
8933 _visitNode(node.variables);
8934 }
8935 _writer.print(";");
8936 _visitNodeWithPrefix(" ", node.condition);
8937 _writer.print(";");
8938 _visitNodeListWithSeparatorAndPrefix(" ", node.updaters, ", ");
8939 _writer.print(") ");
8940 _visitNode(node.body);
8941 return null;
8942 }
8943
8944 Object visitFunctionDeclaration(FunctionDeclaration node) {
8945 _visitNodeWithSuffix(node.returnType, " ");
8946 _visitTokenWithSuffix(node.propertyKeyword, " ");
8947 _visitNode(node.name);
8948 _visitNode(node.functionExpression);
8949 return null;
8950 }
8951
8952 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
8953 _visitNode(node.functionDeclaration);
8954 _writer.print(';');
8955 return null;
8956 }
8957
8958 Object visitFunctionExpression(FunctionExpression node) {
8959 _visitNode(node.parameters);
8960 _writer.print(' ');
8961 _visitNode(node.body);
8962 return null;
8963 }
8964
8965 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
8966 _visitNode(node.function);
8967 _visitNode(node.argumentList);
8968 return null;
8969 }
8970
8971 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
8972 _writer.print("typedef ");
8973 _visitNodeWithSuffix(node.returnType, " ");
8974 _visitNode(node.name);
8975 _visitNode(node.typeParameters);
8976 _visitNode(node.parameters);
8977 _writer.print(";");
8978 return null;
8979 }
8980
8981 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
8982 _visitNodeWithSuffix(node.returnType, " ");
8983 _visitNode(node.identifier);
8984 _visitNode(node.parameters);
8985 return null;
8986 }
8987
8988 Object visitHideCombinator(HideCombinator node) {
8989 _writer.print("hide ");
8990 _visitNodeListWithSeparator(node.hiddenNames, ", ");
8991 return null;
8992 }
8993
8994 Object visitIfStatement(IfStatement node) {
8995 _writer.print("if (");
8996 _visitNode(node.condition);
8997 _writer.print(") ");
8998 _visitNode(node.thenStatement);
8999 _visitNodeWithPrefix(" else ", node.elseStatement);
9000 return null;
9001 }
9002
9003 Object visitImplementsClause(ImplementsClause node) {
9004 _writer.print("implements ");
9005 _visitNodeListWithSeparator(node.interfaces, ", ");
9006 return null;
9007 }
9008
9009 Object visitImportDirective(ImportDirective node) {
9010 _writer.print("import ");
9011 _visitNode(node.uri);
9012 _visitNodeWithPrefix(" as ", node.prefix);
9013 _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " ");
9014 _writer.print(';');
9015 return null;
9016 }
9017
9018 Object visitIndexExpression(IndexExpression node) {
9019 if (node.isCascaded) {
9020 _writer.print("..");
9021 } else {
9022 _visitNode(node.target);
9023 }
9024 _writer.print('[');
9025 _visitNode(node.index);
9026 _writer.print(']');
9027 return null;
9028 }
9029
9030 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
9031 _visitTokenWithSuffix(node.keyword, " ");
9032 _visitNode(node.constructorName);
9033 _visitNode(node.argumentList);
9034 return null;
9035 }
9036
9037 Object visitIntegerLiteral(IntegerLiteral node) {
9038 _writer.print(node.literal.lexeme);
9039 return null;
9040 }
9041
9042 Object visitInterpolationExpression(InterpolationExpression node) {
9043 if (node.rightBracket != null) {
9044 _writer.print("\${");
9045 _visitNode(node.expression);
9046 _writer.print("}");
9047 } else {
9048 _writer.print("\$");
9049 _visitNode(node.expression);
9050 }
9051 return null;
9052 }
9053
9054 Object visitInterpolationString(InterpolationString node) {
9055 _writer.print(node.contents.lexeme);
9056 return null;
9057 }
9058
9059 Object visitIsExpression(IsExpression node) {
9060 _visitNode(node.expression);
9061 if (node.notOperator == null) {
9062 _writer.print(" is ");
9063 } else {
9064 _writer.print(" is! ");
9065 }
9066 _visitNode(node.type);
9067 return null;
9068 }
9069
9070 Object visitLabel(Label node) {
9071 _visitNode(node.label);
9072 _writer.print(":");
9073 return null;
9074 }
9075
9076 Object visitLabeledStatement(LabeledStatement node) {
9077 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
9078 _visitNode(node.statement);
9079 return null;
9080 }
9081
9082 Object visitLibraryDirective(LibraryDirective node) {
9083 _writer.print("library ");
9084 _visitNode(node.name);
9085 _writer.print(';');
9086 _nl();
9087 return null;
9088 }
9089
9090 Object visitLibraryIdentifier(LibraryIdentifier node) {
9091 _writer.print(node.name);
9092 return null;
9093 }
9094
9095 Object visitListLiteral(ListLiteral node) {
9096 if (node.constKeyword != null) {
9097 _writer.print(node.constKeyword.lexeme);
9098 _writer.print(' ');
9099 }
9100 _visitNodeWithSuffix(node.typeArguments, " ");
9101 _writer.print("[");
9102 {
9103 NodeList<Expression> elements = node.elements;
9104 if (elements.length < 2 || elements.toString().length < 60) {
9105 _visitNodeListWithSeparator(elements, ", ");
9106 } else {
9107 String elementIndent = "${_indentString} ";
9108 _writer.print("\n");
9109 _writer.print(elementIndent);
9110 _visitNodeListWithSeparator(elements, ",\n${elementIndent}");
9111 }
9112 }
9113 _writer.print("]");
9114 return null;
9115 }
9116
9117 Object visitMapLiteral(MapLiteral node) {
9118 if (node.constKeyword != null) {
9119 _writer.print(node.constKeyword.lexeme);
9120 _writer.print(' ');
9121 }
9122 _visitNodeWithSuffix(node.typeArguments, " ");
9123 _writer.print("{");
9124 _visitNodeListWithSeparator(node.entries, ", ");
9125 _writer.print("}");
9126 return null;
9127 }
9128
9129 Object visitMapLiteralEntry(MapLiteralEntry node) {
9130 _visitNode(node.key);
9131 _writer.print(" : ");
9132 _visitNode(node.value);
9133 return null;
9134 }
9135
9136 Object visitMethodDeclaration(MethodDeclaration node) {
9137 _visitNode(node.documentationComment);
9138 _visitTokenWithSuffix(node.externalKeyword, " ");
9139 _visitTokenWithSuffix(node.modifierKeyword, " ");
9140 _visitNodeWithSuffix(node.returnType, " ");
9141 _visitTokenWithSuffix(node.propertyKeyword, " ");
9142 _visitTokenWithSuffix(node.operatorKeyword, " ");
9143 _visitNode(node.name);
9144 if (!node.isGetter) {
9145 _visitNode(node.parameters);
9146 }
9147 if (node.body is! EmptyFunctionBody) {
9148 _writer.print(' ');
9149 }
9150 _visitNode(node.body);
9151 return null;
9152 }
9153
9154 Object visitMethodInvocation(MethodInvocation node) {
9155 if (node.isCascaded) {
9156 _writer.print("..");
9157 } else {
9158 _visitNodeWithSuffix(node.target, ".");
9159 }
9160 _visitNode(node.methodName);
9161 _visitNode(node.argumentList);
9162 return null;
9163 }
9164
9165 Object visitNamedExpression(NamedExpression node) {
9166 _visitNode(node.name);
9167 _visitNodeWithPrefix(" ", node.expression);
9168 return null;
9169 }
9170
9171 Object visitNativeClause(NativeClause node) {
9172 _writer.print("native ");
9173 _visitNode(node.name);
9174 return null;
9175 }
9176
9177 Object visitNativeFunctionBody(NativeFunctionBody node) {
9178 _writer.print("native ");
9179 _visitNode(node.stringLiteral);
9180 _writer.print(';');
9181 return null;
9182 }
9183
9184 Object visitNullLiteral(NullLiteral node) {
9185 _writer.print("null");
9186 return null;
9187 }
9188
9189 Object visitParenthesizedExpression(ParenthesizedExpression node) {
9190 _writer.print('(');
9191 _visitNode(node.expression);
9192 _writer.print(')');
9193 return null;
9194 }
9195
9196 Object visitPartDirective(PartDirective node) {
9197 _writer.print("part ");
9198 _visitNode(node.uri);
9199 _writer.print(';');
9200 return null;
9201 }
9202
9203 Object visitPartOfDirective(PartOfDirective node) {
9204 _writer.print("part of ");
9205 _visitNode(node.libraryName);
9206 _writer.print(';');
9207 return null;
9208 }
9209
9210 Object visitPostfixExpression(PostfixExpression node) {
9211 _visitNode(node.operand);
9212 _writer.print(node.operator.lexeme);
9213 return null;
9214 }
9215
9216 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
9217 _visitNode(node.prefix);
9218 _writer.print('.');
9219 _visitNode(node.identifier);
9220 return null;
9221 }
9222
9223 Object visitPrefixExpression(PrefixExpression node) {
9224 _writer.print(node.operator.lexeme);
9225 _visitNode(node.operand);
9226 return null;
9227 }
9228
9229 Object visitPropertyAccess(PropertyAccess node) {
9230 if (node.isCascaded) {
9231 _writer.print("..");
9232 } else {
9233 _visitNodeWithSuffix(node.target, ".");
9234 }
9235 _visitNode(node.propertyName);
9236 return null;
9237 }
9238
9239 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
9240 _writer.print("this");
9241 _visitNodeWithPrefix(".", node.constructorName);
9242 _visitNode(node.argumentList);
9243 return null;
9244 }
9245
9246 Object visitRethrowExpression(RethrowExpression node) {
9247 _writer.print("rethrow");
9248 return null;
9249 }
9250
9251 Object visitReturnStatement(ReturnStatement node) {
9252 Expression expression = node.expression;
9253 if (expression == null) {
9254 _writer.print("return;");
9255 } else {
9256 _writer.print("return ");
9257 expression.accept(this);
9258 _writer.print(";");
9259 }
9260 return null;
9261 }
9262
9263 Object visitScriptTag(ScriptTag node) {
9264 _writer.print(node.scriptTag.lexeme);
9265 return null;
9266 }
9267
9268 Object visitShowCombinator(ShowCombinator node) {
9269 _writer.print("show ");
9270 _visitNodeListWithSeparator(node.shownNames, ", ");
9271 return null;
9272 }
9273
9274 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
9275 _visitTokenWithSuffix(node.keyword, " ");
9276 _visitNodeWithSuffix(node.type, " ");
9277 _visitNode(node.identifier);
9278 return null;
9279 }
9280
9281 Object visitSimpleIdentifier(SimpleIdentifier node) {
9282 _writer.print(node.token.lexeme);
9283 return null;
9284 }
9285
9286 Object visitSimpleStringLiteral(SimpleStringLiteral node) {
9287 _writer.print(node.literal.lexeme);
9288 return null;
9289 }
9290
9291 Object visitStringInterpolation(StringInterpolation node) {
9292 _visitNodeList(node.elements);
9293 return null;
9294 }
9295
9296 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
9297 _writer.print("super");
9298 _visitNodeWithPrefix(".", node.constructorName);
9299 _visitNode(node.argumentList);
9300 return null;
9301 }
9302
9303 Object visitSuperExpression(SuperExpression node) {
9304 _writer.print("super");
9305 return null;
9306 }
9307
9308 Object visitSwitchCase(SwitchCase node) {
9309 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
9310 _writer.print("case ");
9311 _visitNode(node.expression);
9312 _writer.print(": ");
9313 {
9314 _indentInc();
9315 _visitNodeListWithSeparator(node.statements, "\n");
9316 _indentDec();
9317 }
9318 return null;
9319 }
9320
9321 Object visitSwitchDefault(SwitchDefault node) {
9322 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
9323 _writer.print("default: ");
9324 {
9325 _indentInc();
9326 _visitNodeListWithSeparator(node.statements, "\n");
9327 _indentDec();
9328 }
9329 return null;
9330 }
9331
9332 Object visitSwitchStatement(SwitchStatement node) {
9333 _writer.print("switch (");
9334 _visitNode(node.expression);
9335 _writer.print(") {");
9336 {
9337 _indentInc();
9338 _visitNodeListWithSeparator(node.members, "\n");
9339 _indentDec();
9340 }
9341 _nl2();
9342 _writer.print('}');
9343 return null;
9344 }
9345
9346 Object visitSymbolLiteral(SymbolLiteral node) {
9347 _writer.print("#");
9348 _visitTokenListWithSeparator(node.components, ".");
9349 return null;
9350 }
9351
9352 Object visitThisExpression(ThisExpression node) {
9353 _writer.print("this");
9354 return null;
9355 }
9356
9357 Object visitThrowExpression(ThrowExpression node) {
9358 _writer.print("throw ");
9359 _visitNode(node.expression);
9360 return null;
9361 }
9362
9363 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
9364 _visitNodeWithSuffix(node.variables, ";");
9365 return null;
9366 }
9367
9368 Object visitTryStatement(TryStatement node) {
9369 _writer.print("try ");
9370 _visitNode(node.body);
9371 _visitNodeListWithSeparatorAndPrefix(" ", node.catchClauses, " ");
9372 _visitNodeWithPrefix(" finally ", node.finallyBlock);
9373 return null;
9374 }
9375
9376 Object visitTypeArgumentList(TypeArgumentList node) {
9377 _writer.print('<');
9378 _visitNodeListWithSeparator(node.arguments, ", ");
9379 _writer.print('>');
9380 return null;
9381 }
9382
9383 Object visitTypeName(TypeName node) {
9384 _visitNode(node.name);
9385 _visitNode(node.typeArguments);
9386 return null;
9387 }
9388
9389 Object visitTypeParameter(TypeParameter node) {
9390 _visitNode(node.name);
9391 _visitNodeWithPrefix(" extends ", node.bound);
9392 return null;
9393 }
9394
9395 Object visitTypeParameterList(TypeParameterList node) {
9396 _writer.print('<');
9397 _visitNodeListWithSeparator(node.typeParameters, ", ");
9398 _writer.print('>');
9399 return null;
9400 }
9401
9402 Object visitVariableDeclaration(VariableDeclaration node) {
9403 _visitNode(node.name);
9404 _visitNodeWithPrefix(" = ", node.initializer);
9405 return null;
9406 }
9407
9408 Object visitVariableDeclarationList(VariableDeclarationList node) {
9409 _visitTokenWithSuffix(node.keyword, " ");
9410 _visitNodeWithSuffix(node.type, " ");
9411 _visitNodeListWithSeparator(node.variables, ", ");
9412 return null;
9413 }
9414
9415 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) {
9416 _visitNode(node.variables);
9417 _writer.print(";");
9418 return null;
9419 }
9420
9421 Object visitWhileStatement(WhileStatement node) {
9422 _writer.print("while (");
9423 _visitNode(node.condition);
9424 _writer.print(") ");
9425 _visitNode(node.body);
9426 return null;
9427 }
9428
9429 Object visitWithClause(WithClause node) {
9430 _writer.print("with ");
9431 _visitNodeListWithSeparator(node.mixinTypes, ", ");
9432 return null;
9433 }
9434
9435 void _indent() {
9436 _writer.print(_indentString);
9437 }
9438
9439 void _indentDec() {
9440 _indentLevel -= 2;
9441 _indentString = StringUtils.repeat(" ", _indentLevel);
9442 }
9443
9444 void _indentInc() {
9445 _indentLevel += 2;
9446 _indentString = StringUtils.repeat(" ", _indentLevel);
9447 }
9448
9449 void _nl() {
9450 _writer.print("\n");
9451 }
9452
9453 void _nl2() {
9454 _nl();
9455 _indent();
9456 }
9457
9458 void _printLeadingComments(Statement statement) {
9459 List<String> comments = statement.getProperty(COMMENTS_KEY) as List<String>;
9460 if (comments == null) {
9461 return;
9462 }
9463 for (String comment in comments) {
9464 _writer.print(comment);
9465 _writer.print("\n");
9466 _indent();
9467 }
9468 }
9469
9470 /**
9471 * Safely visit the given node.
9472 *
9473 * @param node the node to be visited
9474 */
9475 void _visitNode(AstNode node) {
9476 if (node != null) {
9477 node.accept(this);
9478 }
9479 }
9480
9481 /**
9482 * Print a list of nodes without any separation.
9483 *
9484 * @param nodes the nodes to be printed
9485 * @param separator the separator to be printed between adjacent nodes
9486 */
9487 void _visitNodeList(NodeList<AstNode> nodes) {
9488 _visitNodeListWithSeparator(nodes, "");
9489 }
9490
9491 /**
9492 * Print a list of nodes, separated by the given separator.
9493 *
9494 * @param nodes the nodes to be printed
9495 * @param separator the separator to be printed between adjacent nodes
9496 */
9497 void _visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) {
9498 _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, "");
9499 }
9500
9501 /**
9502 * Print a list of nodes, separated by the given separator.
9503 *
9504 * @param prefix the prefix to be printed if the list is not empty
9505 * @param nodes the nodes to be printed
9506 * @param separator the separator to be printed between adjacent nodes
9507 */
9508 void _visitNodeListWithSeparatorAndPrefix(String prefix, NodeList<AstNode> nod es, String separator) {
9509 _visitNodeListWithSeparatorPrefixAndSuffix(prefix, nodes, separator, "");
9510 }
9511
9512 /**
9513 * Print a list of nodes, separated by the given separator.
9514 *
9515 * @param nodes the nodes to be printed
9516 * @param separator the separator to be printed between adjacent nodes
9517 * @param suffix the suffix to be printed if the list is not empty
9518 */
9519 void _visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes, String sepa rator, String suffix) {
9520 _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, suffix);
9521 }
9522
9523 /**
9524 * Print a list of nodes, separated by the given separator.
9525 *
9526 * @param prefix the prefix to be printed if the list is not empty
9527 * @param nodes the nodes to be printed
9528 * @param separator the separator to be printed between adjacent nodes
9529 * @param suffix the suffix to be printed if the list is not empty
9530 */
9531 void _visitNodeListWithSeparatorPrefixAndSuffix(String prefix, NodeList<AstNod e> nodes, String separator, String suffix) {
9532 if (nodes != null) {
9533 int size = nodes.length;
9534 if (size != 0) {
9535 // prefix
9536 _writer.print(prefix);
9537 if (prefix.endsWith("\n")) {
9538 _indent();
9539 }
9540 // nodes
9541 bool newLineSeparator = separator.endsWith("\n");
9542 for (int i = 0; i < size; i++) {
9543 if (i > 0) {
9544 _writer.print(separator);
9545 if (newLineSeparator) {
9546 _indent();
9547 }
9548 }
9549 AstNode node = nodes[i];
9550 if (node is Statement) {
9551 _printLeadingComments(node);
9552 }
9553 node.accept(this);
9554 }
9555 // suffix
9556 _writer.print(suffix);
9557 }
9558 }
9559 }
9560
9561 /**
9562 * Safely visit the given node, printing the prefix before the node if it is n on-<code>null</code>
9563 * .
9564 *
9565 * @param prefix the prefix to be printed if there is a node to visit
9566 * @param node the node to be visited
9567 */
9568 void _visitNodeWithPrefix(String prefix, AstNode node) {
9569 if (node != null) {
9570 _writer.print(prefix);
9571 node.accept(this);
9572 }
9573 }
9574
9575 /**
9576 * Safely visit the given node, printing the suffix after the node if it is no n-<code>null</code>.
9577 *
9578 * @param suffix the suffix to be printed if there is a node to visit
9579 * @param node the node to be visited
9580 */
9581 void _visitNodeWithSuffix(AstNode node, String suffix) {
9582 if (node != null) {
9583 node.accept(this);
9584 _writer.print(suffix);
9585 }
9586 }
9587
9588 /**
9589 * Print a list of tokens, separated by the given separator.
9590 *
9591 * @param tokens the tokens to be printed
9592 * @param separator the separator to be printed between adjacent tokens
9593 */
9594 void _visitTokenListWithSeparator(List<Token> tokens, String separator) {
9595 int size = tokens.length;
9596 for (int i = 0; i < size; i++) {
9597 if ("\n" == separator) {
9598 _writer.print("\n");
9599 _indent();
9600 } else if (i > 0) {
9601 _writer.print(separator);
9602 }
9603 _writer.print(tokens[i].lexeme);
9604 }
9605 }
9606
9607 /**
9608 * Safely visit the given node, printing the suffix after the node if it is no n-<code>null</code>.
9609 *
9610 * @param suffix the suffix to be printed if there is a node to visit
9611 * @param node the node to be visited
9612 */
9613 void _visitTokenWithSuffix(Token token, String suffix) {
9614 if (token != null) {
9615 _writer.print(token.lexeme);
9616 _writer.print(suffix);
9617 }
9618 }
9619 }
9620 Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline> { 8541 Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline> {
9621 'parseCompilationUnit_1': new MethodTrampoline(1, (Parser target, arg0) => tar get.parseCompilationUnit(arg0)), 8542 'parseCompilationUnit_1': new MethodTrampoline(1, (Parser target, arg0) => tar get.parseCompilationUnit(arg0)),
9622 'parseExpression_1': new MethodTrampoline(1, (Parser target, arg0) => target.p arseExpression(arg0)), 8543 'parseExpression_1': new MethodTrampoline(1, (Parser target, arg0) => target.p arseExpression(arg0)),
9623 'parseStatement_1': new MethodTrampoline(1, (Parser target, arg0) => target.pa rseStatement(arg0)), 8544 'parseStatement_1': new MethodTrampoline(1, (Parser target, arg0) => target.pa rseStatement(arg0)),
9624 'parseStatements_1': new MethodTrampoline(1, (Parser target, arg0) => target.p arseStatements(arg0)), 8545 'parseStatements_1': new MethodTrampoline(1, (Parser target, arg0) => target.p arseStatements(arg0)),
9625 'parseAnnotation_0': new MethodTrampoline(0, (Parser target) => target.parseAn notation()), 8546 'parseAnnotation_0': new MethodTrampoline(0, (Parser target) => target.parseAn notation()),
9626 'parseArgument_0': new MethodTrampoline(0, (Parser target) => target.parseArgu ment()), 8547 'parseArgument_0': new MethodTrampoline(0, (Parser target) => target.parseArgu ment()),
9627 'parseArgumentList_0': new MethodTrampoline(0, (Parser target) => target.parse ArgumentList()), 8548 'parseArgumentList_0': new MethodTrampoline(0, (Parser target) => target.parse ArgumentList()),
9628 'parseBitwiseOrExpression_0': new MethodTrampoline(0, (Parser target) => targe t.parseBitwiseOrExpression()), 8549 'parseBitwiseOrExpression_0': new MethodTrampoline(0, (Parser target) => targe t.parseBitwiseOrExpression()),
9629 'parseBlock_0': new MethodTrampoline(0, (Parser target) => target.parseBlock() ), 8550 'parseBlock_0': new MethodTrampoline(0, (Parser target) => target.parseBlock() ),
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
9829 return trampoline(target, arguments[0], arguments[1]); 8750 return trampoline(target, arguments[0], arguments[1]);
9830 case 3: 8751 case 3:
9831 return trampoline(target, arguments[0], arguments[1], arguments[2]); 8752 return trampoline(target, arguments[0], arguments[1], arguments[2]);
9832 case 4: 8753 case 4:
9833 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]); 8754 return trampoline(target, arguments[0], arguments[1], arguments[2], argu ments[3]);
9834 default: 8755 default:
9835 throw new IllegalArgumentException("Not implemented for > 4 arguments"); 8756 throw new IllegalArgumentException("Not implemented for > 4 arguments");
9836 } 8757 }
9837 } 8758 }
9838 } 8759 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/index.dart ('k') | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698