OLD | NEW |
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 analyzer.test.dart.element.builder_test; | 5 library analyzer.test.dart.element.builder_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 | 1140 |
1141 List<FunctionElement> functions = holder.functions; | 1141 List<FunctionElement> functions = holder.functions; |
1142 main.encloseElements(functions); | 1142 main.encloseElements(functions); |
1143 | 1143 |
1144 FunctionElement f = findElementsByName(unit, 'f').single; | 1144 FunctionElement f = findElementsByName(unit, 'f').single; |
1145 expect(f.parameters, hasLength(1)); | 1145 expect(f.parameters, hasLength(1)); |
1146 expect(f.parameters[0].initializer, isNotNull); | 1146 expect(f.parameters[0].initializer, isNotNull); |
1147 } | 1147 } |
1148 | 1148 |
1149 void test_visitFieldFormalParameter() { | 1149 void test_visitFieldFormalParameter() { |
1150 CompilationUnit unit = parseCompilationUnit( | 1150 CompilationUnit unit = parseCompilationUnit(r''' |
1151 r''' | |
1152 main() { | 1151 main() { |
1153 f(a, this.b) {} | 1152 f(a, this.b) {} |
1154 } | 1153 } |
1155 ''', | 1154 ''', [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); |
1156 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | |
1157 var main = unit.declarations[0] as FunctionDeclaration; | 1155 var main = unit.declarations[0] as FunctionDeclaration; |
1158 var mainBody = main.functionExpression.body as BlockFunctionBody; | 1156 var mainBody = main.functionExpression.body as BlockFunctionBody; |
1159 var mainBlock = mainBody.block; | 1157 var mainBlock = mainBody.block; |
1160 var statement = mainBlock.statements[0] as FunctionDeclarationStatement; | 1158 var statement = mainBlock.statements[0] as FunctionDeclarationStatement; |
1161 FunctionDeclaration f = statement.functionDeclaration; | 1159 FunctionDeclaration f = statement.functionDeclaration; |
1162 | 1160 |
1163 // Build API elements. | 1161 // Build API elements. |
1164 { | 1162 { |
1165 ElementHolder holder = new ElementHolder(); | 1163 ElementHolder holder = new ElementHolder(); |
1166 unit.accept(new ApiElementBuilder(holder, compilationUnitElement)); | 1164 unit.accept(new ApiElementBuilder(holder, compilationUnitElement)); |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2637 AnalysisEngine.instance.logger = logger; | 2635 AnalysisEngine.instance.logger = logger; |
2638 try { | 2636 try { |
2639 _compilationUnit = parseCompilationUnit(code); | 2637 _compilationUnit = parseCompilationUnit(code); |
2640 compilationUnit.accept(visitor); | 2638 compilationUnit.accept(visitor); |
2641 } finally { | 2639 } finally { |
2642 expect(logger.log, hasLength(0)); | 2640 expect(logger.log, hasLength(0)); |
2643 AnalysisEngine.instance.logger = Logger.NULL; | 2641 AnalysisEngine.instance.logger = Logger.NULL; |
2644 } | 2642 } |
2645 } | 2643 } |
2646 } | 2644 } |
OLD | NEW |