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 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 // prepare "A.m" | 294 // prepare "A.m" |
295 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'm'); | 295 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'm'); |
296 CommentReference commentReference = new CommentReference(null, prefixed); | 296 CommentReference commentReference = new CommentReference(null, prefixed); |
297 // resolve | 297 // resolve |
298 _resolveNode(commentReference); | 298 _resolveNode(commentReference); |
299 expect(prefixed.prefix.staticElement, classA); | 299 expect(prefixed.prefix.staticElement, classA); |
300 expect(prefixed.identifier.staticElement, method); | 300 expect(prefixed.identifier.staticElement, method); |
301 _listener.assertNoErrors(); | 301 _listener.assertNoErrors(); |
302 } | 302 } |
303 | 303 |
304 void test_visitCommentReference_prefixedIdentifier_class_operator() { | |
305 ClassElementImpl classA = ElementFactory.classElement2("A"); | |
306 // set method | |
307 MethodElement method = | |
308 ElementFactory.methodElement("==", _typeProvider.boolType); | |
309 classA.methods = <MethodElement>[method]; | |
310 // set name scope | |
311 _visitor.nameScope = new EnclosedScope(null) | |
312 ..defineNameWithoutChecking('A', classA); | |
313 // prepare "A.m" | |
scheglov
2016/07/21 15:38:13
"A.=="
Brian Wilkerson
2016/07/21 15:43:44
Done
| |
314 PrefixedIdentifier prefixed = AstFactory.identifier5('A', '=='); | |
315 CommentReference commentReference = new CommentReference(null, prefixed); | |
316 // resolve | |
317 _resolveNode(commentReference); | |
318 expect(prefixed.prefix.staticElement, classA); | |
319 expect(prefixed.identifier.staticElement, method); | |
320 _listener.assertNoErrors(); | |
321 } | |
322 | |
304 void test_visitConstructorName_named() { | 323 void test_visitConstructorName_named() { |
305 ClassElementImpl classA = ElementFactory.classElement2("A"); | 324 ClassElementImpl classA = ElementFactory.classElement2("A"); |
306 String constructorName = "a"; | 325 String constructorName = "a"; |
307 ConstructorElement constructor = | 326 ConstructorElement constructor = |
308 ElementFactory.constructorElement2(classA, constructorName); | 327 ElementFactory.constructorElement2(classA, constructorName); |
309 classA.constructors = <ConstructorElement>[constructor]; | 328 classA.constructors = <ConstructorElement>[constructor]; |
310 ConstructorName name = AstFactory.constructorName( | 329 ConstructorName name = AstFactory.constructorName( |
311 AstFactory.typeName(classA), constructorName); | 330 AstFactory.typeName(classA), constructorName); |
312 _resolveNode(name); | 331 _resolveNode(name); |
313 expect(name.staticElement, same(constructor)); | 332 expect(name.staticElement, same(constructor)); |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 _visitor.labelScope = innerScope; | 1021 _visitor.labelScope = innerScope; |
1003 statement.accept(_resolver); | 1022 statement.accept(_resolver); |
1004 } finally { | 1023 } finally { |
1005 _visitor.labelScope = outerScope; | 1024 _visitor.labelScope = outerScope; |
1006 } | 1025 } |
1007 } catch (exception) { | 1026 } catch (exception) { |
1008 throw new IllegalArgumentException("Could not resolve node", exception); | 1027 throw new IllegalArgumentException("Could not resolve node", exception); |
1009 } | 1028 } |
1010 } | 1029 } |
1011 } | 1030 } |
OLD | NEW |