OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 expect(breakStatement.target, same(whileStatement)); | 1414 expect(breakStatement.target, same(whileStatement)); |
1415 _listener.assertNoErrors(); | 1415 _listener.assertNoErrors(); |
1416 } | 1416 } |
1417 | 1417 |
1418 void test_visitBreakStatement_withoutLabel() { | 1418 void test_visitBreakStatement_withoutLabel() { |
1419 BreakStatement statement = AstFactory.breakStatement(); | 1419 BreakStatement statement = AstFactory.breakStatement(); |
1420 _resolveStatement(statement, null, null); | 1420 _resolveStatement(statement, null, null); |
1421 _listener.assertNoErrors(); | 1421 _listener.assertNoErrors(); |
1422 } | 1422 } |
1423 | 1423 |
| 1424 void test_visitCommentReference_prefixedIdentifier_class_getter() { |
| 1425 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1426 // set accessors |
| 1427 String propName = "p"; |
| 1428 PropertyAccessorElement getter = |
| 1429 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
| 1430 PropertyAccessorElement setter = |
| 1431 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
| 1432 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
| 1433 // set name scope |
| 1434 _visitor.nameScope = new EnclosedScope(null) |
| 1435 ..defineNameWithoutChecking('A', classA); |
| 1436 // prepare "A.p" |
| 1437 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'p'); |
| 1438 CommentReference commentReference = new CommentReference(null, prefixed); |
| 1439 // resolve |
| 1440 _resolveNode(commentReference); |
| 1441 expect(prefixed.prefix.staticElement, classA); |
| 1442 expect(prefixed.identifier.staticElement, getter); |
| 1443 _listener.assertNoErrors(); |
| 1444 } |
| 1445 |
| 1446 void test_visitCommentReference_prefixedIdentifier_class_method() { |
| 1447 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 1448 // set method |
| 1449 MethodElement method = |
| 1450 ElementFactory.methodElement("m", _typeProvider.intType); |
| 1451 classA.methods = <MethodElement>[method]; |
| 1452 // set name scope |
| 1453 _visitor.nameScope = new EnclosedScope(null) |
| 1454 ..defineNameWithoutChecking('A', classA); |
| 1455 // prepare "A.m" |
| 1456 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'm'); |
| 1457 CommentReference commentReference = new CommentReference(null, prefixed); |
| 1458 // resolve |
| 1459 _resolveNode(commentReference); |
| 1460 expect(prefixed.prefix.staticElement, classA); |
| 1461 expect(prefixed.identifier.staticElement, method); |
| 1462 _listener.assertNoErrors(); |
| 1463 } |
| 1464 |
1424 void test_visitConstructorName_named() { | 1465 void test_visitConstructorName_named() { |
1425 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1466 ClassElementImpl classA = ElementFactory.classElement2("A"); |
1426 String constructorName = "a"; | 1467 String constructorName = "a"; |
1427 ConstructorElement constructor = | 1468 ConstructorElement constructor = |
1428 ElementFactory.constructorElement2(classA, constructorName); | 1469 ElementFactory.constructorElement2(classA, constructorName); |
1429 classA.constructors = <ConstructorElement>[constructor]; | 1470 classA.constructors = <ConstructorElement>[constructor]; |
1430 ConstructorName name = AstFactory.constructorName( | 1471 ConstructorName name = AstFactory.constructorName( |
1431 AstFactory.typeName(classA), constructorName); | 1472 AstFactory.typeName(classA), constructorName); |
1432 _resolveNode(name); | 1473 _resolveNode(name); |
1433 expect(name.staticElement, same(constructor)); | 1474 expect(name.staticElement, same(constructor)); |
(...skipping 14655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16089 | 16130 |
16090 void _resolveTestUnit(String code) { | 16131 void _resolveTestUnit(String code) { |
16091 testCode = code; | 16132 testCode = code; |
16092 testSource = addSource(testCode); | 16133 testSource = addSource(testCode); |
16093 LibraryElement library = resolve2(testSource); | 16134 LibraryElement library = resolve2(testSource); |
16094 assertNoErrors(testSource); | 16135 assertNoErrors(testSource); |
16095 verify([testSource]); | 16136 verify([testSource]); |
16096 testUnit = resolveCompilationUnit(testSource, library); | 16137 testUnit = resolveCompilationUnit(testSource, library); |
16097 } | 16138 } |
16098 } | 16139 } |
OLD | NEW |