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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 3cbf5ac85ec2d77ead4ae7c4778698df9a1530ff..636071ba4b932065b77efdf34db925907bfdaa27 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -8538,1085 +8538,6 @@ class ResolutionCopier implements AstVisitor<bool> {
return first.lexeme == second.lexeme;
}
}
-
-/**
- * Instances of the class {link ToFormattedSourceVisitor} write a source representation of a visited
- * AST node (and all of it's children) to a writer.
- */
-class ToFormattedSourceVisitor implements AstVisitor<Object> {
- static String COMMENTS_KEY = "List of comments before statement";
-
- /**
- * The writer to which the source is to be written.
- */
- PrintWriter _writer;
-
- int _indentLevel = 0;
-
- String _indentString = "";
-
- /**
- * Initialize a newly created visitor to write source code representing the visited nodes to the
- * given writer.
- *
- * @param writer the writer to which the source is to be written
- */
- ToFormattedSourceVisitor(PrintWriter writer) {
- this._writer = writer;
- }
-
- Object visitAdjacentStrings(AdjacentStrings node) {
- _visitNodeListWithSeparator(node.strings, " ");
- return null;
- }
-
- Object visitAnnotation(Annotation node) {
- _writer.print('@');
- _visitNode(node.name);
- _visitNodeWithPrefix(".", node.constructorName);
- _visitNode(node.arguments);
- return null;
- }
-
- Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) {
- _writer.print('?');
- _visitNode(node.identifier);
- return null;
- }
-
- Object visitArgumentList(ArgumentList node) {
- _writer.print('(');
- _visitNodeListWithSeparator(node.arguments, ", ");
- _writer.print(')');
- return null;
- }
-
- Object visitAsExpression(AsExpression node) {
- _visitNode(node.expression);
- _writer.print(" as ");
- _visitNode(node.type);
- return null;
- }
-
- Object visitAssertStatement(AssertStatement node) {
- _writer.print("assert(");
- _visitNode(node.condition);
- _writer.print(");");
- return null;
- }
-
- Object visitAssignmentExpression(AssignmentExpression node) {
- _visitNode(node.leftHandSide);
- _writer.print(' ');
- _writer.print(node.operator.lexeme);
- _writer.print(' ');
- _visitNode(node.rightHandSide);
- return null;
- }
-
- Object visitBinaryExpression(BinaryExpression node) {
- _visitNode(node.leftOperand);
- _writer.print(' ');
- _writer.print(node.operator.lexeme);
- _writer.print(' ');
- _visitNode(node.rightOperand);
- return null;
- }
-
- Object visitBlock(Block node) {
- _writer.print('{');
- {
- _indentInc();
- _visitNodeListWithSeparatorAndPrefix("\n", node.statements, "\n");
- _indentDec();
- }
- _nl2();
- _writer.print('}');
- return null;
- }
-
- Object visitBlockFunctionBody(BlockFunctionBody node) {
- _visitNode(node.block);
- return null;
- }
-
- Object visitBooleanLiteral(BooleanLiteral node) {
- _writer.print(node.literal.lexeme);
- return null;
- }
-
- Object visitBreakStatement(BreakStatement node) {
- _writer.print("break");
- _visitNodeWithPrefix(" ", node.label);
- _writer.print(";");
- return null;
- }
-
- Object visitCascadeExpression(CascadeExpression node) {
- _visitNode(node.target);
- _visitNodeList(node.cascadeSections);
- return null;
- }
-
- Object visitCatchClause(CatchClause node) {
- _visitNodeWithPrefix("on ", node.exceptionType);
- if (node.catchKeyword != null) {
- if (node.exceptionType != null) {
- _writer.print(' ');
- }
- _writer.print("catch (");
- _visitNode(node.exceptionParameter);
- _visitNodeWithPrefix(", ", node.stackTraceParameter);
- _writer.print(") ");
- } else {
- _writer.print(" ");
- }
- _visitNode(node.body);
- return null;
- }
-
- Object visitClassDeclaration(ClassDeclaration node) {
- _visitNode(node.documentationComment);
- _visitTokenWithSuffix(node.abstractKeyword, " ");
- _writer.print("class ");
- _visitNode(node.name);
- _visitNode(node.typeParameters);
- _visitNodeWithPrefix(" ", node.extendsClause);
- _visitNodeWithPrefix(" ", node.withClause);
- _visitNodeWithPrefix(" ", node.implementsClause);
- _writer.print(" {");
- {
- _indentInc();
- _visitNodeListWithSeparatorAndPrefix("\n", node.members, "\n\n");
- _indentDec();
- }
- _nl2();
- _writer.print("}");
- return null;
- }
-
- Object visitClassTypeAlias(ClassTypeAlias node) {
- _writer.print("typedef ");
- _visitNode(node.name);
- _visitNode(node.typeParameters);
- _writer.print(" = ");
- if (node.abstractKeyword != null) {
- _writer.print("abstract ");
- }
- _visitNode(node.superclass);
- _visitNodeWithPrefix(" ", node.withClause);
- _visitNodeWithPrefix(" ", node.implementsClause);
- _writer.print(";");
- return null;
- }
-
- Object visitComment(Comment node) {
- Token token = node.beginToken;
- while (token != null) {
- bool firstLine = true;
- for (String line in StringUtils.split(token.lexeme, "\n")) {
- if (firstLine) {
- firstLine = false;
- } else {
- line = " ${line.trim()}";
- line = StringUtils.replace(line, "/*", "/ *");
- }
- _writer.print(line);
- _nl2();
- }
- if (identical(token, node.endToken)) {
- break;
- }
- }
- return null;
- }
-
- Object visitCommentReference(CommentReference node) => null;
-
- Object visitCompilationUnit(CompilationUnit node) {
- ScriptTag scriptTag = node.scriptTag;
- NodeList<Directive> directives = node.directives;
- _visitNode(scriptTag);
- // directives
- String prefix = scriptTag == null ? "" : " ";
- _visitNodeListWithSeparatorAndPrefix(prefix, directives, "\n");
- _nl();
- // declarations
- prefix = scriptTag == null && directives.isEmpty ? "" : "\n";
- _visitNodeListWithSeparatorAndPrefix(prefix, node.declarations, "\n\n");
- return null;
- }
-
- Object visitConditionalExpression(ConditionalExpression node) {
- _visitNode(node.condition);
- _writer.print(" ? ");
- _visitNode(node.thenExpression);
- _writer.print(" : ");
- _visitNode(node.elseExpression);
- return null;
- }
-
- Object visitConstructorDeclaration(ConstructorDeclaration node) {
- _visitNode(node.documentationComment);
- _visitTokenWithSuffix(node.externalKeyword, " ");
- _visitTokenWithSuffix(node.constKeyword, " ");
- _visitTokenWithSuffix(node.factoryKeyword, " ");
- _visitNode(node.returnType);
- _visitNodeWithPrefix(".", node.name);
- _visitNode(node.parameters);
- _visitNodeListWithSeparatorAndPrefix(" : ", node.initializers, ", ");
- _visitNodeWithPrefix(" = ", node.redirectedConstructor);
- if (node.body is! EmptyFunctionBody) {
- _writer.print(' ');
- }
- _visitNode(node.body);
- return null;
- }
-
- Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
- _visitTokenWithSuffix(node.keyword, ".");
- _visitNode(node.fieldName);
- _writer.print(" = ");
- _visitNode(node.expression);
- return null;
- }
-
- Object visitConstructorName(ConstructorName node) {
- _visitNode(node.type);
- _visitNodeWithPrefix(".", node.name);
- return null;
- }
-
- Object visitContinueStatement(ContinueStatement node) {
- _writer.print("continue");
- _visitNodeWithPrefix(" ", node.label);
- _writer.print(";");
- return null;
- }
-
- Object visitDeclaredIdentifier(DeclaredIdentifier node) {
- _visitTokenWithSuffix(node.keyword, " ");
- _visitNodeWithSuffix(node.type, " ");
- _visitNode(node.identifier);
- return null;
- }
-
- Object visitDefaultFormalParameter(DefaultFormalParameter node) {
- _visitNode(node.parameter);
- if (node.separator != null) {
- _writer.print(" ");
- _writer.print(node.separator.lexeme);
- _visitNodeWithPrefix(" ", node.defaultValue);
- }
- return null;
- }
-
- Object visitDoStatement(DoStatement node) {
- _writer.print("do ");
- _visitNode(node.body);
- _writer.print(" while (");
- _visitNode(node.condition);
- _writer.print(");");
- return null;
- }
-
- Object visitDoubleLiteral(DoubleLiteral node) {
- _writer.print(node.literal.lexeme);
- return null;
- }
-
- Object visitEmptyFunctionBody(EmptyFunctionBody node) {
- _writer.print(';');
- return null;
- }
-
- Object visitEmptyStatement(EmptyStatement node) {
- _writer.print(';');
- return null;
- }
-
- Object visitExportDirective(ExportDirective node) {
- _writer.print("export ");
- _visitNode(node.uri);
- _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " ");
- _writer.print(';');
- return null;
- }
-
- Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
- _writer.print("=> ");
- _visitNode(node.expression);
- if (node.semicolon != null) {
- _writer.print(';');
- }
- return null;
- }
-
- Object visitExpressionStatement(ExpressionStatement node) {
- _visitNode(node.expression);
- _writer.print(';');
- return null;
- }
-
- Object visitExtendsClause(ExtendsClause node) {
- _writer.print("extends ");
- _visitNode(node.superclass);
- return null;
- }
-
- Object visitFieldDeclaration(FieldDeclaration node) {
- _visitNode(node.documentationComment);
- _visitTokenWithSuffix(node.staticKeyword, " ");
- _visitNode(node.fields);
- _writer.print(";");
- return null;
- }
-
- Object visitFieldFormalParameter(FieldFormalParameter node) {
- _visitTokenWithSuffix(node.keyword, " ");
- _visitNodeWithSuffix(node.type, " ");
- _writer.print("this.");
- _visitNode(node.identifier);
- _visitNode(node.parameters);
- return null;
- }
-
- Object visitForEachStatement(ForEachStatement node) {
- DeclaredIdentifier loopVariable = node.loopVariable;
- _writer.print("for (");
- if (loopVariable == null) {
- _visitNode(node.identifier);
- } else {
- _visitNode(loopVariable);
- }
- _writer.print(" in ");
- _visitNode(node.iterator);
- _writer.print(") ");
- _visitNode(node.body);
- return null;
- }
-
- Object visitFormalParameterList(FormalParameterList node) {
- String groupEnd = null;
- _writer.print('(');
- NodeList<FormalParameter> parameters = node.parameters;
- int size = parameters.length;
- for (int i = 0; i < size; i++) {
- FormalParameter parameter = parameters[i];
- if (i > 0) {
- _writer.print(", ");
- }
- if (groupEnd == null && parameter is DefaultFormalParameter) {
- if (identical(parameter.kind, ParameterKind.NAMED)) {
- groupEnd = "}";
- _writer.print('{');
- } else {
- groupEnd = "]";
- _writer.print('[');
- }
- }
- parameter.accept(this);
- }
- if (groupEnd != null) {
- _writer.print(groupEnd);
- }
- _writer.print(')');
- return null;
- }
-
- Object visitForStatement(ForStatement node) {
- Expression initialization = node.initialization;
- _writer.print("for (");
- if (initialization != null) {
- _visitNode(initialization);
- } else {
- _visitNode(node.variables);
- }
- _writer.print(";");
- _visitNodeWithPrefix(" ", node.condition);
- _writer.print(";");
- _visitNodeListWithSeparatorAndPrefix(" ", node.updaters, ", ");
- _writer.print(") ");
- _visitNode(node.body);
- return null;
- }
-
- Object visitFunctionDeclaration(FunctionDeclaration node) {
- _visitNodeWithSuffix(node.returnType, " ");
- _visitTokenWithSuffix(node.propertyKeyword, " ");
- _visitNode(node.name);
- _visitNode(node.functionExpression);
- return null;
- }
-
- Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
- _visitNode(node.functionDeclaration);
- _writer.print(';');
- return null;
- }
-
- Object visitFunctionExpression(FunctionExpression node) {
- _visitNode(node.parameters);
- _writer.print(' ');
- _visitNode(node.body);
- return null;
- }
-
- Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
- _visitNode(node.function);
- _visitNode(node.argumentList);
- return null;
- }
-
- Object visitFunctionTypeAlias(FunctionTypeAlias node) {
- _writer.print("typedef ");
- _visitNodeWithSuffix(node.returnType, " ");
- _visitNode(node.name);
- _visitNode(node.typeParameters);
- _visitNode(node.parameters);
- _writer.print(";");
- return null;
- }
-
- Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
- _visitNodeWithSuffix(node.returnType, " ");
- _visitNode(node.identifier);
- _visitNode(node.parameters);
- return null;
- }
-
- Object visitHideCombinator(HideCombinator node) {
- _writer.print("hide ");
- _visitNodeListWithSeparator(node.hiddenNames, ", ");
- return null;
- }
-
- Object visitIfStatement(IfStatement node) {
- _writer.print("if (");
- _visitNode(node.condition);
- _writer.print(") ");
- _visitNode(node.thenStatement);
- _visitNodeWithPrefix(" else ", node.elseStatement);
- return null;
- }
-
- Object visitImplementsClause(ImplementsClause node) {
- _writer.print("implements ");
- _visitNodeListWithSeparator(node.interfaces, ", ");
- return null;
- }
-
- Object visitImportDirective(ImportDirective node) {
- _writer.print("import ");
- _visitNode(node.uri);
- _visitNodeWithPrefix(" as ", node.prefix);
- _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " ");
- _writer.print(';');
- return null;
- }
-
- Object visitIndexExpression(IndexExpression node) {
- if (node.isCascaded) {
- _writer.print("..");
- } else {
- _visitNode(node.target);
- }
- _writer.print('[');
- _visitNode(node.index);
- _writer.print(']');
- return null;
- }
-
- Object visitInstanceCreationExpression(InstanceCreationExpression node) {
- _visitTokenWithSuffix(node.keyword, " ");
- _visitNode(node.constructorName);
- _visitNode(node.argumentList);
- return null;
- }
-
- Object visitIntegerLiteral(IntegerLiteral node) {
- _writer.print(node.literal.lexeme);
- return null;
- }
-
- Object visitInterpolationExpression(InterpolationExpression node) {
- if (node.rightBracket != null) {
- _writer.print("\${");
- _visitNode(node.expression);
- _writer.print("}");
- } else {
- _writer.print("\$");
- _visitNode(node.expression);
- }
- return null;
- }
-
- Object visitInterpolationString(InterpolationString node) {
- _writer.print(node.contents.lexeme);
- return null;
- }
-
- Object visitIsExpression(IsExpression node) {
- _visitNode(node.expression);
- if (node.notOperator == null) {
- _writer.print(" is ");
- } else {
- _writer.print(" is! ");
- }
- _visitNode(node.type);
- return null;
- }
-
- Object visitLabel(Label node) {
- _visitNode(node.label);
- _writer.print(":");
- return null;
- }
-
- Object visitLabeledStatement(LabeledStatement node) {
- _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
- _visitNode(node.statement);
- return null;
- }
-
- Object visitLibraryDirective(LibraryDirective node) {
- _writer.print("library ");
- _visitNode(node.name);
- _writer.print(';');
- _nl();
- return null;
- }
-
- Object visitLibraryIdentifier(LibraryIdentifier node) {
- _writer.print(node.name);
- return null;
- }
-
- Object visitListLiteral(ListLiteral node) {
- if (node.constKeyword != null) {
- _writer.print(node.constKeyword.lexeme);
- _writer.print(' ');
- }
- _visitNodeWithSuffix(node.typeArguments, " ");
- _writer.print("[");
- {
- NodeList<Expression> elements = node.elements;
- if (elements.length < 2 || elements.toString().length < 60) {
- _visitNodeListWithSeparator(elements, ", ");
- } else {
- String elementIndent = "${_indentString} ";
- _writer.print("\n");
- _writer.print(elementIndent);
- _visitNodeListWithSeparator(elements, ",\n${elementIndent}");
- }
- }
- _writer.print("]");
- return null;
- }
-
- Object visitMapLiteral(MapLiteral node) {
- if (node.constKeyword != null) {
- _writer.print(node.constKeyword.lexeme);
- _writer.print(' ');
- }
- _visitNodeWithSuffix(node.typeArguments, " ");
- _writer.print("{");
- _visitNodeListWithSeparator(node.entries, ", ");
- _writer.print("}");
- return null;
- }
-
- Object visitMapLiteralEntry(MapLiteralEntry node) {
- _visitNode(node.key);
- _writer.print(" : ");
- _visitNode(node.value);
- return null;
- }
-
- Object visitMethodDeclaration(MethodDeclaration node) {
- _visitNode(node.documentationComment);
- _visitTokenWithSuffix(node.externalKeyword, " ");
- _visitTokenWithSuffix(node.modifierKeyword, " ");
- _visitNodeWithSuffix(node.returnType, " ");
- _visitTokenWithSuffix(node.propertyKeyword, " ");
- _visitTokenWithSuffix(node.operatorKeyword, " ");
- _visitNode(node.name);
- if (!node.isGetter) {
- _visitNode(node.parameters);
- }
- if (node.body is! EmptyFunctionBody) {
- _writer.print(' ');
- }
- _visitNode(node.body);
- return null;
- }
-
- Object visitMethodInvocation(MethodInvocation node) {
- if (node.isCascaded) {
- _writer.print("..");
- } else {
- _visitNodeWithSuffix(node.target, ".");
- }
- _visitNode(node.methodName);
- _visitNode(node.argumentList);
- return null;
- }
-
- Object visitNamedExpression(NamedExpression node) {
- _visitNode(node.name);
- _visitNodeWithPrefix(" ", node.expression);
- return null;
- }
-
- Object visitNativeClause(NativeClause node) {
- _writer.print("native ");
- _visitNode(node.name);
- return null;
- }
-
- Object visitNativeFunctionBody(NativeFunctionBody node) {
- _writer.print("native ");
- _visitNode(node.stringLiteral);
- _writer.print(';');
- return null;
- }
-
- Object visitNullLiteral(NullLiteral node) {
- _writer.print("null");
- return null;
- }
-
- Object visitParenthesizedExpression(ParenthesizedExpression node) {
- _writer.print('(');
- _visitNode(node.expression);
- _writer.print(')');
- return null;
- }
-
- Object visitPartDirective(PartDirective node) {
- _writer.print("part ");
- _visitNode(node.uri);
- _writer.print(';');
- return null;
- }
-
- Object visitPartOfDirective(PartOfDirective node) {
- _writer.print("part of ");
- _visitNode(node.libraryName);
- _writer.print(';');
- return null;
- }
-
- Object visitPostfixExpression(PostfixExpression node) {
- _visitNode(node.operand);
- _writer.print(node.operator.lexeme);
- return null;
- }
-
- Object visitPrefixedIdentifier(PrefixedIdentifier node) {
- _visitNode(node.prefix);
- _writer.print('.');
- _visitNode(node.identifier);
- return null;
- }
-
- Object visitPrefixExpression(PrefixExpression node) {
- _writer.print(node.operator.lexeme);
- _visitNode(node.operand);
- return null;
- }
-
- Object visitPropertyAccess(PropertyAccess node) {
- if (node.isCascaded) {
- _writer.print("..");
- } else {
- _visitNodeWithSuffix(node.target, ".");
- }
- _visitNode(node.propertyName);
- return null;
- }
-
- Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
- _writer.print("this");
- _visitNodeWithPrefix(".", node.constructorName);
- _visitNode(node.argumentList);
- return null;
- }
-
- Object visitRethrowExpression(RethrowExpression node) {
- _writer.print("rethrow");
- return null;
- }
-
- Object visitReturnStatement(ReturnStatement node) {
- Expression expression = node.expression;
- if (expression == null) {
- _writer.print("return;");
- } else {
- _writer.print("return ");
- expression.accept(this);
- _writer.print(";");
- }
- return null;
- }
-
- Object visitScriptTag(ScriptTag node) {
- _writer.print(node.scriptTag.lexeme);
- return null;
- }
-
- Object visitShowCombinator(ShowCombinator node) {
- _writer.print("show ");
- _visitNodeListWithSeparator(node.shownNames, ", ");
- return null;
- }
-
- Object visitSimpleFormalParameter(SimpleFormalParameter node) {
- _visitTokenWithSuffix(node.keyword, " ");
- _visitNodeWithSuffix(node.type, " ");
- _visitNode(node.identifier);
- return null;
- }
-
- Object visitSimpleIdentifier(SimpleIdentifier node) {
- _writer.print(node.token.lexeme);
- return null;
- }
-
- Object visitSimpleStringLiteral(SimpleStringLiteral node) {
- _writer.print(node.literal.lexeme);
- return null;
- }
-
- Object visitStringInterpolation(StringInterpolation node) {
- _visitNodeList(node.elements);
- return null;
- }
-
- Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
- _writer.print("super");
- _visitNodeWithPrefix(".", node.constructorName);
- _visitNode(node.argumentList);
- return null;
- }
-
- Object visitSuperExpression(SuperExpression node) {
- _writer.print("super");
- return null;
- }
-
- Object visitSwitchCase(SwitchCase node) {
- _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
- _writer.print("case ");
- _visitNode(node.expression);
- _writer.print(": ");
- {
- _indentInc();
- _visitNodeListWithSeparator(node.statements, "\n");
- _indentDec();
- }
- return null;
- }
-
- Object visitSwitchDefault(SwitchDefault node) {
- _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " ");
- _writer.print("default: ");
- {
- _indentInc();
- _visitNodeListWithSeparator(node.statements, "\n");
- _indentDec();
- }
- return null;
- }
-
- Object visitSwitchStatement(SwitchStatement node) {
- _writer.print("switch (");
- _visitNode(node.expression);
- _writer.print(") {");
- {
- _indentInc();
- _visitNodeListWithSeparator(node.members, "\n");
- _indentDec();
- }
- _nl2();
- _writer.print('}');
- return null;
- }
-
- Object visitSymbolLiteral(SymbolLiteral node) {
- _writer.print("#");
- _visitTokenListWithSeparator(node.components, ".");
- return null;
- }
-
- Object visitThisExpression(ThisExpression node) {
- _writer.print("this");
- return null;
- }
-
- Object visitThrowExpression(ThrowExpression node) {
- _writer.print("throw ");
- _visitNode(node.expression);
- return null;
- }
-
- Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
- _visitNodeWithSuffix(node.variables, ";");
- return null;
- }
-
- Object visitTryStatement(TryStatement node) {
- _writer.print("try ");
- _visitNode(node.body);
- _visitNodeListWithSeparatorAndPrefix(" ", node.catchClauses, " ");
- _visitNodeWithPrefix(" finally ", node.finallyBlock);
- return null;
- }
-
- Object visitTypeArgumentList(TypeArgumentList node) {
- _writer.print('<');
- _visitNodeListWithSeparator(node.arguments, ", ");
- _writer.print('>');
- return null;
- }
-
- Object visitTypeName(TypeName node) {
- _visitNode(node.name);
- _visitNode(node.typeArguments);
- return null;
- }
-
- Object visitTypeParameter(TypeParameter node) {
- _visitNode(node.name);
- _visitNodeWithPrefix(" extends ", node.bound);
- return null;
- }
-
- Object visitTypeParameterList(TypeParameterList node) {
- _writer.print('<');
- _visitNodeListWithSeparator(node.typeParameters, ", ");
- _writer.print('>');
- return null;
- }
-
- Object visitVariableDeclaration(VariableDeclaration node) {
- _visitNode(node.name);
- _visitNodeWithPrefix(" = ", node.initializer);
- return null;
- }
-
- Object visitVariableDeclarationList(VariableDeclarationList node) {
- _visitTokenWithSuffix(node.keyword, " ");
- _visitNodeWithSuffix(node.type, " ");
- _visitNodeListWithSeparator(node.variables, ", ");
- return null;
- }
-
- Object visitVariableDeclarationStatement(VariableDeclarationStatement node) {
- _visitNode(node.variables);
- _writer.print(";");
- return null;
- }
-
- Object visitWhileStatement(WhileStatement node) {
- _writer.print("while (");
- _visitNode(node.condition);
- _writer.print(") ");
- _visitNode(node.body);
- return null;
- }
-
- Object visitWithClause(WithClause node) {
- _writer.print("with ");
- _visitNodeListWithSeparator(node.mixinTypes, ", ");
- return null;
- }
-
- void _indent() {
- _writer.print(_indentString);
- }
-
- void _indentDec() {
- _indentLevel -= 2;
- _indentString = StringUtils.repeat(" ", _indentLevel);
- }
-
- void _indentInc() {
- _indentLevel += 2;
- _indentString = StringUtils.repeat(" ", _indentLevel);
- }
-
- void _nl() {
- _writer.print("\n");
- }
-
- void _nl2() {
- _nl();
- _indent();
- }
-
- void _printLeadingComments(Statement statement) {
- List<String> comments = statement.getProperty(COMMENTS_KEY) as List<String>;
- if (comments == null) {
- return;
- }
- for (String comment in comments) {
- _writer.print(comment);
- _writer.print("\n");
- _indent();
- }
- }
-
- /**
- * Safely visit the given node.
- *
- * @param node the node to be visited
- */
- void _visitNode(AstNode node) {
- if (node != null) {
- node.accept(this);
- }
- }
-
- /**
- * Print a list of nodes without any separation.
- *
- * @param nodes the nodes to be printed
- * @param separator the separator to be printed between adjacent nodes
- */
- void _visitNodeList(NodeList<AstNode> nodes) {
- _visitNodeListWithSeparator(nodes, "");
- }
-
- /**
- * Print a list of nodes, separated by the given separator.
- *
- * @param nodes the nodes to be printed
- * @param separator the separator to be printed between adjacent nodes
- */
- void _visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) {
- _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, "");
- }
-
- /**
- * Print a list of nodes, separated by the given separator.
- *
- * @param prefix the prefix to be printed if the list is not empty
- * @param nodes the nodes to be printed
- * @param separator the separator to be printed between adjacent nodes
- */
- void _visitNodeListWithSeparatorAndPrefix(String prefix, NodeList<AstNode> nodes, String separator) {
- _visitNodeListWithSeparatorPrefixAndSuffix(prefix, nodes, separator, "");
- }
-
- /**
- * Print a list of nodes, separated by the given separator.
- *
- * @param nodes the nodes to be printed
- * @param separator the separator to be printed between adjacent nodes
- * @param suffix the suffix to be printed if the list is not empty
- */
- void _visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes, String separator, String suffix) {
- _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, suffix);
- }
-
- /**
- * Print a list of nodes, separated by the given separator.
- *
- * @param prefix the prefix to be printed if the list is not empty
- * @param nodes the nodes to be printed
- * @param separator the separator to be printed between adjacent nodes
- * @param suffix the suffix to be printed if the list is not empty
- */
- void _visitNodeListWithSeparatorPrefixAndSuffix(String prefix, NodeList<AstNode> nodes, String separator, String suffix) {
- if (nodes != null) {
- int size = nodes.length;
- if (size != 0) {
- // prefix
- _writer.print(prefix);
- if (prefix.endsWith("\n")) {
- _indent();
- }
- // nodes
- bool newLineSeparator = separator.endsWith("\n");
- for (int i = 0; i < size; i++) {
- if (i > 0) {
- _writer.print(separator);
- if (newLineSeparator) {
- _indent();
- }
- }
- AstNode node = nodes[i];
- if (node is Statement) {
- _printLeadingComments(node);
- }
- node.accept(this);
- }
- // suffix
- _writer.print(suffix);
- }
- }
- }
-
- /**
- * Safely visit the given node, printing the prefix before the node if it is non-<code>null</code>
- * .
- *
- * @param prefix the prefix to be printed if there is a node to visit
- * @param node the node to be visited
- */
- void _visitNodeWithPrefix(String prefix, AstNode node) {
- if (node != null) {
- _writer.print(prefix);
- node.accept(this);
- }
- }
-
- /**
- * Safely visit the given node, printing the suffix after the node if it is non-<code>null</code>.
- *
- * @param suffix the suffix to be printed if there is a node to visit
- * @param node the node to be visited
- */
- void _visitNodeWithSuffix(AstNode node, String suffix) {
- if (node != null) {
- node.accept(this);
- _writer.print(suffix);
- }
- }
-
- /**
- * Print a list of tokens, separated by the given separator.
- *
- * @param tokens the tokens to be printed
- * @param separator the separator to be printed between adjacent tokens
- */
- void _visitTokenListWithSeparator(List<Token> tokens, String separator) {
- int size = tokens.length;
- for (int i = 0; i < size; i++) {
- if ("\n" == separator) {
- _writer.print("\n");
- _indent();
- } else if (i > 0) {
- _writer.print(separator);
- }
- _writer.print(tokens[i].lexeme);
- }
- }
-
- /**
- * Safely visit the given node, printing the suffix after the node if it is non-<code>null</code>.
- *
- * @param suffix the suffix to be printed if there is a node to visit
- * @param node the node to be visited
- */
- void _visitTokenWithSuffix(Token token, String suffix) {
- if (token != null) {
- _writer.print(token.lexeme);
- _writer.print(suffix);
- }
- }
-}
Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline> {
'parseCompilationUnit_1': new MethodTrampoline(1, (Parser target, arg0) => target.parseCompilationUnit(arg0)),
'parseExpression_1': new MethodTrampoline(1, (Parser target, arg0) => target.parseExpression(arg0)),
« 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