| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.generated.element_resolver_test; | 5 library analyzer.test.generated.element_resolver_test; |
| 6 | 6 |
| 7 import 'dart:async'; |
| 8 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 11 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 12 import 'package:analyzer/dart/ast/token.dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; | 14 import 'package:analyzer/dart/element/type.dart'; |
| 13 import 'package:analyzer/file_system/memory_file_system.dart'; | 15 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 14 import 'package:analyzer/src/dart/element/element.dart'; | 16 import 'package:analyzer/src/dart/element/element.dart'; |
| 15 import 'package:analyzer/src/generated/element_resolver.dart'; | 17 import 'package:analyzer/src/generated/element_resolver.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/resolver.dart'; | 19 import 'package:analyzer/src/generated/resolver.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 20 import 'package:analyzer/src/generated/source.dart'; |
| 19 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 21 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
| 20 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 22 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 21 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 23 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 22 import 'package:analyzer/src/source/source_resource.dart'; | 24 import 'package:analyzer/src/source/source_resource.dart'; |
| 23 import 'package:test/test.dart'; | 25 import 'package:test/test.dart'; |
| 24 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 26 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 25 | 27 |
| 26 import 'analysis_context_factory.dart'; | 28 import 'analysis_context_factory.dart'; |
| 27 import 'resolver_test_case.dart'; | 29 import 'resolver_test_case.dart'; |
| 28 import 'test_support.dart'; | 30 import 'test_support.dart'; |
| 29 | 31 |
| 30 main() { | 32 main() { |
| 31 defineReflectiveSuite(() { | 33 defineReflectiveSuite(() { |
| 32 defineReflectiveTests(ElementResolverCodeTest); | 34 defineReflectiveTests(ElementResolverCodeTest); |
| 33 defineReflectiveTests(ElementResolverTest); | 35 defineReflectiveTests(ElementResolverTest); |
| 34 }); | 36 }); |
| 35 } | 37 } |
| 36 | 38 |
| 37 @reflectiveTest | 39 @reflectiveTest |
| 38 class ElementResolverCodeTest extends ResolverTestCase { | 40 class ElementResolverCodeTest extends ResolverTestCase { |
| 39 void test_annotation_class_namedConstructor() { | 41 test_annotation_class_namedConstructor() async { |
| 40 addNamedSource( | 42 addNamedSource( |
| 41 '/a.dart', | 43 '/a.dart', |
| 42 r''' | 44 r''' |
| 43 class A { | 45 class A { |
| 44 const A.named(); | 46 const A.named(); |
| 45 } | 47 } |
| 46 '''); | 48 '''); |
| 47 _validateAnnotation('', '@A.named()', (SimpleIdentifier name1, | 49 await _validateAnnotation('', '@A.named()', (SimpleIdentifier name1, |
| 48 SimpleIdentifier name2, | 50 SimpleIdentifier name2, |
| 49 SimpleIdentifier name3, | 51 SimpleIdentifier name3, |
| 50 Element annotationElement) { | 52 Element annotationElement) { |
| 51 expect(name1, isNotNull); | 53 expect(name1, isNotNull); |
| 52 expect(name1.staticElement, new isInstanceOf<ClassElement>()); | 54 expect(name1.staticElement, new isInstanceOf<ClassElement>()); |
| 53 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); | 55 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); |
| 54 expect(name2, isNotNull); | 56 expect(name2, isNotNull); |
| 55 expect(name2.staticElement, new isInstanceOf<ConstructorElement>()); | 57 expect(name2.staticElement, new isInstanceOf<ConstructorElement>()); |
| 56 expect( | 58 expect( |
| 57 resolutionMap.staticElementForIdentifier(name2).displayName, 'named'); | 59 resolutionMap.staticElementForIdentifier(name2).displayName, 'named'); |
| 58 expect(name3, isNull); | 60 expect(name3, isNull); |
| 59 if (annotationElement is ConstructorElement) { | 61 if (annotationElement is ConstructorElement) { |
| 60 expect(annotationElement, same(name2.staticElement)); | 62 expect(annotationElement, same(name2.staticElement)); |
| 61 expect(annotationElement.enclosingElement, name1.staticElement); | 63 expect(annotationElement.enclosingElement, name1.staticElement); |
| 62 expect(annotationElement.displayName, 'named'); | 64 expect(annotationElement.displayName, 'named'); |
| 63 expect(annotationElement.parameters, isEmpty); | 65 expect(annotationElement.parameters, isEmpty); |
| 64 } else { | 66 } else { |
| 65 fail('Expected "annotationElement" is ConstructorElement, ' | 67 fail('Expected "annotationElement" is ConstructorElement, ' |
| 66 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 68 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 67 } | 69 } |
| 68 }); | 70 }); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void test_annotation_class_prefixed_namedConstructor() { | 73 test_annotation_class_prefixed_namedConstructor() async { |
| 72 addNamedSource( | 74 addNamedSource( |
| 73 '/a.dart', | 75 '/a.dart', |
| 74 r''' | 76 r''' |
| 75 class A { | 77 class A { |
| 76 const A.named(); | 78 const A.named(); |
| 77 } | 79 } |
| 78 '''); | 80 '''); |
| 79 _validateAnnotation('as p', '@p.A.named()', (SimpleIdentifier name1, | 81 await _validateAnnotation('as p', '@p.A.named()', (SimpleIdentifier name1, |
| 80 SimpleIdentifier name2, | 82 SimpleIdentifier name2, |
| 81 SimpleIdentifier name3, | 83 SimpleIdentifier name3, |
| 82 Element annotationElement) { | 84 Element annotationElement) { |
| 83 expect(name1, isNotNull); | 85 expect(name1, isNotNull); |
| 84 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); | 86 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); |
| 85 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); | 87 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); |
| 86 expect(name2, isNotNull); | 88 expect(name2, isNotNull); |
| 87 expect(name2.staticElement, new isInstanceOf<ClassElement>()); | 89 expect(name2.staticElement, new isInstanceOf<ClassElement>()); |
| 88 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); | 90 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); |
| 89 expect(name3, isNotNull); | 91 expect(name3, isNotNull); |
| 90 expect(name3.staticElement, new isInstanceOf<ConstructorElement>()); | 92 expect(name3.staticElement, new isInstanceOf<ConstructorElement>()); |
| 91 expect( | 93 expect( |
| 92 resolutionMap.staticElementForIdentifier(name3).displayName, 'named'); | 94 resolutionMap.staticElementForIdentifier(name3).displayName, 'named'); |
| 93 if (annotationElement is ConstructorElement) { | 95 if (annotationElement is ConstructorElement) { |
| 94 expect(annotationElement, same(name3.staticElement)); | 96 expect(annotationElement, same(name3.staticElement)); |
| 95 expect(annotationElement.enclosingElement, name2.staticElement); | 97 expect(annotationElement.enclosingElement, name2.staticElement); |
| 96 expect(annotationElement.displayName, 'named'); | 98 expect(annotationElement.displayName, 'named'); |
| 97 expect(annotationElement.parameters, isEmpty); | 99 expect(annotationElement.parameters, isEmpty); |
| 98 } else { | 100 } else { |
| 99 fail('Expected "annotationElement" is ConstructorElement, ' | 101 fail('Expected "annotationElement" is ConstructorElement, ' |
| 100 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 102 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 101 } | 103 } |
| 102 }); | 104 }); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void test_annotation_class_prefixed_staticConstField() { | 107 test_annotation_class_prefixed_staticConstField() async { |
| 106 addNamedSource( | 108 addNamedSource( |
| 107 '/a.dart', | 109 '/a.dart', |
| 108 r''' | 110 r''' |
| 109 class A { | 111 class A { |
| 110 static const V = 0; | 112 static const V = 0; |
| 111 } | 113 } |
| 112 '''); | 114 '''); |
| 113 _validateAnnotation('as p', '@p.A.V', (SimpleIdentifier name1, | 115 await _validateAnnotation('as p', '@p.A.V', (SimpleIdentifier name1, |
| 114 SimpleIdentifier name2, | 116 SimpleIdentifier name2, |
| 115 SimpleIdentifier name3, | 117 SimpleIdentifier name3, |
| 116 Element annotationElement) { | 118 Element annotationElement) { |
| 117 expect(name1, isNotNull); | 119 expect(name1, isNotNull); |
| 118 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); | 120 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); |
| 119 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); | 121 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); |
| 120 expect(name2, isNotNull); | 122 expect(name2, isNotNull); |
| 121 expect(name2.staticElement, new isInstanceOf<ClassElement>()); | 123 expect(name2.staticElement, new isInstanceOf<ClassElement>()); |
| 122 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); | 124 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); |
| 123 expect(name3, isNotNull); | 125 expect(name3, isNotNull); |
| 124 expect(name3.staticElement, new isInstanceOf<PropertyAccessorElement>()); | 126 expect(name3.staticElement, new isInstanceOf<PropertyAccessorElement>()); |
| 125 expect(resolutionMap.staticElementForIdentifier(name3).displayName, 'V'); | 127 expect(resolutionMap.staticElementForIdentifier(name3).displayName, 'V'); |
| 126 if (annotationElement is PropertyAccessorElement) { | 128 if (annotationElement is PropertyAccessorElement) { |
| 127 expect(annotationElement, same(name3.staticElement)); | 129 expect(annotationElement, same(name3.staticElement)); |
| 128 expect(annotationElement.enclosingElement, name2.staticElement); | 130 expect(annotationElement.enclosingElement, name2.staticElement); |
| 129 expect(annotationElement.displayName, 'V'); | 131 expect(annotationElement.displayName, 'V'); |
| 130 } else { | 132 } else { |
| 131 fail('Expected "annotationElement" is PropertyAccessorElement, ' | 133 fail('Expected "annotationElement" is PropertyAccessorElement, ' |
| 132 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 134 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 133 } | 135 } |
| 134 }); | 136 }); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void test_annotation_class_prefixed_unnamedConstructor() { | 139 test_annotation_class_prefixed_unnamedConstructor() async { |
| 138 addNamedSource( | 140 addNamedSource( |
| 139 '/a.dart', | 141 '/a.dart', |
| 140 r''' | 142 r''' |
| 141 class A { | 143 class A { |
| 142 const A(); | 144 const A(); |
| 143 } | 145 } |
| 144 '''); | 146 '''); |
| 145 _validateAnnotation('as p', '@p.A', (SimpleIdentifier name1, | 147 await _validateAnnotation('as p', '@p.A', (SimpleIdentifier name1, |
| 146 SimpleIdentifier name2, | 148 SimpleIdentifier name2, |
| 147 SimpleIdentifier name3, | 149 SimpleIdentifier name3, |
| 148 Element annotationElement) { | 150 Element annotationElement) { |
| 149 expect(name1, isNotNull); | 151 expect(name1, isNotNull); |
| 150 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); | 152 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); |
| 151 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); | 153 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); |
| 152 expect(name2, isNotNull); | 154 expect(name2, isNotNull); |
| 153 expect(name2.staticElement, new isInstanceOf<ClassElement>()); | 155 expect(name2.staticElement, new isInstanceOf<ClassElement>()); |
| 154 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); | 156 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'A'); |
| 155 expect(name3, isNull); | 157 expect(name3, isNull); |
| 156 if (annotationElement is ConstructorElement) { | 158 if (annotationElement is ConstructorElement) { |
| 157 expect(annotationElement.enclosingElement, name2.staticElement); | 159 expect(annotationElement.enclosingElement, name2.staticElement); |
| 158 expect(annotationElement.displayName, ''); | 160 expect(annotationElement.displayName, ''); |
| 159 expect(annotationElement.parameters, isEmpty); | 161 expect(annotationElement.parameters, isEmpty); |
| 160 } else { | 162 } else { |
| 161 fail('Expected "annotationElement" is ConstructorElement, ' | 163 fail('Expected "annotationElement" is ConstructorElement, ' |
| 162 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 164 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 163 } | 165 } |
| 164 }); | 166 }); |
| 165 } | 167 } |
| 166 | 168 |
| 167 void test_annotation_class_staticConstField() { | 169 test_annotation_class_staticConstField() async { |
| 168 addNamedSource( | 170 addNamedSource( |
| 169 '/a.dart', | 171 '/a.dart', |
| 170 r''' | 172 r''' |
| 171 class A { | 173 class A { |
| 172 static const V = 0; | 174 static const V = 0; |
| 173 } | 175 } |
| 174 '''); | 176 '''); |
| 175 _validateAnnotation('', '@A.V', (SimpleIdentifier name1, | 177 await _validateAnnotation('', '@A.V', (SimpleIdentifier name1, |
| 176 SimpleIdentifier name2, | 178 SimpleIdentifier name2, |
| 177 SimpleIdentifier name3, | 179 SimpleIdentifier name3, |
| 178 Element annotationElement) { | 180 Element annotationElement) { |
| 179 expect(name1, isNotNull); | 181 expect(name1, isNotNull); |
| 180 expect(name1.staticElement, new isInstanceOf<ClassElement>()); | 182 expect(name1.staticElement, new isInstanceOf<ClassElement>()); |
| 181 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); | 183 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); |
| 182 expect(name2, isNotNull); | 184 expect(name2, isNotNull); |
| 183 expect(name2.staticElement, new isInstanceOf<PropertyAccessorElement>()); | 185 expect(name2.staticElement, new isInstanceOf<PropertyAccessorElement>()); |
| 184 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'V'); | 186 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'V'); |
| 185 expect(name3, isNull); | 187 expect(name3, isNull); |
| 186 if (annotationElement is PropertyAccessorElement) { | 188 if (annotationElement is PropertyAccessorElement) { |
| 187 expect(annotationElement, same(name2.staticElement)); | 189 expect(annotationElement, same(name2.staticElement)); |
| 188 expect(annotationElement.enclosingElement, name1.staticElement); | 190 expect(annotationElement.enclosingElement, name1.staticElement); |
| 189 expect(annotationElement.displayName, 'V'); | 191 expect(annotationElement.displayName, 'V'); |
| 190 } else { | 192 } else { |
| 191 fail('Expected "annotationElement" is PropertyAccessorElement, ' | 193 fail('Expected "annotationElement" is PropertyAccessorElement, ' |
| 192 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 194 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 193 } | 195 } |
| 194 }); | 196 }); |
| 195 } | 197 } |
| 196 | 198 |
| 197 void test_annotation_class_unnamedConstructor() { | 199 test_annotation_class_unnamedConstructor() async { |
| 198 addNamedSource( | 200 addNamedSource( |
| 199 '/a.dart', | 201 '/a.dart', |
| 200 r''' | 202 r''' |
| 201 class A { | 203 class A { |
| 202 const A(); | 204 const A(); |
| 203 } | 205 } |
| 204 '''); | 206 '''); |
| 205 _validateAnnotation('', '@A', (SimpleIdentifier name1, | 207 await _validateAnnotation('', '@A', (SimpleIdentifier name1, |
| 206 SimpleIdentifier name2, | 208 SimpleIdentifier name2, |
| 207 SimpleIdentifier name3, | 209 SimpleIdentifier name3, |
| 208 Element annotationElement) { | 210 Element annotationElement) { |
| 209 expect(name1, isNotNull); | 211 expect(name1, isNotNull); |
| 210 expect(name1.staticElement, new isInstanceOf<ClassElement>()); | 212 expect(name1.staticElement, new isInstanceOf<ClassElement>()); |
| 211 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); | 213 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'A'); |
| 212 expect(name2, isNull); | 214 expect(name2, isNull); |
| 213 expect(name3, isNull); | 215 expect(name3, isNull); |
| 214 if (annotationElement is ConstructorElement) { | 216 if (annotationElement is ConstructorElement) { |
| 215 expect(annotationElement.enclosingElement, name1.staticElement); | 217 expect(annotationElement.enclosingElement, name1.staticElement); |
| 216 expect(annotationElement.displayName, ''); | 218 expect(annotationElement.displayName, ''); |
| 217 expect(annotationElement.parameters, isEmpty); | 219 expect(annotationElement.parameters, isEmpty); |
| 218 } else { | 220 } else { |
| 219 fail('Expected "annotationElement" is ConstructorElement, ' | 221 fail('Expected "annotationElement" is ConstructorElement, ' |
| 220 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 222 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 221 } | 223 } |
| 222 }); | 224 }); |
| 223 } | 225 } |
| 224 | 226 |
| 225 void test_annotation_topLevelVariable() { | 227 test_annotation_topLevelVariable() async { |
| 226 addNamedSource( | 228 addNamedSource( |
| 227 '/a.dart', | 229 '/a.dart', |
| 228 r''' | 230 r''' |
| 229 const V = 0; | 231 const V = 0; |
| 230 '''); | 232 '''); |
| 231 _validateAnnotation('', '@V', (SimpleIdentifier name1, | 233 await _validateAnnotation('', '@V', (SimpleIdentifier name1, |
| 232 SimpleIdentifier name2, | 234 SimpleIdentifier name2, |
| 233 SimpleIdentifier name3, | 235 SimpleIdentifier name3, |
| 234 Element annotationElement) { | 236 Element annotationElement) { |
| 235 expect(name1, isNotNull); | 237 expect(name1, isNotNull); |
| 236 expect(name1.staticElement, new isInstanceOf<PropertyAccessorElement>()); | 238 expect(name1.staticElement, new isInstanceOf<PropertyAccessorElement>()); |
| 237 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'V'); | 239 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'V'); |
| 238 expect(name2, isNull); | 240 expect(name2, isNull); |
| 239 expect(name3, isNull); | 241 expect(name3, isNull); |
| 240 if (annotationElement is PropertyAccessorElement) { | 242 if (annotationElement is PropertyAccessorElement) { |
| 241 expect(annotationElement, same(name1.staticElement)); | 243 expect(annotationElement, same(name1.staticElement)); |
| 242 expect(annotationElement.enclosingElement, | 244 expect(annotationElement.enclosingElement, |
| 243 new isInstanceOf<CompilationUnitElement>()); | 245 new isInstanceOf<CompilationUnitElement>()); |
| 244 expect(annotationElement.displayName, 'V'); | 246 expect(annotationElement.displayName, 'V'); |
| 245 } else { | 247 } else { |
| 246 fail('Expected "annotationElement" is PropertyAccessorElement, ' | 248 fail('Expected "annotationElement" is PropertyAccessorElement, ' |
| 247 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 249 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 248 } | 250 } |
| 249 }); | 251 }); |
| 250 } | 252 } |
| 251 | 253 |
| 252 void test_annotation_topLevelVariable_prefixed() { | 254 test_annotation_topLevelVariable_prefixed() async { |
| 253 addNamedSource( | 255 addNamedSource( |
| 254 '/a.dart', | 256 '/a.dart', |
| 255 r''' | 257 r''' |
| 256 const V = 0; | 258 const V = 0; |
| 257 '''); | 259 '''); |
| 258 _validateAnnotation('as p', '@p.V', (SimpleIdentifier name1, | 260 await _validateAnnotation('as p', '@p.V', (SimpleIdentifier name1, |
| 259 SimpleIdentifier name2, | 261 SimpleIdentifier name2, |
| 260 SimpleIdentifier name3, | 262 SimpleIdentifier name3, |
| 261 Element annotationElement) { | 263 Element annotationElement) { |
| 262 expect(name1, isNotNull); | 264 expect(name1, isNotNull); |
| 263 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); | 265 expect(name1.staticElement, new isInstanceOf<PrefixElement>()); |
| 264 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); | 266 expect(resolutionMap.staticElementForIdentifier(name1).displayName, 'p'); |
| 265 expect(name2, isNotNull); | 267 expect(name2, isNotNull); |
| 266 expect(name2.staticElement, new isInstanceOf<PropertyAccessorElement>()); | 268 expect(name2.staticElement, new isInstanceOf<PropertyAccessorElement>()); |
| 267 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'V'); | 269 expect(resolutionMap.staticElementForIdentifier(name2).displayName, 'V'); |
| 268 expect(name3, isNull); | 270 expect(name3, isNull); |
| 269 if (annotationElement is PropertyAccessorElement) { | 271 if (annotationElement is PropertyAccessorElement) { |
| 270 expect(annotationElement, same(name2.staticElement)); | 272 expect(annotationElement, same(name2.staticElement)); |
| 271 expect(annotationElement.enclosingElement, | 273 expect(annotationElement.enclosingElement, |
| 272 new isInstanceOf<CompilationUnitElement>()); | 274 new isInstanceOf<CompilationUnitElement>()); |
| 273 expect(annotationElement.displayName, 'V'); | 275 expect(annotationElement.displayName, 'V'); |
| 274 } else { | 276 } else { |
| 275 fail('Expected "annotationElement" is PropertyAccessorElement, ' | 277 fail('Expected "annotationElement" is PropertyAccessorElement, ' |
| 276 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; | 278 'but (${annotationElement?.runtimeType}) $annotationElement found.')
; |
| 277 } | 279 } |
| 278 }); | 280 }); |
| 279 } | 281 } |
| 280 | 282 |
| 281 void _validateAnnotation( | 283 Future<Null> _validateAnnotation( |
| 282 String annotationPrefix, | 284 String annotationPrefix, |
| 283 String annotationText, | 285 String annotationText, |
| 284 validator(SimpleIdentifier name1, SimpleIdentifier name2, | 286 validator(SimpleIdentifier name1, SimpleIdentifier name2, |
| 285 SimpleIdentifier name3, Element annotationElement)) { | 287 SimpleIdentifier name3, Element annotationElement)) async { |
| 286 CompilationUnit unit = resolveSource(''' | 288 CompilationUnit unit = await resolveSource(''' |
| 287 import 'a.dart' $annotationPrefix; | 289 import 'a.dart' $annotationPrefix; |
| 288 $annotationText | 290 $annotationText |
| 289 class C {} | 291 class C {} |
| 290 '''); | 292 '''); |
| 291 var clazz = unit.declarations.single as ClassDeclaration; | 293 var clazz = unit.declarations.single as ClassDeclaration; |
| 292 Annotation annotation = clazz.metadata.single; | 294 Annotation annotation = clazz.metadata.single; |
| 293 Identifier name = annotation.name; | 295 Identifier name = annotation.name; |
| 294 Element annotationElement = annotation.element; | 296 Element annotationElement = annotation.element; |
| 295 if (name is SimpleIdentifier) { | 297 if (name is SimpleIdentifier) { |
| 296 validator(name, null, annotation.constructorName, annotationElement); | 298 validator(name, null, annotation.constructorName, annotationElement); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 382 } |
| 381 | 383 |
| 382 @override | 384 @override |
| 383 void setUp() { | 385 void setUp() { |
| 384 super.setUp(); | 386 super.setUp(); |
| 385 _listener = new GatheringErrorListener(); | 387 _listener = new GatheringErrorListener(); |
| 386 _typeProvider = new TestTypeProvider(); | 388 _typeProvider = new TestTypeProvider(); |
| 387 _resolver = _createResolver(); | 389 _resolver = _createResolver(); |
| 388 } | 390 } |
| 389 | 391 |
| 390 void test_lookUpMethodInInterfaces() { | 392 test_lookUpMethodInInterfaces() async { |
| 391 InterfaceType intType = _typeProvider.intType; | 393 InterfaceType intType = _typeProvider.intType; |
| 392 // | 394 // |
| 393 // abstract class A { int operator[](int index); } | 395 // abstract class A { int operator[](int index); } |
| 394 // | 396 // |
| 395 ClassElementImpl classA = ElementFactory.classElement2("A"); | 397 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 396 MethodElement operator = | 398 MethodElement operator = |
| 397 ElementFactory.methodElement("[]", intType, [intType]); | 399 ElementFactory.methodElement("[]", intType, [intType]); |
| 398 classA.methods = <MethodElement>[operator]; | 400 classA.methods = <MethodElement>[operator]; |
| 399 // | 401 // |
| 400 // class B implements A {} | 402 // class B implements A {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 415 // a[i]; | 417 // a[i]; |
| 416 // | 418 // |
| 417 SimpleIdentifier array = AstTestFactory.identifier3("a"); | 419 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
| 418 array.staticType = classD.type; | 420 array.staticType = classD.type; |
| 419 IndexExpression expression = | 421 IndexExpression expression = |
| 420 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); | 422 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
| 421 expect(_resolveIndexExpression(expression), same(operator)); | 423 expect(_resolveIndexExpression(expression), same(operator)); |
| 422 _listener.assertNoErrors(); | 424 _listener.assertNoErrors(); |
| 423 } | 425 } |
| 424 | 426 |
| 425 void test_visitAssignmentExpression_compound() { | 427 test_visitAssignmentExpression_compound() async { |
| 426 InterfaceType intType = _typeProvider.intType; | 428 InterfaceType intType = _typeProvider.intType; |
| 427 SimpleIdentifier leftHandSide = AstTestFactory.identifier3("a"); | 429 SimpleIdentifier leftHandSide = AstTestFactory.identifier3("a"); |
| 428 leftHandSide.staticType = intType; | 430 leftHandSide.staticType = intType; |
| 429 AssignmentExpression assignment = AstTestFactory.assignmentExpression( | 431 AssignmentExpression assignment = AstTestFactory.assignmentExpression( |
| 430 leftHandSide, TokenType.PLUS_EQ, AstTestFactory.integer(1)); | 432 leftHandSide, TokenType.PLUS_EQ, AstTestFactory.integer(1)); |
| 431 _resolveNode(assignment); | 433 _resolveNode(assignment); |
| 432 expect( | 434 expect( |
| 433 assignment.staticElement, same(getMethod(_typeProvider.numType, "+"))); | 435 assignment.staticElement, same(getMethod(_typeProvider.numType, "+"))); |
| 434 _listener.assertNoErrors(); | 436 _listener.assertNoErrors(); |
| 435 } | 437 } |
| 436 | 438 |
| 437 void test_visitAssignmentExpression_simple() { | 439 test_visitAssignmentExpression_simple() async { |
| 438 AssignmentExpression expression = AstTestFactory.assignmentExpression( | 440 AssignmentExpression expression = AstTestFactory.assignmentExpression( |
| 439 AstTestFactory.identifier3("x"), | 441 AstTestFactory.identifier3("x"), |
| 440 TokenType.EQ, | 442 TokenType.EQ, |
| 441 AstTestFactory.integer(0)); | 443 AstTestFactory.integer(0)); |
| 442 _resolveNode(expression); | 444 _resolveNode(expression); |
| 443 expect(expression.staticElement, isNull); | 445 expect(expression.staticElement, isNull); |
| 444 _listener.assertNoErrors(); | 446 _listener.assertNoErrors(); |
| 445 } | 447 } |
| 446 | 448 |
| 447 void test_visitBinaryExpression_bangEq() { | 449 test_visitBinaryExpression_bangEq() async { |
| 448 // String i; | 450 // String i; |
| 449 // var j; | 451 // var j; |
| 450 // i == j | 452 // i == j |
| 451 InterfaceType stringType = _typeProvider.stringType; | 453 InterfaceType stringType = _typeProvider.stringType; |
| 452 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 454 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 453 left.staticType = stringType; | 455 left.staticType = stringType; |
| 454 BinaryExpression expression = AstTestFactory.binaryExpression( | 456 BinaryExpression expression = AstTestFactory.binaryExpression( |
| 455 left, TokenType.BANG_EQ, AstTestFactory.identifier3("j")); | 457 left, TokenType.BANG_EQ, AstTestFactory.identifier3("j")); |
| 456 _resolveNode(expression); | 458 _resolveNode(expression); |
| 457 var stringElement = stringType.element; | 459 var stringElement = stringType.element; |
| 458 expect(expression.staticElement, isNotNull); | 460 expect(expression.staticElement, isNotNull); |
| 459 expect( | 461 expect( |
| 460 expression.staticElement, | 462 expression.staticElement, |
| 461 stringElement.lookUpMethod( | 463 stringElement.lookUpMethod( |
| 462 TokenType.EQ_EQ.lexeme, stringElement.library)); | 464 TokenType.EQ_EQ.lexeme, stringElement.library)); |
| 463 expect(expression.propagatedElement, isNull); | 465 expect(expression.propagatedElement, isNull); |
| 464 _listener.assertNoErrors(); | 466 _listener.assertNoErrors(); |
| 465 } | 467 } |
| 466 | 468 |
| 467 void test_visitBinaryExpression_eq() { | 469 test_visitBinaryExpression_eq() async { |
| 468 // String i; | 470 // String i; |
| 469 // var j; | 471 // var j; |
| 470 // i == j | 472 // i == j |
| 471 InterfaceType stringType = _typeProvider.stringType; | 473 InterfaceType stringType = _typeProvider.stringType; |
| 472 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 474 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 473 left.staticType = stringType; | 475 left.staticType = stringType; |
| 474 BinaryExpression expression = AstTestFactory.binaryExpression( | 476 BinaryExpression expression = AstTestFactory.binaryExpression( |
| 475 left, TokenType.EQ_EQ, AstTestFactory.identifier3("j")); | 477 left, TokenType.EQ_EQ, AstTestFactory.identifier3("j")); |
| 476 _resolveNode(expression); | 478 _resolveNode(expression); |
| 477 var stringElement = stringType.element; | 479 var stringElement = stringType.element; |
| 478 expect( | 480 expect( |
| 479 expression.staticElement, | 481 expression.staticElement, |
| 480 stringElement.lookUpMethod( | 482 stringElement.lookUpMethod( |
| 481 TokenType.EQ_EQ.lexeme, stringElement.library)); | 483 TokenType.EQ_EQ.lexeme, stringElement.library)); |
| 482 expect(expression.propagatedElement, isNull); | 484 expect(expression.propagatedElement, isNull); |
| 483 _listener.assertNoErrors(); | 485 _listener.assertNoErrors(); |
| 484 } | 486 } |
| 485 | 487 |
| 486 void test_visitBinaryExpression_plus() { | 488 test_visitBinaryExpression_plus() async { |
| 487 // num i; | 489 // num i; |
| 488 // var j; | 490 // var j; |
| 489 // i + j | 491 // i + j |
| 490 InterfaceType numType = _typeProvider.numType; | 492 InterfaceType numType = _typeProvider.numType; |
| 491 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 493 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 492 left.staticType = numType; | 494 left.staticType = numType; |
| 493 BinaryExpression expression = AstTestFactory.binaryExpression( | 495 BinaryExpression expression = AstTestFactory.binaryExpression( |
| 494 left, TokenType.PLUS, AstTestFactory.identifier3("j")); | 496 left, TokenType.PLUS, AstTestFactory.identifier3("j")); |
| 495 _resolveNode(expression); | 497 _resolveNode(expression); |
| 496 expect(expression.staticElement, getMethod(numType, "+")); | 498 expect(expression.staticElement, getMethod(numType, "+")); |
| 497 expect(expression.propagatedElement, isNull); | 499 expect(expression.propagatedElement, isNull); |
| 498 _listener.assertNoErrors(); | 500 _listener.assertNoErrors(); |
| 499 } | 501 } |
| 500 | 502 |
| 501 void test_visitBinaryExpression_plus_propagatedElement() { | 503 test_visitBinaryExpression_plus_propagatedElement() async { |
| 502 // var i = 1; | 504 // var i = 1; |
| 503 // var j; | 505 // var j; |
| 504 // i + j | 506 // i + j |
| 505 InterfaceType numType = _typeProvider.numType; | 507 InterfaceType numType = _typeProvider.numType; |
| 506 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 508 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 507 left.propagatedType = numType; | 509 left.propagatedType = numType; |
| 508 BinaryExpression expression = AstTestFactory.binaryExpression( | 510 BinaryExpression expression = AstTestFactory.binaryExpression( |
| 509 left, TokenType.PLUS, AstTestFactory.identifier3("j")); | 511 left, TokenType.PLUS, AstTestFactory.identifier3("j")); |
| 510 _resolveNode(expression); | 512 _resolveNode(expression); |
| 511 expect(expression.staticElement, isNull); | 513 expect(expression.staticElement, isNull); |
| 512 expect(expression.propagatedElement, getMethod(numType, "+")); | 514 expect(expression.propagatedElement, getMethod(numType, "+")); |
| 513 _listener.assertNoErrors(); | 515 _listener.assertNoErrors(); |
| 514 } | 516 } |
| 515 | 517 |
| 516 void test_visitBreakStatement_withLabel() { | 518 test_visitBreakStatement_withLabel() async { |
| 517 // loop: while (true) { | 519 // loop: while (true) { |
| 518 // break loop; | 520 // break loop; |
| 519 // } | 521 // } |
| 520 String label = "loop"; | 522 String label = "loop"; |
| 521 LabelElementImpl labelElement = new LabelElementImpl.forNode( | 523 LabelElementImpl labelElement = new LabelElementImpl.forNode( |
| 522 AstTestFactory.identifier3(label), false, false); | 524 AstTestFactory.identifier3(label), false, false); |
| 523 BreakStatement breakStatement = AstTestFactory.breakStatement2(label); | 525 BreakStatement breakStatement = AstTestFactory.breakStatement2(label); |
| 524 Expression condition = AstTestFactory.booleanLiteral(true); | 526 Expression condition = AstTestFactory.booleanLiteral(true); |
| 525 WhileStatement whileStatement = | 527 WhileStatement whileStatement = |
| 526 AstTestFactory.whileStatement(condition, breakStatement); | 528 AstTestFactory.whileStatement(condition, breakStatement); |
| 527 expect(_resolveBreak(breakStatement, labelElement, whileStatement), | 529 expect(_resolveBreak(breakStatement, labelElement, whileStatement), |
| 528 same(labelElement)); | 530 same(labelElement)); |
| 529 expect(breakStatement.target, same(whileStatement)); | 531 expect(breakStatement.target, same(whileStatement)); |
| 530 _listener.assertNoErrors(); | 532 _listener.assertNoErrors(); |
| 531 } | 533 } |
| 532 | 534 |
| 533 void test_visitBreakStatement_withoutLabel() { | 535 test_visitBreakStatement_withoutLabel() async { |
| 534 BreakStatement statement = AstTestFactory.breakStatement(); | 536 BreakStatement statement = AstTestFactory.breakStatement(); |
| 535 _resolveStatement(statement, null, null); | 537 _resolveStatement(statement, null, null); |
| 536 _listener.assertNoErrors(); | 538 _listener.assertNoErrors(); |
| 537 } | 539 } |
| 538 | 540 |
| 539 void test_visitCommentReference_prefixedIdentifier_class_getter() { | 541 test_visitCommentReference_prefixedIdentifier_class_getter() async { |
| 540 ClassElementImpl classA = ElementFactory.classElement2("A"); | 542 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 541 // set accessors | 543 // set accessors |
| 542 String propName = "p"; | 544 String propName = "p"; |
| 543 PropertyAccessorElement getter = | 545 PropertyAccessorElement getter = |
| 544 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 546 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
| 545 PropertyAccessorElement setter = | 547 PropertyAccessorElement setter = |
| 546 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 548 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
| 547 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 549 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
| 548 // set name scope | 550 // set name scope |
| 549 _visitor.nameScope = new EnclosedScope(null) | 551 _visitor.nameScope = new EnclosedScope(null) |
| 550 ..defineNameWithoutChecking('A', classA); | 552 ..defineNameWithoutChecking('A', classA); |
| 551 // prepare "A.p" | 553 // prepare "A.p" |
| 552 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p'); | 554 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p'); |
| 553 CommentReference commentReference = | 555 CommentReference commentReference = |
| 554 astFactory.commentReference(null, prefixed); | 556 astFactory.commentReference(null, prefixed); |
| 555 // resolve | 557 // resolve |
| 556 _resolveNode(commentReference); | 558 _resolveNode(commentReference); |
| 557 expect(prefixed.prefix.staticElement, classA); | 559 expect(prefixed.prefix.staticElement, classA); |
| 558 expect(prefixed.identifier.staticElement, getter); | 560 expect(prefixed.identifier.staticElement, getter); |
| 559 _listener.assertNoErrors(); | 561 _listener.assertNoErrors(); |
| 560 } | 562 } |
| 561 | 563 |
| 562 void test_visitCommentReference_prefixedIdentifier_class_method() { | 564 test_visitCommentReference_prefixedIdentifier_class_method() async { |
| 563 ClassElementImpl classA = ElementFactory.classElement2("A"); | 565 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 564 // set method | 566 // set method |
| 565 MethodElement method = | 567 MethodElement method = |
| 566 ElementFactory.methodElement("m", _typeProvider.intType); | 568 ElementFactory.methodElement("m", _typeProvider.intType); |
| 567 classA.methods = <MethodElement>[method]; | 569 classA.methods = <MethodElement>[method]; |
| 568 // set name scope | 570 // set name scope |
| 569 _visitor.nameScope = new EnclosedScope(null) | 571 _visitor.nameScope = new EnclosedScope(null) |
| 570 ..defineNameWithoutChecking('A', classA); | 572 ..defineNameWithoutChecking('A', classA); |
| 571 // prepare "A.m" | 573 // prepare "A.m" |
| 572 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm'); | 574 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm'); |
| 573 CommentReference commentReference = | 575 CommentReference commentReference = |
| 574 astFactory.commentReference(null, prefixed); | 576 astFactory.commentReference(null, prefixed); |
| 575 // resolve | 577 // resolve |
| 576 _resolveNode(commentReference); | 578 _resolveNode(commentReference); |
| 577 expect(prefixed.prefix.staticElement, classA); | 579 expect(prefixed.prefix.staticElement, classA); |
| 578 expect(prefixed.identifier.staticElement, method); | 580 expect(prefixed.identifier.staticElement, method); |
| 579 _listener.assertNoErrors(); | 581 _listener.assertNoErrors(); |
| 580 } | 582 } |
| 581 | 583 |
| 582 void test_visitCommentReference_prefixedIdentifier_class_operator() { | 584 test_visitCommentReference_prefixedIdentifier_class_operator() async { |
| 583 ClassElementImpl classA = ElementFactory.classElement2("A"); | 585 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 584 // set method | 586 // set method |
| 585 MethodElement method = | 587 MethodElement method = |
| 586 ElementFactory.methodElement("==", _typeProvider.boolType); | 588 ElementFactory.methodElement("==", _typeProvider.boolType); |
| 587 classA.methods = <MethodElement>[method]; | 589 classA.methods = <MethodElement>[method]; |
| 588 // set name scope | 590 // set name scope |
| 589 _visitor.nameScope = new EnclosedScope(null) | 591 _visitor.nameScope = new EnclosedScope(null) |
| 590 ..defineNameWithoutChecking('A', classA); | 592 ..defineNameWithoutChecking('A', classA); |
| 591 // prepare "A.==" | 593 // prepare "A.==" |
| 592 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '=='); | 594 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '=='); |
| 593 CommentReference commentReference = | 595 CommentReference commentReference = |
| 594 astFactory.commentReference(null, prefixed); | 596 astFactory.commentReference(null, prefixed); |
| 595 // resolve | 597 // resolve |
| 596 _resolveNode(commentReference); | 598 _resolveNode(commentReference); |
| 597 expect(prefixed.prefix.staticElement, classA); | 599 expect(prefixed.prefix.staticElement, classA); |
| 598 expect(prefixed.identifier.staticElement, method); | 600 expect(prefixed.identifier.staticElement, method); |
| 599 _listener.assertNoErrors(); | 601 _listener.assertNoErrors(); |
| 600 } | 602 } |
| 601 | 603 |
| 602 void test_visitConstructorName_named() { | 604 test_visitConstructorName_named() async { |
| 603 ClassElementImpl classA = ElementFactory.classElement2("A"); | 605 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 604 String constructorName = "a"; | 606 String constructorName = "a"; |
| 605 ConstructorElement constructor = | 607 ConstructorElement constructor = |
| 606 ElementFactory.constructorElement2(classA, constructorName); | 608 ElementFactory.constructorElement2(classA, constructorName); |
| 607 classA.constructors = <ConstructorElement>[constructor]; | 609 classA.constructors = <ConstructorElement>[constructor]; |
| 608 ConstructorName name = AstTestFactory.constructorName( | 610 ConstructorName name = AstTestFactory.constructorName( |
| 609 AstTestFactory.typeName(classA), constructorName); | 611 AstTestFactory.typeName(classA), constructorName); |
| 610 _resolveNode(name); | 612 _resolveNode(name); |
| 611 expect(name.staticElement, same(constructor)); | 613 expect(name.staticElement, same(constructor)); |
| 612 _listener.assertNoErrors(); | 614 _listener.assertNoErrors(); |
| 613 } | 615 } |
| 614 | 616 |
| 615 void test_visitConstructorName_unnamed() { | 617 test_visitConstructorName_unnamed() async { |
| 616 ClassElementImpl classA = ElementFactory.classElement2("A"); | 618 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 617 String constructorName = null; | 619 String constructorName = null; |
| 618 ConstructorElement constructor = | 620 ConstructorElement constructor = |
| 619 ElementFactory.constructorElement2(classA, constructorName); | 621 ElementFactory.constructorElement2(classA, constructorName); |
| 620 classA.constructors = <ConstructorElement>[constructor]; | 622 classA.constructors = <ConstructorElement>[constructor]; |
| 621 ConstructorName name = AstTestFactory.constructorName( | 623 ConstructorName name = AstTestFactory.constructorName( |
| 622 AstTestFactory.typeName(classA), constructorName); | 624 AstTestFactory.typeName(classA), constructorName); |
| 623 _resolveNode(name); | 625 _resolveNode(name); |
| 624 expect(name.staticElement, same(constructor)); | 626 expect(name.staticElement, same(constructor)); |
| 625 _listener.assertNoErrors(); | 627 _listener.assertNoErrors(); |
| 626 } | 628 } |
| 627 | 629 |
| 628 void test_visitContinueStatement_withLabel() { | 630 test_visitContinueStatement_withLabel() async { |
| 629 // loop: while (true) { | 631 // loop: while (true) { |
| 630 // continue loop; | 632 // continue loop; |
| 631 // } | 633 // } |
| 632 String label = "loop"; | 634 String label = "loop"; |
| 633 LabelElementImpl labelElement = new LabelElementImpl.forNode( | 635 LabelElementImpl labelElement = new LabelElementImpl.forNode( |
| 634 AstTestFactory.identifier3(label), false, false); | 636 AstTestFactory.identifier3(label), false, false); |
| 635 ContinueStatement continueStatement = | 637 ContinueStatement continueStatement = |
| 636 AstTestFactory.continueStatement(label); | 638 AstTestFactory.continueStatement(label); |
| 637 Expression condition = AstTestFactory.booleanLiteral(true); | 639 Expression condition = AstTestFactory.booleanLiteral(true); |
| 638 WhileStatement whileStatement = | 640 WhileStatement whileStatement = |
| 639 AstTestFactory.whileStatement(condition, continueStatement); | 641 AstTestFactory.whileStatement(condition, continueStatement); |
| 640 expect(_resolveContinue(continueStatement, labelElement, whileStatement), | 642 expect(_resolveContinue(continueStatement, labelElement, whileStatement), |
| 641 same(labelElement)); | 643 same(labelElement)); |
| 642 expect(continueStatement.target, same(whileStatement)); | 644 expect(continueStatement.target, same(whileStatement)); |
| 643 _listener.assertNoErrors(); | 645 _listener.assertNoErrors(); |
| 644 } | 646 } |
| 645 | 647 |
| 646 void test_visitContinueStatement_withoutLabel() { | 648 test_visitContinueStatement_withoutLabel() async { |
| 647 ContinueStatement statement = AstTestFactory.continueStatement(); | 649 ContinueStatement statement = AstTestFactory.continueStatement(); |
| 648 _resolveStatement(statement, null, null); | 650 _resolveStatement(statement, null, null); |
| 649 _listener.assertNoErrors(); | 651 _listener.assertNoErrors(); |
| 650 } | 652 } |
| 651 | 653 |
| 652 void test_visitEnumDeclaration() { | 654 test_visitEnumDeclaration() async { |
| 653 CompilationUnitElementImpl compilationUnitElement = | 655 CompilationUnitElementImpl compilationUnitElement = |
| 654 ElementFactory.compilationUnit('foo.dart'); | 656 ElementFactory.compilationUnit('foo.dart'); |
| 655 EnumElementImpl enumElement = | 657 EnumElementImpl enumElement = |
| 656 ElementFactory.enumElement(_typeProvider, ('E')); | 658 ElementFactory.enumElement(_typeProvider, ('E')); |
| 657 compilationUnitElement.enums = <ClassElement>[enumElement]; | 659 compilationUnitElement.enums = <ClassElement>[enumElement]; |
| 658 EnumDeclaration enumNode = AstTestFactory.enumDeclaration2('E', []); | 660 EnumDeclaration enumNode = AstTestFactory.enumDeclaration2('E', []); |
| 659 Annotation annotationNode = | 661 Annotation annotationNode = |
| 660 AstTestFactory.annotation(AstTestFactory.identifier3('a')); | 662 AstTestFactory.annotation(AstTestFactory.identifier3('a')); |
| 661 annotationNode.element = ElementFactory.classElement2('A'); | 663 annotationNode.element = ElementFactory.classElement2('A'); |
| 662 annotationNode.elementAnnotation = | 664 annotationNode.elementAnnotation = |
| 663 new ElementAnnotationImpl(compilationUnitElement); | 665 new ElementAnnotationImpl(compilationUnitElement); |
| 664 enumNode.metadata.add(annotationNode); | 666 enumNode.metadata.add(annotationNode); |
| 665 enumNode.name.staticElement = enumElement; | 667 enumNode.name.staticElement = enumElement; |
| 666 List<ElementAnnotation> metadata = <ElementAnnotation>[ | 668 List<ElementAnnotation> metadata = <ElementAnnotation>[ |
| 667 annotationNode.elementAnnotation | 669 annotationNode.elementAnnotation |
| 668 ]; | 670 ]; |
| 669 _resolveNode(enumNode); | 671 _resolveNode(enumNode); |
| 670 expect(metadata[0].element, annotationNode.element); | 672 expect(metadata[0].element, annotationNode.element); |
| 671 } | 673 } |
| 672 | 674 |
| 673 void test_visitExportDirective_noCombinators() { | 675 test_visitExportDirective_noCombinators() async { |
| 674 ExportDirective directive = AstTestFactory.exportDirective2(null); | 676 ExportDirective directive = AstTestFactory.exportDirective2(null); |
| 675 directive.element = ElementFactory | 677 directive.element = ElementFactory |
| 676 .exportFor(ElementFactory.library(_definingLibrary.context, "lib")); | 678 .exportFor(ElementFactory.library(_definingLibrary.context, "lib")); |
| 677 _resolveNode(directive); | 679 _resolveNode(directive); |
| 678 _listener.assertNoErrors(); | 680 _listener.assertNoErrors(); |
| 679 } | 681 } |
| 680 | 682 |
| 681 void test_visitFieldFormalParameter() { | 683 test_visitFieldFormalParameter() async { |
| 682 String fieldName = "f"; | 684 String fieldName = "f"; |
| 683 InterfaceType intType = _typeProvider.intType; | 685 InterfaceType intType = _typeProvider.intType; |
| 684 FieldElementImpl fieldElement = | 686 FieldElementImpl fieldElement = |
| 685 ElementFactory.fieldElement(fieldName, false, false, false, intType); | 687 ElementFactory.fieldElement(fieldName, false, false, false, intType); |
| 686 ClassElementImpl classA = ElementFactory.classElement2("A"); | 688 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 687 classA.fields = <FieldElement>[fieldElement]; | 689 classA.fields = <FieldElement>[fieldElement]; |
| 688 FieldFormalParameter parameter = | 690 FieldFormalParameter parameter = |
| 689 AstTestFactory.fieldFormalParameter2(fieldName); | 691 AstTestFactory.fieldFormalParameter2(fieldName); |
| 690 FieldFormalParameterElementImpl parameterElement = | 692 FieldFormalParameterElementImpl parameterElement = |
| 691 ElementFactory.fieldFormalParameter(parameter.identifier); | 693 ElementFactory.fieldFormalParameter(parameter.identifier); |
| 692 parameterElement.field = fieldElement; | 694 parameterElement.field = fieldElement; |
| 693 parameterElement.type = intType; | 695 parameterElement.type = intType; |
| 694 parameter.identifier.staticElement = parameterElement; | 696 parameter.identifier.staticElement = parameterElement; |
| 695 _resolveInClass(parameter, classA); | 697 _resolveInClass(parameter, classA); |
| 696 expect(resolutionMap.elementDeclaredByFormalParameter(parameter).type, | 698 expect(resolutionMap.elementDeclaredByFormalParameter(parameter).type, |
| 697 same(intType)); | 699 same(intType)); |
| 698 } | 700 } |
| 699 | 701 |
| 700 void test_visitImportDirective_noCombinators_noPrefix() { | 702 test_visitImportDirective_noCombinators_noPrefix() async { |
| 701 ImportDirective directive = AstTestFactory.importDirective3(null, null); | 703 ImportDirective directive = AstTestFactory.importDirective3(null, null); |
| 702 directive.element = ElementFactory.importFor( | 704 directive.element = ElementFactory.importFor( |
| 703 ElementFactory.library(_definingLibrary.context, "lib"), null); | 705 ElementFactory.library(_definingLibrary.context, "lib"), null); |
| 704 _resolveNode(directive); | 706 _resolveNode(directive); |
| 705 _listener.assertNoErrors(); | 707 _listener.assertNoErrors(); |
| 706 } | 708 } |
| 707 | 709 |
| 708 void test_visitImportDirective_noCombinators_prefix() { | 710 test_visitImportDirective_noCombinators_prefix() async { |
| 709 String prefixName = "p"; | 711 String prefixName = "p"; |
| 710 ImportElement importElement = ElementFactory.importFor( | 712 ImportElement importElement = ElementFactory.importFor( |
| 711 ElementFactory.library(_definingLibrary.context, "lib"), | 713 ElementFactory.library(_definingLibrary.context, "lib"), |
| 712 ElementFactory.prefix(prefixName)); | 714 ElementFactory.prefix(prefixName)); |
| 713 _definingLibrary.imports = <ImportElement>[importElement]; | 715 _definingLibrary.imports = <ImportElement>[importElement]; |
| 714 ImportDirective directive = | 716 ImportDirective directive = |
| 715 AstTestFactory.importDirective3(null, prefixName); | 717 AstTestFactory.importDirective3(null, prefixName); |
| 716 directive.element = importElement; | 718 directive.element = importElement; |
| 717 _resolveNode(directive); | 719 _resolveNode(directive); |
| 718 _listener.assertNoErrors(); | 720 _listener.assertNoErrors(); |
| 719 } | 721 } |
| 720 | 722 |
| 721 void test_visitImportDirective_withCombinators() { | 723 test_visitImportDirective_withCombinators() async { |
| 722 ShowCombinator combinator = AstTestFactory.showCombinator2(["A", "B", "C"]); | 724 ShowCombinator combinator = AstTestFactory.showCombinator2(["A", "B", "C"]); |
| 723 ImportDirective directive = | 725 ImportDirective directive = |
| 724 AstTestFactory.importDirective3(null, null, [combinator]); | 726 AstTestFactory.importDirective3(null, null, [combinator]); |
| 725 LibraryElementImpl library = | 727 LibraryElementImpl library = |
| 726 ElementFactory.library(_definingLibrary.context, "lib"); | 728 ElementFactory.library(_definingLibrary.context, "lib"); |
| 727 TopLevelVariableElementImpl varA = | 729 TopLevelVariableElementImpl varA = |
| 728 ElementFactory.topLevelVariableElement2("A"); | 730 ElementFactory.topLevelVariableElement2("A"); |
| 729 TopLevelVariableElementImpl varB = | 731 TopLevelVariableElementImpl varB = |
| 730 ElementFactory.topLevelVariableElement2("B"); | 732 ElementFactory.topLevelVariableElement2("B"); |
| 731 TopLevelVariableElementImpl varC = | 733 TopLevelVariableElementImpl varC = |
| 732 ElementFactory.topLevelVariableElement2("C"); | 734 ElementFactory.topLevelVariableElement2("C"); |
| 733 CompilationUnitElementImpl unit = | 735 CompilationUnitElementImpl unit = |
| 734 library.definingCompilationUnit as CompilationUnitElementImpl; | 736 library.definingCompilationUnit as CompilationUnitElementImpl; |
| 735 unit.accessors = <PropertyAccessorElement>[ | 737 unit.accessors = <PropertyAccessorElement>[ |
| 736 varA.getter, | 738 varA.getter, |
| 737 varA.setter, | 739 varA.setter, |
| 738 varB.getter, | 740 varB.getter, |
| 739 varC.setter | 741 varC.setter |
| 740 ]; | 742 ]; |
| 741 unit.topLevelVariables = <TopLevelVariableElement>[varA, varB, varC]; | 743 unit.topLevelVariables = <TopLevelVariableElement>[varA, varB, varC]; |
| 742 directive.element = ElementFactory.importFor(library, null); | 744 directive.element = ElementFactory.importFor(library, null); |
| 743 _resolveNode(directive); | 745 _resolveNode(directive); |
| 744 expect(combinator.shownNames[0].staticElement, same(varA)); | 746 expect(combinator.shownNames[0].staticElement, same(varA)); |
| 745 expect(combinator.shownNames[1].staticElement, same(varB)); | 747 expect(combinator.shownNames[1].staticElement, same(varB)); |
| 746 expect(combinator.shownNames[2].staticElement, same(varC)); | 748 expect(combinator.shownNames[2].staticElement, same(varC)); |
| 747 _listener.assertNoErrors(); | 749 _listener.assertNoErrors(); |
| 748 } | 750 } |
| 749 | 751 |
| 750 void test_visitIndexExpression_get() { | 752 test_visitIndexExpression_get() async { |
| 751 ClassElementImpl classA = ElementFactory.classElement2("A"); | 753 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 752 InterfaceType intType = _typeProvider.intType; | 754 InterfaceType intType = _typeProvider.intType; |
| 753 MethodElement getter = | 755 MethodElement getter = |
| 754 ElementFactory.methodElement("[]", intType, [intType]); | 756 ElementFactory.methodElement("[]", intType, [intType]); |
| 755 classA.methods = <MethodElement>[getter]; | 757 classA.methods = <MethodElement>[getter]; |
| 756 SimpleIdentifier array = AstTestFactory.identifier3("a"); | 758 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
| 757 array.staticType = classA.type; | 759 array.staticType = classA.type; |
| 758 IndexExpression expression = | 760 IndexExpression expression = |
| 759 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); | 761 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
| 760 expect(_resolveIndexExpression(expression), same(getter)); | 762 expect(_resolveIndexExpression(expression), same(getter)); |
| 761 _listener.assertNoErrors(); | 763 _listener.assertNoErrors(); |
| 762 } | 764 } |
| 763 | 765 |
| 764 void test_visitIndexExpression_set() { | 766 test_visitIndexExpression_set() async { |
| 765 ClassElementImpl classA = ElementFactory.classElement2("A"); | 767 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 766 InterfaceType intType = _typeProvider.intType; | 768 InterfaceType intType = _typeProvider.intType; |
| 767 MethodElement setter = | 769 MethodElement setter = |
| 768 ElementFactory.methodElement("[]=", intType, [intType]); | 770 ElementFactory.methodElement("[]=", intType, [intType]); |
| 769 classA.methods = <MethodElement>[setter]; | 771 classA.methods = <MethodElement>[setter]; |
| 770 SimpleIdentifier array = AstTestFactory.identifier3("a"); | 772 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
| 771 array.staticType = classA.type; | 773 array.staticType = classA.type; |
| 772 IndexExpression expression = | 774 IndexExpression expression = |
| 773 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); | 775 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
| 774 AstTestFactory.assignmentExpression( | 776 AstTestFactory.assignmentExpression( |
| 775 expression, TokenType.EQ, AstTestFactory.integer(0)); | 777 expression, TokenType.EQ, AstTestFactory.integer(0)); |
| 776 expect(_resolveIndexExpression(expression), same(setter)); | 778 expect(_resolveIndexExpression(expression), same(setter)); |
| 777 _listener.assertNoErrors(); | 779 _listener.assertNoErrors(); |
| 778 } | 780 } |
| 779 | 781 |
| 780 void test_visitInstanceCreationExpression_named() { | 782 test_visitInstanceCreationExpression_named() async { |
| 781 ClassElementImpl classA = ElementFactory.classElement2("A"); | 783 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 782 String constructorName = "a"; | 784 String constructorName = "a"; |
| 783 ConstructorElement constructor = | 785 ConstructorElement constructor = |
| 784 ElementFactory.constructorElement2(classA, constructorName); | 786 ElementFactory.constructorElement2(classA, constructorName); |
| 785 classA.constructors = <ConstructorElement>[constructor]; | 787 classA.constructors = <ConstructorElement>[constructor]; |
| 786 ConstructorName name = AstTestFactory.constructorName( | 788 ConstructorName name = AstTestFactory.constructorName( |
| 787 AstTestFactory.typeName(classA), constructorName); | 789 AstTestFactory.typeName(classA), constructorName); |
| 788 name.staticElement = constructor; | 790 name.staticElement = constructor; |
| 789 InstanceCreationExpression creation = | 791 InstanceCreationExpression creation = |
| 790 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); | 792 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); |
| 791 _resolveNode(creation); | 793 _resolveNode(creation); |
| 792 expect(creation.staticElement, same(constructor)); | 794 expect(creation.staticElement, same(constructor)); |
| 793 _listener.assertNoErrors(); | 795 _listener.assertNoErrors(); |
| 794 } | 796 } |
| 795 | 797 |
| 796 void test_visitInstanceCreationExpression_unnamed() { | 798 test_visitInstanceCreationExpression_unnamed() async { |
| 797 ClassElementImpl classA = ElementFactory.classElement2("A"); | 799 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 798 String constructorName = null; | 800 String constructorName = null; |
| 799 ConstructorElement constructor = | 801 ConstructorElement constructor = |
| 800 ElementFactory.constructorElement2(classA, constructorName); | 802 ElementFactory.constructorElement2(classA, constructorName); |
| 801 classA.constructors = <ConstructorElement>[constructor]; | 803 classA.constructors = <ConstructorElement>[constructor]; |
| 802 ConstructorName name = AstTestFactory.constructorName( | 804 ConstructorName name = AstTestFactory.constructorName( |
| 803 AstTestFactory.typeName(classA), constructorName); | 805 AstTestFactory.typeName(classA), constructorName); |
| 804 name.staticElement = constructor; | 806 name.staticElement = constructor; |
| 805 InstanceCreationExpression creation = | 807 InstanceCreationExpression creation = |
| 806 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); | 808 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); |
| 807 _resolveNode(creation); | 809 _resolveNode(creation); |
| 808 expect(creation.staticElement, same(constructor)); | 810 expect(creation.staticElement, same(constructor)); |
| 809 _listener.assertNoErrors(); | 811 _listener.assertNoErrors(); |
| 810 } | 812 } |
| 811 | 813 |
| 812 void test_visitInstanceCreationExpression_unnamed_namedParameter() { | 814 test_visitInstanceCreationExpression_unnamed_namedParameter() async { |
| 813 ClassElementImpl classA = ElementFactory.classElement2("A"); | 815 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 814 String constructorName = null; | 816 String constructorName = null; |
| 815 ConstructorElementImpl constructor = | 817 ConstructorElementImpl constructor = |
| 816 ElementFactory.constructorElement2(classA, constructorName); | 818 ElementFactory.constructorElement2(classA, constructorName); |
| 817 String parameterName = "a"; | 819 String parameterName = "a"; |
| 818 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 820 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 819 constructor.parameters = <ParameterElement>[parameter]; | 821 constructor.parameters = <ParameterElement>[parameter]; |
| 820 classA.constructors = <ConstructorElement>[constructor]; | 822 classA.constructors = <ConstructorElement>[constructor]; |
| 821 ConstructorName name = AstTestFactory.constructorName( | 823 ConstructorName name = AstTestFactory.constructorName( |
| 822 AstTestFactory.typeName(classA), constructorName); | 824 AstTestFactory.typeName(classA), constructorName); |
| 823 name.staticElement = constructor; | 825 name.staticElement = constructor; |
| 824 InstanceCreationExpression creation = AstTestFactory | 826 InstanceCreationExpression creation = AstTestFactory |
| 825 .instanceCreationExpression(Keyword.NEW, name, [ | 827 .instanceCreationExpression(Keyword.NEW, name, [ |
| 826 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) | 828 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) |
| 827 ]); | 829 ]); |
| 828 _resolveNode(creation); | 830 _resolveNode(creation); |
| 829 expect(creation.staticElement, same(constructor)); | 831 expect(creation.staticElement, same(constructor)); |
| 830 expect( | 832 expect( |
| 831 (creation.argumentList.arguments[0] as NamedExpression) | 833 (creation.argumentList.arguments[0] as NamedExpression) |
| 832 .name | 834 .name |
| 833 .label | 835 .label |
| 834 .staticElement, | 836 .staticElement, |
| 835 same(parameter)); | 837 same(parameter)); |
| 836 _listener.assertNoErrors(); | 838 _listener.assertNoErrors(); |
| 837 } | 839 } |
| 838 | 840 |
| 839 void test_visitMethodInvocation() { | 841 test_visitMethodInvocation() async { |
| 840 InterfaceType numType = _typeProvider.numType; | 842 InterfaceType numType = _typeProvider.numType; |
| 841 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 843 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 842 left.staticType = numType; | 844 left.staticType = numType; |
| 843 String methodName = "abs"; | 845 String methodName = "abs"; |
| 844 MethodInvocation invocation = | 846 MethodInvocation invocation = |
| 845 AstTestFactory.methodInvocation(left, methodName); | 847 AstTestFactory.methodInvocation(left, methodName); |
| 846 _resolveNode(invocation); | 848 _resolveNode(invocation); |
| 847 expect(invocation.methodName.staticElement, | 849 expect(invocation.methodName.staticElement, |
| 848 same(getMethod(numType, methodName))); | 850 same(getMethod(numType, methodName))); |
| 849 _listener.assertNoErrors(); | 851 _listener.assertNoErrors(); |
| 850 } | 852 } |
| 851 | 853 |
| 852 void test_visitMethodInvocation_namedParameter() { | 854 test_visitMethodInvocation_namedParameter() async { |
| 853 ClassElementImpl classA = ElementFactory.classElement2("A"); | 855 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 854 String methodName = "m"; | 856 String methodName = "m"; |
| 855 String parameterName = "p"; | 857 String parameterName = "p"; |
| 856 MethodElementImpl method = ElementFactory.methodElement(methodName, null); | 858 MethodElementImpl method = ElementFactory.methodElement(methodName, null); |
| 857 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 859 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 858 method.parameters = <ParameterElement>[parameter]; | 860 method.parameters = <ParameterElement>[parameter]; |
| 859 classA.methods = <MethodElement>[method]; | 861 classA.methods = <MethodElement>[method]; |
| 860 SimpleIdentifier left = AstTestFactory.identifier3("i"); | 862 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
| 861 left.staticType = classA.type; | 863 left.staticType = classA.type; |
| 862 MethodInvocation invocation = AstTestFactory.methodInvocation( | 864 MethodInvocation invocation = AstTestFactory.methodInvocation( |
| 863 left, methodName, [ | 865 left, methodName, [ |
| 864 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) | 866 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) |
| 865 ]); | 867 ]); |
| 866 _resolveNode(invocation); | 868 _resolveNode(invocation); |
| 867 expect(invocation.methodName.staticElement, same(method)); | 869 expect(invocation.methodName.staticElement, same(method)); |
| 868 expect( | 870 expect( |
| 869 (invocation.argumentList.arguments[0] as NamedExpression) | 871 (invocation.argumentList.arguments[0] as NamedExpression) |
| 870 .name | 872 .name |
| 871 .label | 873 .label |
| 872 .staticElement, | 874 .staticElement, |
| 873 same(parameter)); | 875 same(parameter)); |
| 874 _listener.assertNoErrors(); | 876 _listener.assertNoErrors(); |
| 875 } | 877 } |
| 876 | 878 |
| 877 void test_visitPostfixExpression() { | 879 test_visitPostfixExpression() async { |
| 878 InterfaceType numType = _typeProvider.numType; | 880 InterfaceType numType = _typeProvider.numType; |
| 879 SimpleIdentifier operand = AstTestFactory.identifier3("i"); | 881 SimpleIdentifier operand = AstTestFactory.identifier3("i"); |
| 880 operand.staticType = numType; | 882 operand.staticType = numType; |
| 881 PostfixExpression expression = | 883 PostfixExpression expression = |
| 882 AstTestFactory.postfixExpression(operand, TokenType.PLUS_PLUS); | 884 AstTestFactory.postfixExpression(operand, TokenType.PLUS_PLUS); |
| 883 _resolveNode(expression); | 885 _resolveNode(expression); |
| 884 expect(expression.staticElement, getMethod(numType, "+")); | 886 expect(expression.staticElement, getMethod(numType, "+")); |
| 885 _listener.assertNoErrors(); | 887 _listener.assertNoErrors(); |
| 886 } | 888 } |
| 887 | 889 |
| 888 void test_visitPrefixedIdentifier_dynamic() { | 890 test_visitPrefixedIdentifier_dynamic() async { |
| 889 DartType dynamicType = _typeProvider.dynamicType; | 891 DartType dynamicType = _typeProvider.dynamicType; |
| 890 SimpleIdentifier target = AstTestFactory.identifier3("a"); | 892 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
| 891 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 893 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
| 892 variable.type = dynamicType; | 894 variable.type = dynamicType; |
| 893 target.staticElement = variable; | 895 target.staticElement = variable; |
| 894 target.staticType = dynamicType; | 896 target.staticType = dynamicType; |
| 895 PrefixedIdentifier identifier = | 897 PrefixedIdentifier identifier = |
| 896 AstTestFactory.identifier(target, AstTestFactory.identifier3("b")); | 898 AstTestFactory.identifier(target, AstTestFactory.identifier3("b")); |
| 897 _resolveNode(identifier); | 899 _resolveNode(identifier); |
| 898 expect(identifier.staticElement, isNull); | 900 expect(identifier.staticElement, isNull); |
| 899 expect(identifier.identifier.staticElement, isNull); | 901 expect(identifier.identifier.staticElement, isNull); |
| 900 _listener.assertNoErrors(); | 902 _listener.assertNoErrors(); |
| 901 } | 903 } |
| 902 | 904 |
| 903 void test_visitPrefixedIdentifier_nonDynamic() { | 905 test_visitPrefixedIdentifier_nonDynamic() async { |
| 904 ClassElementImpl classA = ElementFactory.classElement2("A"); | 906 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 905 String getterName = "b"; | 907 String getterName = "b"; |
| 906 PropertyAccessorElement getter = | 908 PropertyAccessorElement getter = |
| 907 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 909 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 908 classA.accessors = <PropertyAccessorElement>[getter]; | 910 classA.accessors = <PropertyAccessorElement>[getter]; |
| 909 SimpleIdentifier target = AstTestFactory.identifier3("a"); | 911 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
| 910 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 912 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
| 911 variable.type = classA.type; | 913 variable.type = classA.type; |
| 912 target.staticElement = variable; | 914 target.staticElement = variable; |
| 913 target.staticType = classA.type; | 915 target.staticType = classA.type; |
| 914 PrefixedIdentifier identifier = AstTestFactory.identifier( | 916 PrefixedIdentifier identifier = AstTestFactory.identifier( |
| 915 target, AstTestFactory.identifier3(getterName)); | 917 target, AstTestFactory.identifier3(getterName)); |
| 916 _resolveNode(identifier); | 918 _resolveNode(identifier); |
| 917 expect(identifier.staticElement, same(getter)); | 919 expect(identifier.staticElement, same(getter)); |
| 918 expect(identifier.identifier.staticElement, same(getter)); | 920 expect(identifier.identifier.staticElement, same(getter)); |
| 919 _listener.assertNoErrors(); | 921 _listener.assertNoErrors(); |
| 920 } | 922 } |
| 921 | 923 |
| 922 void test_visitPrefixedIdentifier_staticClassMember_getter() { | 924 test_visitPrefixedIdentifier_staticClassMember_getter() async { |
| 923 ClassElementImpl classA = ElementFactory.classElement2("A"); | 925 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 924 // set accessors | 926 // set accessors |
| 925 String propName = "b"; | 927 String propName = "b"; |
| 926 PropertyAccessorElement getter = | 928 PropertyAccessorElement getter = |
| 927 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 929 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
| 928 PropertyAccessorElement setter = | 930 PropertyAccessorElement setter = |
| 929 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 931 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
| 930 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 932 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
| 931 // prepare "A.m" | 933 // prepare "A.m" |
| 932 SimpleIdentifier target = AstTestFactory.identifier3("A"); | 934 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
| 933 target.staticElement = classA; | 935 target.staticElement = classA; |
| 934 target.staticType = classA.type; | 936 target.staticType = classA.type; |
| 935 PrefixedIdentifier identifier = | 937 PrefixedIdentifier identifier = |
| 936 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); | 938 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
| 937 // resolve | 939 // resolve |
| 938 _resolveNode(identifier); | 940 _resolveNode(identifier); |
| 939 expect(identifier.staticElement, same(getter)); | 941 expect(identifier.staticElement, same(getter)); |
| 940 expect(identifier.identifier.staticElement, same(getter)); | 942 expect(identifier.identifier.staticElement, same(getter)); |
| 941 _listener.assertNoErrors(); | 943 _listener.assertNoErrors(); |
| 942 } | 944 } |
| 943 | 945 |
| 944 void test_visitPrefixedIdentifier_staticClassMember_method() { | 946 test_visitPrefixedIdentifier_staticClassMember_method() async { |
| 945 ClassElementImpl classA = ElementFactory.classElement2("A"); | 947 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 946 // set methods | 948 // set methods |
| 947 String propName = "m"; | 949 String propName = "m"; |
| 948 MethodElement method = | 950 MethodElement method = |
| 949 ElementFactory.methodElement("m", _typeProvider.intType); | 951 ElementFactory.methodElement("m", _typeProvider.intType); |
| 950 classA.methods = <MethodElement>[method]; | 952 classA.methods = <MethodElement>[method]; |
| 951 // prepare "A.m" | 953 // prepare "A.m" |
| 952 SimpleIdentifier target = AstTestFactory.identifier3("A"); | 954 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
| 953 target.staticElement = classA; | 955 target.staticElement = classA; |
| 954 target.staticType = classA.type; | 956 target.staticType = classA.type; |
| 955 PrefixedIdentifier identifier = | 957 PrefixedIdentifier identifier = |
| 956 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); | 958 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
| 957 AstTestFactory.assignmentExpression( | 959 AstTestFactory.assignmentExpression( |
| 958 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); | 960 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); |
| 959 // resolve | 961 // resolve |
| 960 _resolveNode(identifier); | 962 _resolveNode(identifier); |
| 961 expect(identifier.staticElement, same(method)); | 963 expect(identifier.staticElement, same(method)); |
| 962 expect(identifier.identifier.staticElement, same(method)); | 964 expect(identifier.identifier.staticElement, same(method)); |
| 963 _listener.assertNoErrors(); | 965 _listener.assertNoErrors(); |
| 964 } | 966 } |
| 965 | 967 |
| 966 void test_visitPrefixedIdentifier_staticClassMember_setter() { | 968 test_visitPrefixedIdentifier_staticClassMember_setter() async { |
| 967 ClassElementImpl classA = ElementFactory.classElement2("A"); | 969 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 968 // set accessors | 970 // set accessors |
| 969 String propName = "b"; | 971 String propName = "b"; |
| 970 PropertyAccessorElement getter = | 972 PropertyAccessorElement getter = |
| 971 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 973 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
| 972 PropertyAccessorElement setter = | 974 PropertyAccessorElement setter = |
| 973 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 975 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
| 974 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 976 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
| 975 // prepare "A.b = null" | 977 // prepare "A.b = null" |
| 976 SimpleIdentifier target = AstTestFactory.identifier3("A"); | 978 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
| 977 target.staticElement = classA; | 979 target.staticElement = classA; |
| 978 target.staticType = classA.type; | 980 target.staticType = classA.type; |
| 979 PrefixedIdentifier identifier = | 981 PrefixedIdentifier identifier = |
| 980 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); | 982 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
| 981 AstTestFactory.assignmentExpression( | 983 AstTestFactory.assignmentExpression( |
| 982 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); | 984 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); |
| 983 // resolve | 985 // resolve |
| 984 _resolveNode(identifier); | 986 _resolveNode(identifier); |
| 985 expect(identifier.staticElement, same(setter)); | 987 expect(identifier.staticElement, same(setter)); |
| 986 expect(identifier.identifier.staticElement, same(setter)); | 988 expect(identifier.identifier.staticElement, same(setter)); |
| 987 _listener.assertNoErrors(); | 989 _listener.assertNoErrors(); |
| 988 } | 990 } |
| 989 | 991 |
| 990 void test_visitPrefixExpression() { | 992 test_visitPrefixExpression() async { |
| 991 InterfaceType numType = _typeProvider.numType; | 993 InterfaceType numType = _typeProvider.numType; |
| 992 SimpleIdentifier operand = AstTestFactory.identifier3("i"); | 994 SimpleIdentifier operand = AstTestFactory.identifier3("i"); |
| 993 operand.staticType = numType; | 995 operand.staticType = numType; |
| 994 PrefixExpression expression = | 996 PrefixExpression expression = |
| 995 AstTestFactory.prefixExpression(TokenType.PLUS_PLUS, operand); | 997 AstTestFactory.prefixExpression(TokenType.PLUS_PLUS, operand); |
| 996 _resolveNode(expression); | 998 _resolveNode(expression); |
| 997 expect(expression.staticElement, getMethod(numType, "+")); | 999 expect(expression.staticElement, getMethod(numType, "+")); |
| 998 _listener.assertNoErrors(); | 1000 _listener.assertNoErrors(); |
| 999 } | 1001 } |
| 1000 | 1002 |
| 1001 void test_visitPropertyAccess_getter_identifier() { | 1003 test_visitPropertyAccess_getter_identifier() async { |
| 1002 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1004 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1003 String getterName = "b"; | 1005 String getterName = "b"; |
| 1004 PropertyAccessorElement getter = | 1006 PropertyAccessorElement getter = |
| 1005 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 1007 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 1006 classA.accessors = <PropertyAccessorElement>[getter]; | 1008 classA.accessors = <PropertyAccessorElement>[getter]; |
| 1007 SimpleIdentifier target = AstTestFactory.identifier3("a"); | 1009 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
| 1008 target.staticType = classA.type; | 1010 target.staticType = classA.type; |
| 1009 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); | 1011 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); |
| 1010 _resolveNode(access); | 1012 _resolveNode(access); |
| 1011 expect(access.propertyName.staticElement, same(getter)); | 1013 expect(access.propertyName.staticElement, same(getter)); |
| 1012 _listener.assertNoErrors(); | 1014 _listener.assertNoErrors(); |
| 1013 } | 1015 } |
| 1014 | 1016 |
| 1015 void test_visitPropertyAccess_getter_super() { | 1017 test_visitPropertyAccess_getter_super() async { |
| 1016 // | 1018 // |
| 1017 // class A { | 1019 // class A { |
| 1018 // int get b; | 1020 // int get b; |
| 1019 // } | 1021 // } |
| 1020 // class B { | 1022 // class B { |
| 1021 // ... super.m ... | 1023 // ... super.m ... |
| 1022 // } | 1024 // } |
| 1023 // | 1025 // |
| 1024 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1026 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1025 String getterName = "b"; | 1027 String getterName = "b"; |
| 1026 PropertyAccessorElement getter = | 1028 PropertyAccessorElement getter = |
| 1027 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 1029 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 1028 classA.accessors = <PropertyAccessorElement>[getter]; | 1030 classA.accessors = <PropertyAccessorElement>[getter]; |
| 1029 SuperExpression target = AstTestFactory.superExpression(); | 1031 SuperExpression target = AstTestFactory.superExpression(); |
| 1030 target.staticType = ElementFactory.classElement("B", classA.type).type; | 1032 target.staticType = ElementFactory.classElement("B", classA.type).type; |
| 1031 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); | 1033 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); |
| 1032 AstTestFactory.methodDeclaration2( | 1034 AstTestFactory.methodDeclaration2( |
| 1033 null, | 1035 null, |
| 1034 null, | 1036 null, |
| 1035 null, | 1037 null, |
| 1036 null, | 1038 null, |
| 1037 AstTestFactory.identifier3("m"), | 1039 AstTestFactory.identifier3("m"), |
| 1038 AstTestFactory.formalParameterList(), | 1040 AstTestFactory.formalParameterList(), |
| 1039 AstTestFactory.expressionFunctionBody(access)); | 1041 AstTestFactory.expressionFunctionBody(access)); |
| 1040 _resolveNode(access); | 1042 _resolveNode(access); |
| 1041 expect(access.propertyName.staticElement, same(getter)); | 1043 expect(access.propertyName.staticElement, same(getter)); |
| 1042 _listener.assertNoErrors(); | 1044 _listener.assertNoErrors(); |
| 1043 } | 1045 } |
| 1044 | 1046 |
| 1045 void test_visitPropertyAccess_setter_this() { | 1047 test_visitPropertyAccess_setter_this() async { |
| 1046 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1048 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1047 String setterName = "b"; | 1049 String setterName = "b"; |
| 1048 PropertyAccessorElement setter = | 1050 PropertyAccessorElement setter = |
| 1049 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 1051 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
| 1050 classA.accessors = <PropertyAccessorElement>[setter]; | 1052 classA.accessors = <PropertyAccessorElement>[setter]; |
| 1051 ThisExpression target = AstTestFactory.thisExpression(); | 1053 ThisExpression target = AstTestFactory.thisExpression(); |
| 1052 target.staticType = classA.type; | 1054 target.staticType = classA.type; |
| 1053 PropertyAccess access = AstTestFactory.propertyAccess2(target, setterName); | 1055 PropertyAccess access = AstTestFactory.propertyAccess2(target, setterName); |
| 1054 AstTestFactory.assignmentExpression( | 1056 AstTestFactory.assignmentExpression( |
| 1055 access, TokenType.EQ, AstTestFactory.integer(0)); | 1057 access, TokenType.EQ, AstTestFactory.integer(0)); |
| 1056 _resolveNode(access); | 1058 _resolveNode(access); |
| 1057 expect(access.propertyName.staticElement, same(setter)); | 1059 expect(access.propertyName.staticElement, same(setter)); |
| 1058 _listener.assertNoErrors(); | 1060 _listener.assertNoErrors(); |
| 1059 } | 1061 } |
| 1060 | 1062 |
| 1061 void test_visitSimpleIdentifier_classScope() { | 1063 test_visitSimpleIdentifier_classScope() async { |
| 1062 InterfaceType doubleType = _typeProvider.doubleType; | 1064 InterfaceType doubleType = _typeProvider.doubleType; |
| 1063 String fieldName = "NAN"; | 1065 String fieldName = "NAN"; |
| 1064 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); | 1066 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); |
| 1065 _resolveInClass(node, doubleType.element); | 1067 _resolveInClass(node, doubleType.element); |
| 1066 expect(node.staticElement, getGetter(doubleType, fieldName)); | 1068 expect(node.staticElement, getGetter(doubleType, fieldName)); |
| 1067 _listener.assertNoErrors(); | 1069 _listener.assertNoErrors(); |
| 1068 } | 1070 } |
| 1069 | 1071 |
| 1070 void test_visitSimpleIdentifier_dynamic() { | 1072 test_visitSimpleIdentifier_dynamic() async { |
| 1071 SimpleIdentifier node = AstTestFactory.identifier3("dynamic"); | 1073 SimpleIdentifier node = AstTestFactory.identifier3("dynamic"); |
| 1072 _resolveIdentifier(node); | 1074 _resolveIdentifier(node); |
| 1073 expect(node.staticElement, same(_typeProvider.dynamicType.element)); | 1075 expect(node.staticElement, same(_typeProvider.dynamicType.element)); |
| 1074 expect(node.staticType, same(_typeProvider.typeType)); | 1076 expect(node.staticType, same(_typeProvider.typeType)); |
| 1075 _listener.assertNoErrors(); | 1077 _listener.assertNoErrors(); |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 void test_visitSimpleIdentifier_lexicalScope() { | 1080 test_visitSimpleIdentifier_lexicalScope() async { |
| 1079 SimpleIdentifier node = AstTestFactory.identifier3("i"); | 1081 SimpleIdentifier node = AstTestFactory.identifier3("i"); |
| 1080 VariableElementImpl element = ElementFactory.localVariableElement(node); | 1082 VariableElementImpl element = ElementFactory.localVariableElement(node); |
| 1081 expect(_resolveIdentifier(node, [element]), same(element)); | 1083 expect(_resolveIdentifier(node, [element]), same(element)); |
| 1082 _listener.assertNoErrors(); | 1084 _listener.assertNoErrors(); |
| 1083 } | 1085 } |
| 1084 | 1086 |
| 1085 void test_visitSimpleIdentifier_lexicalScope_field_setter() { | 1087 test_visitSimpleIdentifier_lexicalScope_field_setter() async { |
| 1086 InterfaceType intType = _typeProvider.intType; | 1088 InterfaceType intType = _typeProvider.intType; |
| 1087 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1089 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1088 String fieldName = "a"; | 1090 String fieldName = "a"; |
| 1089 FieldElement field = | 1091 FieldElement field = |
| 1090 ElementFactory.fieldElement(fieldName, false, false, false, intType); | 1092 ElementFactory.fieldElement(fieldName, false, false, false, intType); |
| 1091 classA.fields = <FieldElement>[field]; | 1093 classA.fields = <FieldElement>[field]; |
| 1092 classA.accessors = <PropertyAccessorElement>[field.getter, field.setter]; | 1094 classA.accessors = <PropertyAccessorElement>[field.getter, field.setter]; |
| 1093 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); | 1095 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); |
| 1094 AstTestFactory.assignmentExpression( | 1096 AstTestFactory.assignmentExpression( |
| 1095 node, TokenType.EQ, AstTestFactory.integer(0)); | 1097 node, TokenType.EQ, AstTestFactory.integer(0)); |
| 1096 _resolveInClass(node, classA); | 1098 _resolveInClass(node, classA); |
| 1097 Element element = node.staticElement; | 1099 Element element = node.staticElement; |
| 1098 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, | 1100 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, |
| 1099 PropertyAccessorElement, element); | 1101 PropertyAccessorElement, element); |
| 1100 expect((element as PropertyAccessorElement).isSetter, isTrue); | 1102 expect((element as PropertyAccessorElement).isSetter, isTrue); |
| 1101 _listener.assertNoErrors(); | 1103 _listener.assertNoErrors(); |
| 1102 } | 1104 } |
| 1103 | 1105 |
| 1104 void test_visitSuperConstructorInvocation() { | 1106 test_visitSuperConstructorInvocation() async { |
| 1105 ClassElementImpl superclass = ElementFactory.classElement2("A"); | 1107 ClassElementImpl superclass = ElementFactory.classElement2("A"); |
| 1106 ConstructorElementImpl superConstructor = | 1108 ConstructorElementImpl superConstructor = |
| 1107 ElementFactory.constructorElement2(superclass, null); | 1109 ElementFactory.constructorElement2(superclass, null); |
| 1108 superclass.constructors = <ConstructorElement>[superConstructor]; | 1110 superclass.constructors = <ConstructorElement>[superConstructor]; |
| 1109 ClassElementImpl subclass = | 1111 ClassElementImpl subclass = |
| 1110 ElementFactory.classElement("B", superclass.type); | 1112 ElementFactory.classElement("B", superclass.type); |
| 1111 ConstructorElementImpl subConstructor = | 1113 ConstructorElementImpl subConstructor = |
| 1112 ElementFactory.constructorElement2(subclass, null); | 1114 ElementFactory.constructorElement2(subclass, null); |
| 1113 subclass.constructors = <ConstructorElement>[subConstructor]; | 1115 subclass.constructors = <ConstructorElement>[subConstructor]; |
| 1114 SuperConstructorInvocation invocation = | 1116 SuperConstructorInvocation invocation = |
| 1115 AstTestFactory.superConstructorInvocation(); | 1117 AstTestFactory.superConstructorInvocation(); |
| 1116 AstTestFactory.classDeclaration(null, 'C', null, null, null, null, [ | 1118 AstTestFactory.classDeclaration(null, 'C', null, null, null, null, [ |
| 1117 AstTestFactory.constructorDeclaration(null, 'C', null, [invocation]) | 1119 AstTestFactory.constructorDeclaration(null, 'C', null, [invocation]) |
| 1118 ]); | 1120 ]); |
| 1119 _resolveInClass(invocation, subclass); | 1121 _resolveInClass(invocation, subclass); |
| 1120 expect(invocation.staticElement, superConstructor); | 1122 expect(invocation.staticElement, superConstructor); |
| 1121 _listener.assertNoErrors(); | 1123 _listener.assertNoErrors(); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| 1124 void test_visitSuperConstructorInvocation_namedParameter() { | 1126 test_visitSuperConstructorInvocation_namedParameter() async { |
| 1125 ClassElementImpl superclass = ElementFactory.classElement2("A"); | 1127 ClassElementImpl superclass = ElementFactory.classElement2("A"); |
| 1126 ConstructorElementImpl superConstructor = | 1128 ConstructorElementImpl superConstructor = |
| 1127 ElementFactory.constructorElement2(superclass, null); | 1129 ElementFactory.constructorElement2(superclass, null); |
| 1128 String parameterName = "p"; | 1130 String parameterName = "p"; |
| 1129 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 1131 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 1130 superConstructor.parameters = <ParameterElement>[parameter]; | 1132 superConstructor.parameters = <ParameterElement>[parameter]; |
| 1131 superclass.constructors = <ConstructorElement>[superConstructor]; | 1133 superclass.constructors = <ConstructorElement>[superConstructor]; |
| 1132 ClassElementImpl subclass = | 1134 ClassElementImpl subclass = |
| 1133 ElementFactory.classElement("B", superclass.type); | 1135 ElementFactory.classElement("B", superclass.type); |
| 1134 ConstructorElementImpl subConstructor = | 1136 ConstructorElementImpl subConstructor = |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 innerScope = new LabelScope( | 1296 innerScope = new LabelScope( |
| 1295 outerScope, labelElement.name, labelTarget, labelElement); | 1297 outerScope, labelElement.name, labelTarget, labelElement); |
| 1296 } | 1298 } |
| 1297 _visitor.labelScope = innerScope; | 1299 _visitor.labelScope = innerScope; |
| 1298 statement.accept(_resolver); | 1300 statement.accept(_resolver); |
| 1299 } finally { | 1301 } finally { |
| 1300 _visitor.labelScope = outerScope; | 1302 _visitor.labelScope = outerScope; |
| 1301 } | 1303 } |
| 1302 } | 1304 } |
| 1303 } | 1305 } |
| OLD | NEW |