| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 11 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 11 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 12 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart'; | |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 14 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/generated/source_io.dart'; | 16 import 'package:analyzer/src/generated/source_io.dart'; |
| 17 import 'package:analyzer/src/summary/base.dart'; | 17 import 'package:analyzer/src/summary/base.dart'; |
| 18 import 'package:analyzer/src/summary/idl.dart'; | 18 import 'package:analyzer/src/summary/idl.dart'; |
| 19 import 'package:analyzer/src/summary/public_namespace_computer.dart' | 19 import 'package:analyzer/src/summary/public_namespace_computer.dart' |
| 20 as public_namespace; | 20 as public_namespace; |
| 21 import 'package:analyzer/src/summary/summarize_elements.dart' | 21 import 'package:analyzer/src/summary/summarize_elements.dart' |
| 22 as summarize_elements; | 22 as summarize_elements; |
| 23 import 'package:path/path.dart' show posix; | 23 import 'package:path/path.dart' show posix; |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 UnlinkedClass cls = serializeClassText('class C {}'); | 1300 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1301 expect(cls.isAbstract, false); | 1301 expect(cls.isAbstract, false); |
| 1302 expect(cls.isMixinApplication, false); | 1302 expect(cls.isMixinApplication, false); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 test_class_no_interface() { | 1305 test_class_no_interface() { |
| 1306 UnlinkedClass cls = serializeClassText('class C {}'); | 1306 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1307 expect(cls.interfaces, isEmpty); | 1307 expect(cls.interfaces, isEmpty); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 test_unresolved_import() { | |
| 1311 allowMissingFiles = true; | |
| 1312 serializeLibraryText("import 'foo.dart';", allowErrors: true); | |
| 1313 expect(unlinkedUnits[0].imports, hasLength(2)); | |
| 1314 expect(unlinkedUnits[0].imports[0].uri, 'foo.dart'); | |
| 1315 // Note: imports[1] is the implicit import of dart:core. | |
| 1316 expect(unlinkedUnits[0].imports[1].isImplicit, true); | |
| 1317 expect(linked.importDependencies, hasLength(2)); | |
| 1318 checkDependency( | |
| 1319 linked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 1320 } | |
| 1321 | |
| 1322 test_unresolved_export() { | |
| 1323 allowMissingFiles = true; | |
| 1324 serializeLibraryText("export 'foo.dart';", allowErrors: true); | |
| 1325 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | |
| 1326 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'foo.dart'); | |
| 1327 expect(linked.exportDependencies, hasLength(1)); | |
| 1328 checkDependency( | |
| 1329 linked.exportDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 1330 } | |
| 1331 | |
| 1332 test_unresolved_part() { | |
| 1333 allowMissingFiles = true; | |
| 1334 serializeLibraryText("part 'foo.dart';", allowErrors: true); | |
| 1335 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); | |
| 1336 expect(unlinkedUnits[0].publicNamespace.parts[0], 'foo.dart'); | |
| 1337 } | |
| 1338 | |
| 1339 test_class_no_mixins() { | 1310 test_class_no_mixins() { |
| 1340 UnlinkedClass cls = serializeClassText('class C {}'); | 1311 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1341 expect(cls.mixins, isEmpty); | 1312 expect(cls.mixins, isEmpty); |
| 1342 } | 1313 } |
| 1343 | 1314 |
| 1344 test_class_no_type_param() { | 1315 test_class_no_type_param() { |
| 1345 UnlinkedClass cls = serializeClassText('class C {}'); | 1316 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1346 expect(cls.typeParameters, isEmpty); | 1317 expect(cls.typeParameters, isEmpty); |
| 1347 } | 1318 } |
| 1348 | 1319 |
| (...skipping 8717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10066 expect(type.typeParameters[0].name, 'T'); | 10037 expect(type.typeParameters[0].name, 'T'); |
| 10067 expect(type.typeParameters[1].name, 'U'); | 10038 expect(type.typeParameters[1].name, 'U'); |
| 10068 } | 10039 } |
| 10069 | 10040 |
| 10070 test_unit_codeRange() { | 10041 test_unit_codeRange() { |
| 10071 serializeLibraryText(' int a = 1; '); | 10042 serializeLibraryText(' int a = 1; '); |
| 10072 UnlinkedUnit unit = unlinkedUnits[0]; | 10043 UnlinkedUnit unit = unlinkedUnits[0]; |
| 10073 _assertCodeRange(unit.codeRange, 0, 14); | 10044 _assertCodeRange(unit.codeRange, 0, 14); |
| 10074 } | 10045 } |
| 10075 | 10046 |
| 10047 test_unresolved_export() { |
| 10048 allowMissingFiles = true; |
| 10049 serializeLibraryText("export 'foo.dart';", allowErrors: true); |
| 10050 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 10051 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'foo.dart'); |
| 10052 expect(linked.exportDependencies, hasLength(1)); |
| 10053 checkDependency( |
| 10054 linked.exportDependencies[0], absUri('/foo.dart'), 'foo.dart'); |
| 10055 } |
| 10056 |
| 10057 test_unresolved_import() { |
| 10058 allowMissingFiles = true; |
| 10059 serializeLibraryText("import 'foo.dart';", allowErrors: true); |
| 10060 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 10061 expect(unlinkedUnits[0].imports[0].uri, 'foo.dart'); |
| 10062 // Note: imports[1] is the implicit import of dart:core. |
| 10063 expect(unlinkedUnits[0].imports[1].isImplicit, true); |
| 10064 expect(linked.importDependencies, hasLength(2)); |
| 10065 checkDependency( |
| 10066 linked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); |
| 10067 } |
| 10068 |
| 10069 test_unresolved_part() { |
| 10070 allowMissingFiles = true; |
| 10071 serializeLibraryText("part 'foo.dart';", allowErrors: true); |
| 10072 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); |
| 10073 expect(unlinkedUnits[0].publicNamespace.parts[0], 'foo.dart'); |
| 10074 } |
| 10075 |
| 10076 test_unresolved_reference_in_multiple_parts() { | 10076 test_unresolved_reference_in_multiple_parts() { |
| 10077 addNamedSource('/a.dart', 'part of foo; int x; Unresolved y;'); | 10077 addNamedSource('/a.dart', 'part of foo; int x; Unresolved y;'); |
| 10078 serializeLibraryText('library foo; part "a.dart"; Unresolved z;', | 10078 serializeLibraryText('library foo; part "a.dart"; Unresolved z;', |
| 10079 allowErrors: true); | 10079 allowErrors: true); |
| 10080 // The unresolved types in the defining compilation unit and the part | 10080 // The unresolved types in the defining compilation unit and the part |
| 10081 // should both work correctly even though they use different reference | 10081 // should both work correctly even though they use different reference |
| 10082 // indices. | 10082 // indices. |
| 10083 checkUnresolvedTypeRef( | 10083 checkUnresolvedTypeRef( |
| 10084 unlinkedUnits[0].variables[0].type, null, 'Unresolved'); | 10084 unlinkedUnits[0].variables[0].type, null, 'Unresolved'); |
| 10085 checkUnresolvedTypeRef( | 10085 checkUnresolvedTypeRef( |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10487 class _PrefixExpectation { | 10487 class _PrefixExpectation { |
| 10488 final ReferenceKind kind; | 10488 final ReferenceKind kind; |
| 10489 final String name; | 10489 final String name; |
| 10490 final String absoluteUri; | 10490 final String absoluteUri; |
| 10491 final String relativeUri; | 10491 final String relativeUri; |
| 10492 final int numTypeParameters; | 10492 final int numTypeParameters; |
| 10493 | 10493 |
| 10494 _PrefixExpectation(this.kind, this.name, | 10494 _PrefixExpectation(this.kind, this.name, |
| 10495 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10495 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 10496 } | 10496 } |
| OLD | NEW |