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

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

Issue 1480433002: Add support for assert statements with messages to the analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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 library engine.testing.ast_factory; 5 library engine.testing.ast_factory;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
10 import 'package:analyzer/src/generated/testing/token_factory.dart'; 10 import 'package:analyzer/src/generated/testing/token_factory.dart';
(...skipping 28 matching lines...) Expand all
39 arguments); 39 arguments);
40 40
41 static ArgumentList argumentList([List<Expression> arguments]) => 41 static ArgumentList argumentList([List<Expression> arguments]) =>
42 new ArgumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 42 new ArgumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
43 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); 43 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
44 44
45 static AsExpression asExpression(Expression expression, TypeName type) => 45 static AsExpression asExpression(Expression expression, TypeName type) =>
46 new AsExpression( 46 new AsExpression(
47 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type); 47 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type);
48 48
49 static AssertStatement assertStatement(Expression condition) => 49 static AssertStatement assertStatement(Expression condition,
50 [Expression message]) =>
50 new AssertStatement( 51 new AssertStatement(
51 TokenFactory.tokenFromKeyword(Keyword.ASSERT), 52 TokenFactory.tokenFromKeyword(Keyword.ASSERT),
52 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 53 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
53 condition, 54 condition,
55 message == null ? null : TokenFactory.tokenFromType(TokenType.COMMA),
56 message,
54 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 57 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
55 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 58 TokenFactory.tokenFromType(TokenType.SEMICOLON));
56 59
57 static AssignmentExpression assignmentExpression(Expression leftHandSide, 60 static AssignmentExpression assignmentExpression(Expression leftHandSide,
58 TokenType operator, Expression rightHandSide) => 61 TokenType operator, Expression rightHandSide) =>
59 new AssignmentExpression( 62 new AssignmentExpression(
60 leftHandSide, TokenFactory.tokenFromType(operator), rightHandSide); 63 leftHandSide, TokenFactory.tokenFromType(operator), rightHandSide);
61 64
62 static BlockFunctionBody asyncBlockFunctionBody( 65 static BlockFunctionBody asyncBlockFunctionBody(
63 [List<Statement> statements]) => 66 [List<Statement> statements]) =>
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 expression, 1254 expression,
1252 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1255 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1253 1256
1254 static YieldStatement yieldStatement(Expression expression) => 1257 static YieldStatement yieldStatement(Expression expression) =>
1255 new YieldStatement( 1258 new YieldStatement(
1256 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), 1259 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"),
1257 null, 1260 null,
1258 expression, 1261 expression,
1259 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1262 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1260 } 1263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698