| 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_test; | 5 library analyzer.test.src.summary.summary_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (namespace == null) { | 169 if (namespace == null) { |
| 170 namespace = uriToPublicNamespace[absoluteUri]; | 170 namespace = uriToPublicNamespace[absoluteUri]; |
| 171 } | 171 } |
| 172 if (namespace == null && !allowMissingFiles) { | 172 if (namespace == null && !allowMissingFiles) { |
| 173 fail('Prelinker unexpectedly requested namespace for "$relativeUri"' | 173 fail('Prelinker unexpectedly requested namespace for "$relativeUri"' |
| 174 ' (resolves to "$absoluteUri").' | 174 ' (resolves to "$absoluteUri").' |
| 175 ' Namespaces available: ${uriToPublicNamespace.keys}'); | 175 ' Namespaces available: ${uriToPublicNamespace.keys}'); |
| 176 } | 176 } |
| 177 return namespace; | 177 return namespace; |
| 178 } | 178 } |
| 179 prelinked = new PrelinkedLibrary.fromBuffer( | 179 linked = new LinkedLibrary.fromBuffer( |
| 180 prelink(unlinkedUnits[0], getPart, getImport).toBuffer()); | 180 prelink(unlinkedUnits[0], getPart, getImport).toBuffer()); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * Override of [SummaryTest] which creates summaries from the element model. | 185 * Override of [SummaryTest] which creates summaries from the element model. |
| 186 */ | 186 */ |
| 187 @reflectiveTest | 187 @reflectiveTest |
| 188 class SummarizeElementsTest extends ResolverTestCase with SummaryTest { | 188 class SummarizeElementsTest extends ResolverTestCase with SummaryTest { |
| 189 /** | 189 /** |
| (...skipping 25 matching lines...) Expand all Loading... |
| 215 * Serialize the library containing the given class [element], then | 215 * Serialize the library containing the given class [element], then |
| 216 * deserialize it and return the summary of the class. | 216 * deserialize it and return the summary of the class. |
| 217 */ | 217 */ |
| 218 UnlinkedClass serializeClassElement(ClassElement element) { | 218 UnlinkedClass serializeClassElement(ClassElement element) { |
| 219 serializeLibraryElement(element.library); | 219 serializeLibraryElement(element.library); |
| 220 return findClass(element.name, failIfAbsent: true); | 220 return findClass(element.name, failIfAbsent: true); |
| 221 } | 221 } |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * Serialize the given [library] element, then deserialize it and store the | 224 * Serialize the given [library] element, then deserialize it and store the |
| 225 * resulting summary in [prelinked] and [unlinkedUnits]. | 225 * resulting summary in [linked] and [unlinkedUnits]. |
| 226 */ | 226 */ |
| 227 void serializeLibraryElement(LibraryElement library) { | 227 void serializeLibraryElement(LibraryElement library) { |
| 228 summarize_elements.LibrarySerializationResult serializedLib = | 228 summarize_elements.LibrarySerializationResult serializedLib = |
| 229 summarize_elements.serializeLibrary(library, typeProvider); | 229 summarize_elements.serializeLibrary(library, typeProvider); |
| 230 { | 230 { |
| 231 List<int> buffer = serializedLib.prelinked.toBuffer(); | 231 List<int> buffer = serializedLib.linked.toBuffer(); |
| 232 prelinked = new PrelinkedLibrary.fromBuffer(buffer); | 232 linked = new LinkedLibrary.fromBuffer(buffer); |
| 233 } | 233 } |
| 234 unlinkedUnits = serializedLib.unlinkedUnits.map((UnlinkedUnitBuilder b) { | 234 unlinkedUnits = serializedLib.unlinkedUnits.map((UnlinkedUnitBuilder b) { |
| 235 List<int> buffer = b.toBuffer(); | 235 List<int> buffer = b.toBuffer(); |
| 236 return new UnlinkedUnit.fromBuffer(buffer); | 236 return new UnlinkedUnit.fromBuffer(buffer); |
| 237 }).toList(); | 237 }).toList(); |
| 238 unitUris = serializedLib.unitUris; | 238 unitUris = serializedLib.unitUris; |
| 239 } | 239 } |
| 240 | 240 |
| 241 @override | 241 @override |
| 242 void serializeLibraryText(String text, {bool allowErrors: false}) { | 242 void serializeLibraryText(String text, {bool allowErrors: false}) { |
| 243 Source source = addSource(text); | 243 Source source = addSource(text); |
| 244 _fileContents[source] = text; | 244 _fileContents[source] = text; |
| 245 LibraryElement library = resolve2(source); | 245 LibraryElement library = resolve2(source); |
| 246 if (!allowErrors) { | 246 if (!allowErrors) { |
| 247 assertNoErrors(source); | 247 assertNoErrors(source); |
| 248 } | 248 } |
| 249 serializeLibraryElement(library); | 249 serializeLibraryElement(library); |
| 250 expect( | 250 expect(unlinkedUnits[0].imports.length, linked.importDependencies.length); |
| 251 unlinkedUnits[0].imports.length, prelinked.importDependencies.length); | 251 expect(linked.units.length, unlinkedUnits.length); |
| 252 expect(prelinked.units.length, unlinkedUnits.length); | 252 for (int i = 0; i < linked.units.length; i++) { |
| 253 for (int i = 0; i < prelinked.units.length; i++) { | |
| 254 expect(unlinkedUnits[i].references.length, | 253 expect(unlinkedUnits[i].references.length, |
| 255 prelinked.units[i].references.length); | 254 linked.units[i].references.length); |
| 256 } | 255 } |
| 257 verifyPublicNamespace(); | 256 verifyPublicNamespace(); |
| 258 } | 257 } |
| 259 | 258 |
| 260 @override | 259 @override |
| 261 void setUp() { | 260 void setUp() { |
| 262 super.setUp(); | 261 super.setUp(); |
| 263 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 262 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 264 options.enableGenericMethods = true; | 263 options.enableGenericMethods = true; |
| 265 resetWithOptions(options); | 264 resetWithOptions(options); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 296 } | 295 } |
| 297 | 296 |
| 298 /** | 297 /** |
| 299 * Base class containing most summary tests. This allows summary tests to be | 298 * Base class containing most summary tests. This allows summary tests to be |
| 300 * re-used to exercise all the different ways in which summaries can be | 299 * re-used to exercise all the different ways in which summaries can be |
| 301 * generated (e.g. direct from the AST, from the element model, from a | 300 * generated (e.g. direct from the AST, from the element model, from a |
| 302 * "relinking" process, etc.) | 301 * "relinking" process, etc.) |
| 303 */ | 302 */ |
| 304 abstract class SummaryTest { | 303 abstract class SummaryTest { |
| 305 /** | 304 /** |
| 306 * Prelinked summary that results from serializing and then deserializing the | 305 * Linked summary that results from serializing and then deserializing the |
| 307 * library under test. | 306 * library under test. |
| 308 */ | 307 */ |
| 309 PrelinkedLibrary prelinked; | 308 LinkedLibrary linked; |
| 310 | 309 |
| 311 /** | 310 /** |
| 312 * Unlinked compilation unit summaries that result from serializing and | 311 * Unlinked compilation unit summaries that result from serializing and |
| 313 * deserializing the library under test. | 312 * deserializing the library under test. |
| 314 */ | 313 */ |
| 315 List<UnlinkedUnit> unlinkedUnits; | 314 List<UnlinkedUnit> unlinkedUnits; |
| 316 | 315 |
| 317 /** | 316 /** |
| 318 * A test will set this to `true` if it contains `import`, `export`, or | 317 * A test will set this to `true` if it contains `import`, `export`, or |
| 319 * `part` declarations that deliberately refer to non-existent files. | 318 * `part` declarations that deliberately refer to non-existent files. |
| 320 */ | 319 */ |
| 321 bool allowMissingFiles = false; | 320 bool allowMissingFiles = false; |
| 322 | 321 |
| 323 /** | 322 /** |
| 324 * `true` if the summary was created directly from the AST (and hence | 323 * `true` if the summary was created directly from the AST (and hence |
| 325 * contains information that is not obtainable from the element model alone). | 324 * contains information that is not obtainable from the element model alone). |
| 326 * TODO(paulberry): modify the element model so that it contains all the data | 325 * TODO(paulberry): modify the element model so that it contains all the data |
| 327 * that summaries need, so that this flag is no longer needed. | 326 * that summaries need, so that this flag is no longer needed. |
| 328 */ | 327 */ |
| 329 bool get checkAstDerivedData; | 328 bool get checkAstDerivedData; |
| 330 | 329 |
| 331 /** | 330 /** |
| 332 * Get access to the prelinked defining compilation unit. | 331 * Get access to the linked defining compilation unit. |
| 333 */ | 332 */ |
| 334 PrelinkedUnit get definingUnit => prelinked.units[0]; | 333 LinkedUnit get definingUnit => linked.units[0]; |
| 335 | 334 |
| 336 /** | 335 /** |
| 337 * `true` if the prelinked portion of the summary is expected to contain | 336 * `true` if the linked portion of the summary is expected to contain |
| 338 * absolute URIs. This happens because the element model doesn't (yet) store | 337 * absolute URIs. This happens because the element model doesn't (yet) store |
| 339 * enough information to recover relative URIs, TODO(paulberry): fix this. | 338 * enough information to recover relative URIs, TODO(paulberry): fix this. |
| 340 */ | 339 */ |
| 341 bool get expectAbsoluteUrisInDependencies; | 340 bool get expectAbsoluteUrisInDependencies; |
| 342 | 341 |
| 343 /** | 342 /** |
| 344 * Convert [path] to a suitably formatted absolute path URI for the current | 343 * Convert [path] to a suitably formatted absolute path URI for the current |
| 345 * platform. | 344 * platform. |
| 346 */ | 345 */ |
| 347 String absUri(String path) { | 346 String absUri(String path) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 359 * a file reachable via the given [absoluteUri] and [relativeUri]. | 358 * a file reachable via the given [absoluteUri] and [relativeUri]. |
| 360 */ | 359 */ |
| 361 void checkDependency(int dependency, String absoluteUri, String relativeUri) { | 360 void checkDependency(int dependency, String absoluteUri, String relativeUri) { |
| 362 if (expectAbsoluteUrisInDependencies) { | 361 if (expectAbsoluteUrisInDependencies) { |
| 363 // The element model doesn't (yet) store enough information to recover | 362 // The element model doesn't (yet) store enough information to recover |
| 364 // relative URIs, so we have to use the absolute URI. | 363 // relative URIs, so we have to use the absolute URI. |
| 365 // TODO(paulberry): fix this. | 364 // TODO(paulberry): fix this. |
| 366 relativeUri = absoluteUri; | 365 relativeUri = absoluteUri; |
| 367 } | 366 } |
| 368 expect(dependency, new isInstanceOf<int>()); | 367 expect(dependency, new isInstanceOf<int>()); |
| 369 expect(prelinked.dependencies[dependency].uri, relativeUri); | 368 expect(linked.dependencies[dependency].uri, relativeUri); |
| 370 } | 369 } |
| 371 | 370 |
| 372 /** | 371 /** |
| 373 * Verify that the given [dependency] lists the given [absoluteUris] or | 372 * Verify that the given [dependency] lists the given [absoluteUris] or |
| 374 * [relativeUris] as its parts. | 373 * [relativeUris] as its parts. |
| 375 */ | 374 */ |
| 376 void checkDependencyParts(PrelinkedDependency dependency, | 375 void checkDependencyParts(LinkedDependency dependency, |
| 377 List<String> absoluteUris, List<String> relativeUris) { | 376 List<String> absoluteUris, List<String> relativeUris) { |
| 378 if (expectAbsoluteUrisInDependencies) { | 377 if (expectAbsoluteUrisInDependencies) { |
| 379 // The element model doesn't (yet) store enough information to recover | 378 // The element model doesn't (yet) store enough information to recover |
| 380 // relative URIs, so we have to use the absolute URI. | 379 // relative URIs, so we have to use the absolute URI. |
| 381 // TODO(paulberry): fix this. | 380 // TODO(paulberry): fix this. |
| 382 relativeUris = absoluteUris; | 381 relativeUris = absoluteUris; |
| 383 } | 382 } |
| 384 expect(dependency.parts, relativeUris); | 383 expect(dependency.parts, relativeUris); |
| 385 } | 384 } |
| 386 | 385 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 415 } | 414 } |
| 416 | 415 |
| 417 /** | 416 /** |
| 418 * Verify that the given [exportName] represents a reference to an entity | 417 * Verify that the given [exportName] represents a reference to an entity |
| 419 * declared in a file reachable via [absoluteUri] and [relativeUri], having | 418 * declared in a file reachable via [absoluteUri] and [relativeUri], having |
| 420 * name [expectedName]. [expectedKind] is the kind of object referenced. | 419 * name [expectedName]. [expectedKind] is the kind of object referenced. |
| 421 * [expectedTargetUnit] is the index of the compilation unit in which the | 420 * [expectedTargetUnit] is the index of the compilation unit in which the |
| 422 * target of the [exportName] is expected to appear; if not specified it is | 421 * target of the [exportName] is expected to appear; if not specified it is |
| 423 * assumed to be the defining compilation unit. | 422 * assumed to be the defining compilation unit. |
| 424 */ | 423 */ |
| 425 void checkExportName( | 424 void checkExportName(LinkedExportName exportName, String absoluteUri, |
| 426 PrelinkedExportName exportName, | 425 String relativeUri, String expectedName, ReferenceKind expectedKind, |
| 427 String absoluteUri, | |
| 428 String relativeUri, | |
| 429 String expectedName, | |
| 430 PrelinkedReferenceKind expectedKind, | |
| 431 {int expectedTargetUnit: 0}) { | 426 {int expectedTargetUnit: 0}) { |
| 432 expect(exportName, new isInstanceOf<PrelinkedExportName>()); | 427 expect(exportName, new isInstanceOf<LinkedExportName>()); |
| 433 // Exported names must come from other libraries. | 428 // Exported names must come from other libraries. |
| 434 expect(exportName.dependency, isNot(0)); | 429 expect(exportName.dependency, isNot(0)); |
| 435 checkDependency(exportName.dependency, absoluteUri, relativeUri); | 430 checkDependency(exportName.dependency, absoluteUri, relativeUri); |
| 436 expect(exportName.name, expectedName); | 431 expect(exportName.name, expectedName); |
| 437 expect(exportName.kind, expectedKind); | 432 expect(exportName.kind, expectedKind); |
| 438 expect(exportName.unit, expectedTargetUnit); | 433 expect(exportName.unit, expectedTargetUnit); |
| 439 } | 434 } |
| 440 | 435 |
| 441 /** | 436 /** |
| 442 * Verify that the dependency table contains an entry for a file reachable | 437 * Verify that the dependency table contains an entry for a file reachable |
| 443 * via the given [absoluteUri] and [relativeUri]. | 438 * via the given [absoluteUri] and [relativeUri]. |
| 444 * | 439 * |
| 445 * The [PrelinkedDependency] is returned. | 440 * The [LinkedDependency] is returned. |
| 446 */ | 441 */ |
| 447 PrelinkedDependency checkHasDependency( | 442 LinkedDependency checkHasDependency(String absoluteUri, String relativeUri) { |
| 448 String absoluteUri, String relativeUri) { | |
| 449 if (expectAbsoluteUrisInDependencies) { | 443 if (expectAbsoluteUrisInDependencies) { |
| 450 // The element model doesn't (yet) store enough information to recover | 444 // The element model doesn't (yet) store enough information to recover |
| 451 // relative URIs, so we have to use the absolute URI. | 445 // relative URIs, so we have to use the absolute URI. |
| 452 // TODO(paulberry): fix this. | 446 // TODO(paulberry): fix this. |
| 453 relativeUri = absoluteUri; | 447 relativeUri = absoluteUri; |
| 454 } | 448 } |
| 455 List<String> found = <String>[]; | 449 List<String> found = <String>[]; |
| 456 for (PrelinkedDependency dep in prelinked.dependencies) { | 450 for (LinkedDependency dep in linked.dependencies) { |
| 457 if (dep.uri == relativeUri) { | 451 if (dep.uri == relativeUri) { |
| 458 return dep; | 452 return dep; |
| 459 } | 453 } |
| 460 found.add(dep.uri); | 454 found.add(dep.uri); |
| 461 } | 455 } |
| 462 fail('Did not find dependency $relativeUri. Found: $found'); | 456 fail('Did not find dependency $relativeUri. Found: $found'); |
| 463 return null; | 457 return null; |
| 464 } | 458 } |
| 465 | 459 |
| 466 /** | 460 /** |
| 467 * Verify that the dependency table *does not* contain any entries for a file | 461 * Verify that the dependency table *does not* contain any entries for a file |
| 468 * reachable via the given [absoluteUri] and [relativeUri]. | 462 * reachable via the given [absoluteUri] and [relativeUri]. |
| 469 */ | 463 */ |
| 470 void checkLacksDependency(String absoluteUri, String relativeUri) { | 464 void checkLacksDependency(String absoluteUri, String relativeUri) { |
| 471 if (expectAbsoluteUrisInDependencies) { | 465 if (expectAbsoluteUrisInDependencies) { |
| 472 // The element model doesn't (yet) store enough information to recover | 466 // The element model doesn't (yet) store enough information to recover |
| 473 // relative URIs, so we have to use the absolute URI. | 467 // relative URIs, so we have to use the absolute URI. |
| 474 // TODO(paulberry): fix this. | 468 // TODO(paulberry): fix this. |
| 475 relativeUri = absoluteUri; | 469 relativeUri = absoluteUri; |
| 476 } | 470 } |
| 477 for (PrelinkedDependency dep in prelinked.dependencies) { | 471 for (LinkedDependency dep in linked.dependencies) { |
| 478 if (dep.uri == relativeUri) { | 472 if (dep.uri == relativeUri) { |
| 479 fail('Unexpected dependency found: $relativeUri'); | 473 fail('Unexpected dependency found: $relativeUri'); |
| 480 } | 474 } |
| 481 } | 475 } |
| 482 } | 476 } |
| 483 | 477 |
| 484 /** | 478 /** |
| 485 * Verify that the given [typeRef] represents a reference to a type parameter | 479 * Verify that the given [typeRef] represents a reference to a type parameter |
| 486 * having the given [deBruijnIndex]. | 480 * having the given [deBruijnIndex]. |
| 487 */ | 481 */ |
| 488 void checkParamTypeRef(UnlinkedTypeRef typeRef, int deBruijnIndex) { | 482 void checkParamTypeRef(UnlinkedTypeRef typeRef, int deBruijnIndex) { |
| 489 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); | 483 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); |
| 490 expect(typeRef.reference, 0); | 484 expect(typeRef.reference, 0); |
| 491 expect(typeRef.typeArguments, isEmpty); | 485 expect(typeRef.typeArguments, isEmpty); |
| 492 expect(typeRef.paramReference, deBruijnIndex); | 486 expect(typeRef.paramReference, deBruijnIndex); |
| 493 } | 487 } |
| 494 | 488 |
| 495 /** | 489 /** |
| 496 * Verify that [prefixReference] is a valid reference to a prefix having the | 490 * Verify that [prefixReference] is a valid reference to a prefix having the |
| 497 * given [name]. | 491 * given [name]. |
| 498 */ | 492 */ |
| 499 void checkPrefix(int prefixReference, String name) { | 493 void checkPrefix(int prefixReference, String name) { |
| 500 expect(prefixReference, isNot(0)); | 494 expect(prefixReference, isNot(0)); |
| 501 expect(unlinkedUnits[0].references[prefixReference].prefixReference, 0); | 495 expect(unlinkedUnits[0].references[prefixReference].prefixReference, 0); |
| 502 expect(unlinkedUnits[0].references[prefixReference].name, name); | 496 expect(unlinkedUnits[0].references[prefixReference].name, name); |
| 503 expect(definingUnit.references[prefixReference].dependency, 0); | 497 expect(definingUnit.references[prefixReference].dependency, 0); |
| 504 expect(definingUnit.references[prefixReference].kind, | 498 expect(definingUnit.references[prefixReference].kind, ReferenceKind.prefix); |
| 505 PrelinkedReferenceKind.prefix); | |
| 506 expect(definingUnit.references[prefixReference].unit, 0); | 499 expect(definingUnit.references[prefixReference].unit, 0); |
| 507 } | 500 } |
| 508 | 501 |
| 509 /** | 502 /** |
| 510 * Verify that the given [typeRef] represents a reference to a type declared | 503 * Verify that the given [typeRef] represents a reference to a type declared |
| 511 * in a file reachable via [absoluteUri] and [relativeUri], having name | 504 * in a file reachable via [absoluteUri] and [relativeUri], having name |
| 512 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is | 505 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is |
| 513 * reached via the given prefix. If [allowTypeParameters] is true, allow the | 506 * reached via the given prefix. If [allowTypeParameters] is true, allow the |
| 514 * type reference to supply type parameters. [expectedKind] is the kind of | 507 * type reference to supply type parameters. [expectedKind] is the kind of |
| 515 * object referenced. [prelinkedSourceUnit] and [unlinkedSourceUnit] refer | 508 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer |
| 516 * to the compilation unit within which the [typeRef] appears; if not | 509 * to the compilation unit within which the [typeRef] appears; if not |
| 517 * specified they are assumed to refer to the defining compilation unit. | 510 * specified they are assumed to refer to the defining compilation unit. |
| 518 * [expectedTargetUnit] is the index of the compilation unit in which the | 511 * [expectedTargetUnit] is the index of the compilation unit in which the |
| 519 * target of the [typeRef] is expected to appear; if not specified it is | 512 * target of the [typeRef] is expected to appear; if not specified it is |
| 520 * assumed to be the defining compilation unit. [numTypeParameters] is the | 513 * assumed to be the defining compilation unit. [numTypeParameters] is the |
| 521 * number of type parameters of the thing being referred to. | 514 * number of type parameters of the thing being referred to. |
| 522 */ | 515 */ |
| 523 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri, | 516 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri, |
| 524 String relativeUri, String expectedName, | 517 String relativeUri, String expectedName, |
| 525 {String expectedPrefix, | 518 {String expectedPrefix, |
| 526 bool allowTypeParameters: false, | 519 bool allowTypeParameters: false, |
| 527 PrelinkedReferenceKind expectedKind: PrelinkedReferenceKind.classOrEnum, | 520 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 528 int expectedTargetUnit: 0, | 521 int expectedTargetUnit: 0, |
| 529 PrelinkedUnit prelinkedSourceUnit, | 522 LinkedUnit linkedSourceUnit, |
| 530 UnlinkedUnit unlinkedSourceUnit, | 523 UnlinkedUnit unlinkedSourceUnit, |
| 531 int numTypeParameters: 0}) { | 524 int numTypeParameters: 0}) { |
| 532 prelinkedSourceUnit ??= definingUnit; | 525 linkedSourceUnit ??= definingUnit; |
| 533 unlinkedSourceUnit ??= unlinkedUnits[0]; | 526 unlinkedSourceUnit ??= unlinkedUnits[0]; |
| 534 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); | 527 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); |
| 535 expect(typeRef.paramReference, 0); | 528 expect(typeRef.paramReference, 0); |
| 536 int index = typeRef.reference; | 529 int index = typeRef.reference; |
| 537 UnlinkedReference reference = unlinkedSourceUnit.references[index]; | 530 UnlinkedReference reference = unlinkedSourceUnit.references[index]; |
| 538 PrelinkedReference referenceResolution = | 531 LinkedReference referenceResolution = linkedSourceUnit.references[index]; |
| 539 prelinkedSourceUnit.references[index]; | |
| 540 if (index == 0) { | 532 if (index == 0) { |
| 541 // Index 0 is reserved for "dynamic". | 533 // Index 0 is reserved for "dynamic". |
| 542 expect(reference.name, isEmpty); | 534 expect(reference.name, isEmpty); |
| 543 expect(reference.prefixReference, 0); | 535 expect(reference.prefixReference, 0); |
| 544 } | 536 } |
| 545 if (absoluteUri == null) { | 537 if (absoluteUri == null) { |
| 546 expect(referenceResolution.dependency, 0); | 538 expect(referenceResolution.dependency, 0); |
| 547 } else { | 539 } else { |
| 548 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); | 540 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); |
| 549 } | 541 } |
| 550 if (!allowTypeParameters) { | 542 if (!allowTypeParameters) { |
| 551 expect(typeRef.typeArguments, isEmpty); | 543 expect(typeRef.typeArguments, isEmpty); |
| 552 } | 544 } |
| 553 if (expectedKind == PrelinkedReferenceKind.unresolved) { | 545 if (expectedKind == ReferenceKind.unresolved) { |
| 554 // summarize_elements.dart isn't yet able to record the name of | 546 // summarize_elements.dart isn't yet able to record the name of |
| 555 // unresolved references. TODO(paulberry): fix this. | 547 // unresolved references. TODO(paulberry): fix this. |
| 556 expect(reference.name, '*unresolved*'); | 548 expect(reference.name, '*unresolved*'); |
| 557 } else if (expectedName == null) { | 549 } else if (expectedName == null) { |
| 558 expect(reference.name, isEmpty); | 550 expect(reference.name, isEmpty); |
| 559 } else { | 551 } else { |
| 560 expect(reference.name, expectedName); | 552 expect(reference.name, expectedName); |
| 561 } | 553 } |
| 562 if (expectedPrefix == null) { | 554 if (expectedPrefix == null) { |
| 563 expect(reference.prefixReference, 0); | 555 expect(reference.prefixReference, 0); |
| 564 } else { | 556 } else { |
| 565 checkPrefix(reference.prefixReference, expectedPrefix); | 557 checkPrefix(reference.prefixReference, expectedPrefix); |
| 566 } | 558 } |
| 567 expect(referenceResolution.kind, expectedKind); | 559 expect(referenceResolution.kind, expectedKind); |
| 568 expect(referenceResolution.unit, expectedTargetUnit); | 560 expect(referenceResolution.unit, expectedTargetUnit); |
| 569 expect(referenceResolution.numTypeParameters, numTypeParameters); | 561 expect(referenceResolution.numTypeParameters, numTypeParameters); |
| 570 } | 562 } |
| 571 | 563 |
| 572 /** | 564 /** |
| 573 * Verify that the given [typeRef] represents a reference to an unresolved | 565 * Verify that the given [typeRef] represents a reference to an unresolved |
| 574 * type. | 566 * type. |
| 575 */ | 567 */ |
| 576 void checkUnresolvedTypeRef( | 568 void checkUnresolvedTypeRef( |
| 577 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) { | 569 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) { |
| 578 // When serializing from the element model, unresolved type refs lose their | 570 // When serializing from the element model, unresolved type refs lose their |
| 579 // name. | 571 // name. |
| 580 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, | 572 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, |
| 581 expectedPrefix: expectedPrefix, | 573 expectedPrefix: expectedPrefix, expectedKind: ReferenceKind.unresolved); |
| 582 expectedKind: PrelinkedReferenceKind.unresolved); | |
| 583 } | |
| 584 | |
| 585 test_dependencies_export_to_export_unused() { | |
| 586 // TODO(paulberry): fix this test. | |
| 587 addNamedSource('/a.dart', 'export "b.dart";'); | |
| 588 addNamedSource('/b.dart', ''); | |
| 589 serializeLibraryText('export "a.dart";'); | |
| 590 // The main test library depends on b.dart, even though it doesn't | |
| 591 // re-export any names defined in b.dart, because a change to b.dart might | |
| 592 // cause it to start exporting a name that the main test library *does* | |
| 593 // use. | |
| 594 checkHasDependency(absUri('/b.dart'), 'b.dart'); | |
| 595 } | |
| 596 | |
| 597 test_dependencies_export_unused() { | |
| 598 // TODO(paulberry): fix this test. | |
| 599 addNamedSource('/a.dart', ''); | |
| 600 serializeLibraryText('export "a.dart";'); | |
| 601 // The main test library depends on a.dart, even though it doesn't | |
| 602 // re-export any names defined in a.dart, because a change to a.dart might | |
| 603 // cause it to start exporting a name that the main test library *will* | |
| 604 // re-export. | |
| 605 checkHasDependency(absUri('/a.dart'), 'a.dart'); | |
| 606 } | 574 } |
| 607 | 575 |
| 608 fail_enum_value_documented() { | 576 fail_enum_value_documented() { |
| 609 // TODO(paulberry): currently broken because of dartbug.com/25385 | 577 // TODO(paulberry): currently broken because of dartbug.com/25385 |
| 610 String text = ''' | 578 String text = ''' |
| 611 enum E { | 579 enum E { |
| 612 /** | 580 /** |
| 613 * Docs | 581 * Docs |
| 614 */ | 582 */ |
| 615 v | 583 v |
| 616 }'''; | 584 }'''; |
| 617 UnlinkedEnumValue value = serializeEnumText(text).values[0]; | 585 UnlinkedEnumValue value = serializeEnumText(text).values[0]; |
| 618 expect(value.documentationComment, isNotNull); | 586 expect(value.documentationComment, isNotNull); |
| 619 checkDocumentationComment(value.documentationComment, text); | 587 checkDocumentationComment(value.documentationComment, text); |
| 620 } | 588 } |
| 621 | 589 |
| 622 fail_test_import_missing() { | 590 fail_test_import_missing() { |
| 623 // TODO(paulberry): At the moment unresolved imports are not included in | 591 // TODO(paulberry): At the moment unresolved imports are not included in |
| 624 // the element model, so we can't pass this test. | 592 // the element model, so we can't pass this test. |
| 625 // Unresolved imports are included since this is necessary for proper | 593 // Unresolved imports are included since this is necessary for proper |
| 626 // dependency tracking. | 594 // dependency tracking. |
| 627 allowMissingFiles = true; | 595 allowMissingFiles = true; |
| 628 serializeLibraryText('import "foo.dart";', allowErrors: true); | 596 serializeLibraryText('import "foo.dart";', allowErrors: true); |
| 629 // Second import is the implicit import of dart:core | 597 // Second import is the implicit import of dart:core |
| 630 expect(unlinkedUnits[0].imports, hasLength(2)); | 598 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 631 checkDependency( | 599 checkDependency( |
| 632 prelinked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); | 600 linked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); |
| 633 } | 601 } |
| 634 | 602 |
| 635 fail_type_reference_to_nonexistent_file_via_prefix() { | 603 fail_type_reference_to_nonexistent_file_via_prefix() { |
| 636 // TODO(paulberry): this test currently fails because there is not enough | 604 // TODO(paulberry): this test currently fails because there is not enough |
| 637 // information in the element model to figure out that the unresolved | 605 // information in the element model to figure out that the unresolved |
| 638 // reference `p.C` uses the prefix `p`. | 606 // reference `p.C` uses the prefix `p`. |
| 639 allowMissingFiles = true; | 607 allowMissingFiles = true; |
| 640 UnlinkedTypeRef typeRef = serializeTypeText('p.C', | 608 UnlinkedTypeRef typeRef = serializeTypeText('p.C', |
| 641 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true); | 609 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true); |
| 642 checkUnresolvedTypeRef(typeRef, 'p', 'C'); | 610 checkUnresolvedTypeRef(typeRef, 'p', 'C'); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 'abstract class C = D with E; class D {} class E {}'); | 970 'abstract class C = D with E; class D {} class E {}'); |
| 1003 expect(cls.isAbstract, true); | 971 expect(cls.isAbstract, true); |
| 1004 } | 972 } |
| 1005 | 973 |
| 1006 test_class_alias_concrete() { | 974 test_class_alias_concrete() { |
| 1007 UnlinkedClass cls = | 975 UnlinkedClass cls = |
| 1008 serializeClassText('class C = _D with _E; class _D {} class _E {}'); | 976 serializeClassText('class C = _D with _E; class _D {} class _E {}'); |
| 1009 expect(cls.isAbstract, false); | 977 expect(cls.isAbstract, false); |
| 1010 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 978 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1011 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 979 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1012 PrelinkedReferenceKind.classOrEnum); | 980 ReferenceKind.classOrEnum); |
| 1013 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); | 981 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
| 1014 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 982 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 1015 } | 983 } |
| 1016 | 984 |
| 1017 test_class_alias_documented() { | 985 test_class_alias_documented() { |
| 1018 String text = ''' | 986 String text = ''' |
| 1019 // Extra comment so doc comment offset != 0 | 987 // Extra comment so doc comment offset != 0 |
| 1020 /** | 988 /** |
| 1021 * Docs | 989 * Docs |
| 1022 */ | 990 */ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 serializeClassText('class C = D with E; class D {} class E {}'); | 1057 serializeClassText('class C = D with E; class D {} class E {}'); |
| 1090 checkTypeRef(cls.supertype, null, null, 'D'); | 1058 checkTypeRef(cls.supertype, null, null, 'D'); |
| 1091 expect(cls.hasNoSupertype, isFalse); | 1059 expect(cls.hasNoSupertype, isFalse); |
| 1092 } | 1060 } |
| 1093 | 1061 |
| 1094 test_class_concrete() { | 1062 test_class_concrete() { |
| 1095 UnlinkedClass cls = serializeClassText('class C {}'); | 1063 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1096 expect(cls.isAbstract, false); | 1064 expect(cls.isAbstract, false); |
| 1097 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1065 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1098 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 1066 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1099 PrelinkedReferenceKind.classOrEnum); | 1067 ReferenceKind.classOrEnum); |
| 1100 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); | 1068 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
| 1101 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 1069 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 1102 } | 1070 } |
| 1103 | 1071 |
| 1104 test_class_documented() { | 1072 test_class_documented() { |
| 1105 String text = ''' | 1073 String text = ''' |
| 1106 // Extra comment so doc comment offset != 0 | 1074 // Extra comment so doc comment offset != 0 |
| 1107 /** | 1075 /** |
| 1108 * Docs | 1076 * Docs |
| 1109 */ | 1077 */ |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 executables: serializeClassText('class C { C(); }').executables); | 1463 executables: serializeClassText('class C { C(); }').executables); |
| 1496 expect(executable.returnType, isNull); | 1464 expect(executable.returnType, isNull); |
| 1497 } | 1465 } |
| 1498 | 1466 |
| 1499 test_constructor_return_type_parameterized() { | 1467 test_constructor_return_type_parameterized() { |
| 1500 UnlinkedExecutable executable = findExecutable('', | 1468 UnlinkedExecutable executable = findExecutable('', |
| 1501 executables: serializeClassText('class C<T, U> { C(); }').executables); | 1469 executables: serializeClassText('class C<T, U> { C(); }').executables); |
| 1502 expect(executable.returnType, isNull); | 1470 expect(executable.returnType, isNull); |
| 1503 } | 1471 } |
| 1504 | 1472 |
| 1473 test_dependencies_export_to_export_unused() { |
| 1474 // TODO(paulberry): fix this test. |
| 1475 addNamedSource('/a.dart', 'export "b.dart";'); |
| 1476 addNamedSource('/b.dart', ''); |
| 1477 serializeLibraryText('export "a.dart";'); |
| 1478 // The main test library depends on b.dart, even though it doesn't |
| 1479 // re-export any names defined in b.dart, because a change to b.dart might |
| 1480 // cause it to start exporting a name that the main test library *does* |
| 1481 // use. |
| 1482 checkHasDependency(absUri('/b.dart'), 'b.dart'); |
| 1483 } |
| 1484 |
| 1485 test_dependencies_export_unused() { |
| 1486 // TODO(paulberry): fix this test. |
| 1487 addNamedSource('/a.dart', ''); |
| 1488 serializeLibraryText('export "a.dart";'); |
| 1489 // The main test library depends on a.dart, even though it doesn't |
| 1490 // re-export any names defined in a.dart, because a change to a.dart might |
| 1491 // cause it to start exporting a name that the main test library *will* |
| 1492 // re-export. |
| 1493 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1494 } |
| 1495 |
| 1505 test_dependencies_import_to_export() { | 1496 test_dependencies_import_to_export() { |
| 1506 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); | 1497 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); |
| 1507 addNamedSource('/b.dart', 'library b;'); | 1498 addNamedSource('/b.dart', 'library b;'); |
| 1508 serializeLibraryText('import "a.dart"; A a;'); | 1499 serializeLibraryText('import "a.dart"; A a;'); |
| 1509 checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1500 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1510 // The main test library depends on b.dart, because names defined in | 1501 // The main test library depends on b.dart, because names defined in |
| 1511 // b.dart are exported by a.dart. | 1502 // b.dart are exported by a.dart. |
| 1512 checkHasDependency(absUri('/b.dart'), 'b.dart'); | 1503 checkHasDependency(absUri('/b.dart'), 'b.dart'); |
| 1513 } | 1504 } |
| 1514 | 1505 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 // start exporting a name that the main test library *does* use. | 1584 // start exporting a name that the main test library *does* use. |
| 1594 checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1585 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1595 } | 1586 } |
| 1596 | 1587 |
| 1597 test_dependencies_parts() { | 1588 test_dependencies_parts() { |
| 1598 addNamedSource( | 1589 addNamedSource( |
| 1599 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); | 1590 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); |
| 1600 addNamedSource('/b.dart', 'part of a;'); | 1591 addNamedSource('/b.dart', 'part of a;'); |
| 1601 addNamedSource('/c.dart', 'part of a;'); | 1592 addNamedSource('/c.dart', 'part of a;'); |
| 1602 serializeLibraryText('import "a.dart"; A a;'); | 1593 serializeLibraryText('import "a.dart"; A a;'); |
| 1603 PrelinkedDependency dep = checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1594 LinkedDependency dep = checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1604 checkDependencyParts( | 1595 checkDependencyParts( |
| 1605 dep, [absUri('/b.dart'), absUri('/c.dart')], ['b.dart', 'c.dart']); | 1596 dep, [absUri('/b.dart'), absUri('/c.dart')], ['b.dart', 'c.dart']); |
| 1606 } | 1597 } |
| 1607 | 1598 |
| 1608 test_dependencies_parts_relative_to_importing_library() { | 1599 test_dependencies_parts_relative_to_importing_library() { |
| 1609 addNamedSource('/a/b.dart', 'export "c/d.dart";'); | 1600 addNamedSource('/a/b.dart', 'export "c/d.dart";'); |
| 1610 addNamedSource('/a/c/d.dart', | 1601 addNamedSource('/a/c/d.dart', |
| 1611 'library d; part "e/f.dart"; part "g/h.dart"; class D {}'); | 1602 'library d; part "e/f.dart"; part "g/h.dart"; class D {}'); |
| 1612 addNamedSource('/a/c/e/f.dart', 'part of d;'); | 1603 addNamedSource('/a/c/e/f.dart', 'part of d;'); |
| 1613 addNamedSource('/a/c/g/h.dart', 'part of d;'); | 1604 addNamedSource('/a/c/g/h.dart', 'part of d;'); |
| 1614 serializeLibraryText('import "a/b.dart"; D d;'); | 1605 serializeLibraryText('import "a/b.dart"; D d;'); |
| 1615 PrelinkedDependency dep = | 1606 LinkedDependency dep = |
| 1616 checkHasDependency(absUri('/a/c/d.dart'), 'a/c/d.dart'); | 1607 checkHasDependency(absUri('/a/c/d.dart'), 'a/c/d.dart'); |
| 1617 checkDependencyParts( | 1608 checkDependencyParts( |
| 1618 dep, | 1609 dep, |
| 1619 [absUri('/a/c/e/f.dart'), absUri('/a/c/g/h.dart')], | 1610 [absUri('/a/c/e/f.dart'), absUri('/a/c/g/h.dart')], |
| 1620 ['a/c/e/f.dart', 'a/c/g/h.dart']); | 1611 ['a/c/e/f.dart', 'a/c/g/h.dart']); |
| 1621 } | 1612 } |
| 1622 | 1613 |
| 1623 test_elements_in_part() { | 1614 test_elements_in_part() { |
| 1624 addNamedSource( | 1615 addNamedSource( |
| 1625 '/part1.dart', | 1616 '/part1.dart', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1644 test_enum() { | 1635 test_enum() { |
| 1645 String text = 'enum E { v1 }'; | 1636 String text = 'enum E { v1 }'; |
| 1646 UnlinkedEnum e = serializeEnumText(text); | 1637 UnlinkedEnum e = serializeEnumText(text); |
| 1647 expect(e.name, 'E'); | 1638 expect(e.name, 'E'); |
| 1648 expect(e.nameOffset, text.indexOf('E')); | 1639 expect(e.nameOffset, text.indexOf('E')); |
| 1649 expect(e.values, hasLength(1)); | 1640 expect(e.values, hasLength(1)); |
| 1650 expect(e.values[0].name, 'v1'); | 1641 expect(e.values[0].name, 'v1'); |
| 1651 expect(e.values[0].nameOffset, text.indexOf('v1')); | 1642 expect(e.values[0].nameOffset, text.indexOf('v1')); |
| 1652 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1643 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1653 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 1644 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1654 PrelinkedReferenceKind.classOrEnum); | 1645 ReferenceKind.classOrEnum); |
| 1655 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E'); | 1646 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E'); |
| 1656 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 1647 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 1657 } | 1648 } |
| 1658 | 1649 |
| 1659 test_enum_documented() { | 1650 test_enum_documented() { |
| 1660 String text = ''' | 1651 String text = ''' |
| 1661 // Extra comment so doc comment offset != 0 | 1652 // Extra comment so doc comment offset != 0 |
| 1662 /** | 1653 /** |
| 1663 * Docs | 1654 * Docs |
| 1664 */ | 1655 */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1695 test_executable_function() { | 1686 test_executable_function() { |
| 1696 String text = ' f() {}'; | 1687 String text = ' f() {}'; |
| 1697 UnlinkedExecutable executable = serializeExecutableText(text); | 1688 UnlinkedExecutable executable = serializeExecutableText(text); |
| 1698 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 1689 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 1699 expect(executable.hasImplicitReturnType, isTrue); | 1690 expect(executable.hasImplicitReturnType, isTrue); |
| 1700 checkDynamicTypeRef(executable.returnType); | 1691 checkDynamicTypeRef(executable.returnType); |
| 1701 expect(executable.isExternal, isFalse); | 1692 expect(executable.isExternal, isFalse); |
| 1702 expect(executable.nameOffset, text.indexOf('f')); | 1693 expect(executable.nameOffset, text.indexOf('f')); |
| 1703 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1694 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1704 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 1695 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1705 PrelinkedReferenceKind.topLevelFunction); | 1696 ReferenceKind.topLevelFunction); |
| 1706 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); | 1697 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); |
| 1707 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 1698 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 1708 } | 1699 } |
| 1709 | 1700 |
| 1710 test_executable_function_explicit_return() { | 1701 test_executable_function_explicit_return() { |
| 1711 UnlinkedExecutable executable = | 1702 UnlinkedExecutable executable = |
| 1712 serializeExecutableText('dynamic f() => null;'); | 1703 serializeExecutableText('dynamic f() => null;'); |
| 1713 expect(executable.hasImplicitReturnType, isFalse); | 1704 expect(executable.hasImplicitReturnType, isFalse); |
| 1714 checkDynamicTypeRef(executable.returnType); | 1705 checkDynamicTypeRef(executable.returnType); |
| 1715 } | 1706 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1728 String text = 'int get f => 1;'; | 1719 String text = 'int get f => 1;'; |
| 1729 UnlinkedExecutable executable = serializeExecutableText(text); | 1720 UnlinkedExecutable executable = serializeExecutableText(text); |
| 1730 expect(executable.kind, UnlinkedExecutableKind.getter); | 1721 expect(executable.kind, UnlinkedExecutableKind.getter); |
| 1731 expect(executable.hasImplicitReturnType, isFalse); | 1722 expect(executable.hasImplicitReturnType, isFalse); |
| 1732 expect(executable.isExternal, isFalse); | 1723 expect(executable.isExternal, isFalse); |
| 1733 expect(executable.nameOffset, text.indexOf('f')); | 1724 expect(executable.nameOffset, text.indexOf('f')); |
| 1734 expect(findVariable('f'), isNull); | 1725 expect(findVariable('f'), isNull); |
| 1735 expect(findExecutable('f='), isNull); | 1726 expect(findExecutable('f='), isNull); |
| 1736 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 1727 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 1737 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 1728 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 1738 PrelinkedReferenceKind.topLevelPropertyAccessor); | 1729 ReferenceKind.topLevelPropertyAccessor); |
| 1739 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); | 1730 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); |
| 1740 } | 1731 } |
| 1741 | 1732 |
| 1742 test_executable_getter_external() { | 1733 test_executable_getter_external() { |
| 1743 UnlinkedExecutable executable = | 1734 UnlinkedExecutable executable = |
| 1744 serializeExecutableText('external int get f;'); | 1735 serializeExecutableText('external int get f;'); |
| 1745 expect(executable.isExternal, isTrue); | 1736 expect(executable.isExternal, isTrue); |
| 1746 } | 1737 } |
| 1747 | 1738 |
| 1748 test_executable_getter_private() { | 1739 test_executable_getter_private() { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 String text = 'void set f(value) {}'; | 2049 String text = 'void set f(value) {}'; |
| 2059 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); | 2050 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); |
| 2060 expect(executable.kind, UnlinkedExecutableKind.setter); | 2051 expect(executable.kind, UnlinkedExecutableKind.setter); |
| 2061 expect(executable.hasImplicitReturnType, isFalse); | 2052 expect(executable.hasImplicitReturnType, isFalse); |
| 2062 expect(executable.isExternal, isFalse); | 2053 expect(executable.isExternal, isFalse); |
| 2063 expect(executable.nameOffset, text.indexOf('f')); | 2054 expect(executable.nameOffset, text.indexOf('f')); |
| 2064 expect(findVariable('f'), isNull); | 2055 expect(findVariable('f'), isNull); |
| 2065 expect(findExecutable('f'), isNull); | 2056 expect(findExecutable('f'), isNull); |
| 2066 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 2057 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 2067 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 2058 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 2068 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2059 ReferenceKind.topLevelPropertyAccessor); |
| 2069 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f='); | 2060 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f='); |
| 2070 } | 2061 } |
| 2071 | 2062 |
| 2072 test_executable_setter_external() { | 2063 test_executable_setter_external() { |
| 2073 UnlinkedExecutable executable = | 2064 UnlinkedExecutable executable = |
| 2074 serializeExecutableText('external void set f(value);', 'f='); | 2065 serializeExecutableText('external void set f(value);', 'f='); |
| 2075 expect(executable.isExternal, isTrue); | 2066 expect(executable.isExternal, isTrue); |
| 2076 } | 2067 } |
| 2077 | 2068 |
| 2078 test_executable_setter_implicit_return() { | 2069 test_executable_setter_implicit_return() { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 } | 2139 } |
| 2149 | 2140 |
| 2150 test_executable_type_param_in_return_type_method() { | 2141 test_executable_type_param_in_return_type_method() { |
| 2151 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); | 2142 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); |
| 2152 checkParamTypeRef(ex.returnType, 1); | 2143 checkParamTypeRef(ex.returnType, 1); |
| 2153 } | 2144 } |
| 2154 | 2145 |
| 2155 test_export_class() { | 2146 test_export_class() { |
| 2156 addNamedSource('/a.dart', 'class C {}'); | 2147 addNamedSource('/a.dart', 'class C {}'); |
| 2157 serializeLibraryText('export "a.dart";'); | 2148 serializeLibraryText('export "a.dart";'); |
| 2158 expect(prelinked.exportNames, hasLength(1)); | 2149 expect(linked.exportNames, hasLength(1)); |
| 2159 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', | 2150 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', |
| 2160 PrelinkedReferenceKind.classOrEnum); | 2151 ReferenceKind.classOrEnum); |
| 2161 } | 2152 } |
| 2162 | 2153 |
| 2163 test_export_class_alias() { | 2154 test_export_class_alias() { |
| 2164 addNamedSource( | 2155 addNamedSource( |
| 2165 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}'); | 2156 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}'); |
| 2166 serializeLibraryText('export "a.dart";'); | 2157 serializeLibraryText('export "a.dart";'); |
| 2167 expect(prelinked.exportNames, hasLength(1)); | 2158 expect(linked.exportNames, hasLength(1)); |
| 2168 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', | 2159 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', |
| 2169 PrelinkedReferenceKind.classOrEnum); | 2160 ReferenceKind.classOrEnum); |
| 2170 } | 2161 } |
| 2171 | 2162 |
| 2172 test_export_enum() { | 2163 test_export_enum() { |
| 2173 addNamedSource('/a.dart', 'enum E { v }'); | 2164 addNamedSource('/a.dart', 'enum E { v }'); |
| 2174 serializeLibraryText('export "a.dart";'); | 2165 serializeLibraryText('export "a.dart";'); |
| 2175 expect(prelinked.exportNames, hasLength(1)); | 2166 expect(linked.exportNames, hasLength(1)); |
| 2176 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'E', | 2167 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'E', |
| 2177 PrelinkedReferenceKind.classOrEnum); | 2168 ReferenceKind.classOrEnum); |
| 2178 } | 2169 } |
| 2179 | 2170 |
| 2180 test_export_from_part() { | 2171 test_export_from_part() { |
| 2181 addNamedSource('/a.dart', 'library foo; part "b.dart";'); | 2172 addNamedSource('/a.dart', 'library foo; part "b.dart";'); |
| 2182 addNamedSource('/b.dart', 'part of foo; f() {}'); | 2173 addNamedSource('/b.dart', 'part of foo; f() {}'); |
| 2183 serializeLibraryText('export "a.dart";'); | 2174 serializeLibraryText('export "a.dart";'); |
| 2184 expect(prelinked.exportNames, hasLength(1)); | 2175 expect(linked.exportNames, hasLength(1)); |
| 2185 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2176 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2186 PrelinkedReferenceKind.topLevelFunction, | 2177 ReferenceKind.topLevelFunction, |
| 2187 expectedTargetUnit: 1); | 2178 expectedTargetUnit: 1); |
| 2188 } | 2179 } |
| 2189 | 2180 |
| 2190 test_export_function() { | 2181 test_export_function() { |
| 2191 addNamedSource('/a.dart', 'f() {}'); | 2182 addNamedSource('/a.dart', 'f() {}'); |
| 2192 serializeLibraryText('export "a.dart";'); | 2183 serializeLibraryText('export "a.dart";'); |
| 2193 expect(prelinked.exportNames, hasLength(1)); | 2184 expect(linked.exportNames, hasLength(1)); |
| 2194 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2185 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2195 PrelinkedReferenceKind.topLevelFunction); | 2186 ReferenceKind.topLevelFunction); |
| 2196 } | 2187 } |
| 2197 | 2188 |
| 2198 test_export_getter() { | 2189 test_export_getter() { |
| 2199 addNamedSource('/a.dart', 'get f => null'); | 2190 addNamedSource('/a.dart', 'get f => null'); |
| 2200 serializeLibraryText('export "a.dart";'); | 2191 serializeLibraryText('export "a.dart";'); |
| 2201 expect(prelinked.exportNames, hasLength(1)); | 2192 expect(linked.exportNames, hasLength(1)); |
| 2202 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2193 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2203 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2194 ReferenceKind.topLevelPropertyAccessor); |
| 2204 } | 2195 } |
| 2205 | 2196 |
| 2206 test_export_hide() { | 2197 test_export_hide() { |
| 2207 addNamedSource('/a.dart', 'f() {} g() {}'); | 2198 addNamedSource('/a.dart', 'f() {} g() {}'); |
| 2208 serializeLibraryText('export "a.dart" hide g;'); | 2199 serializeLibraryText('export "a.dart" hide g;'); |
| 2209 expect(prelinked.exportNames, hasLength(1)); | 2200 expect(linked.exportNames, hasLength(1)); |
| 2210 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2201 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2211 PrelinkedReferenceKind.topLevelFunction); | 2202 ReferenceKind.topLevelFunction); |
| 2212 } | 2203 } |
| 2213 | 2204 |
| 2214 test_export_hide_order() { | 2205 test_export_hide_order() { |
| 2215 serializeLibraryText('export "dart:async" hide Future, Stream;'); | 2206 serializeLibraryText('export "dart:async" hide Future, Stream;'); |
| 2216 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 2207 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 2217 expect( | 2208 expect( |
| 2218 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); | 2209 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); |
| 2219 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, | 2210 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, |
| 2220 isEmpty); | 2211 isEmpty); |
| 2221 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, | 2212 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, |
| 2222 hasLength(2)); | 2213 hasLength(2)); |
| 2223 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[0], | 2214 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[0], |
| 2224 'Future'); | 2215 'Future'); |
| 2225 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1], | 2216 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1], |
| 2226 'Stream'); | 2217 'Stream'); |
| 2227 expect(prelinked.exportNames, isNotEmpty); | 2218 expect(linked.exportNames, isNotEmpty); |
| 2228 } | 2219 } |
| 2229 | 2220 |
| 2230 test_export_names_excludes_names_from_library() { | 2221 test_export_names_excludes_names_from_library() { |
| 2231 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;'); | 2222 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;'); |
| 2232 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;'); | 2223 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;'); |
| 2233 expect(prelinked.exportNames, isEmpty); | 2224 expect(linked.exportNames, isEmpty); |
| 2234 } | 2225 } |
| 2235 | 2226 |
| 2236 test_export_no_combinators() { | 2227 test_export_no_combinators() { |
| 2237 serializeLibraryText('export "dart:async";'); | 2228 serializeLibraryText('export "dart:async";'); |
| 2238 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 2229 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 2239 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty); | 2230 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty); |
| 2240 } | 2231 } |
| 2241 | 2232 |
| 2242 test_export_not_shadowed_by_prefix() { | 2233 test_export_not_shadowed_by_prefix() { |
| 2243 addNamedSource('/a.dart', 'f() {}'); | 2234 addNamedSource('/a.dart', 'f() {}'); |
| 2244 serializeLibraryText('export "a.dart"; import "dart:core" as f; f.int _x;'); | 2235 serializeLibraryText('export "a.dart"; import "dart:core" as f; f.int _x;'); |
| 2245 expect(prelinked.exportNames, hasLength(1)); | 2236 expect(linked.exportNames, hasLength(1)); |
| 2246 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2237 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2247 PrelinkedReferenceKind.topLevelFunction); | 2238 ReferenceKind.topLevelFunction); |
| 2248 } | 2239 } |
| 2249 | 2240 |
| 2250 test_export_offset() { | 2241 test_export_offset() { |
| 2251 String libraryText = ' export "dart:async";'; | 2242 String libraryText = ' export "dart:async";'; |
| 2252 serializeLibraryText(libraryText); | 2243 serializeLibraryText(libraryText); |
| 2253 expect(unlinkedUnits[0].exports[0].uriOffset, | 2244 expect(unlinkedUnits[0].exports[0].uriOffset, |
| 2254 libraryText.indexOf('"dart:async"')); | 2245 libraryText.indexOf('"dart:async"')); |
| 2255 expect(unlinkedUnits[0].exports[0].uriEnd, libraryText.indexOf(';')); | 2246 expect(unlinkedUnits[0].exports[0].uriEnd, libraryText.indexOf(';')); |
| 2256 expect(unlinkedUnits[0].exports[0].offset, libraryText.indexOf('export')); | 2247 expect(unlinkedUnits[0].exports[0].offset, libraryText.indexOf('export')); |
| 2257 } | 2248 } |
| 2258 | 2249 |
| 2259 test_export_private() { | 2250 test_export_private() { |
| 2260 // Private names should not be exported. | 2251 // Private names should not be exported. |
| 2261 addNamedSource('/a.dart', '_f() {}'); | 2252 addNamedSource('/a.dart', '_f() {}'); |
| 2262 serializeLibraryText('export "a.dart";'); | 2253 serializeLibraryText('export "a.dart";'); |
| 2263 expect(prelinked.exportNames, isEmpty); | 2254 expect(linked.exportNames, isEmpty); |
| 2264 } | 2255 } |
| 2265 | 2256 |
| 2266 test_export_setter() { | 2257 test_export_setter() { |
| 2267 addNamedSource('/a.dart', 'void set f(value) {}'); | 2258 addNamedSource('/a.dart', 'void set f(value) {}'); |
| 2268 serializeLibraryText('export "a.dart";'); | 2259 serializeLibraryText('export "a.dart";'); |
| 2269 expect(prelinked.exportNames, hasLength(1)); | 2260 expect(linked.exportNames, hasLength(1)); |
| 2270 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f=', | 2261 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f=', |
| 2271 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2262 ReferenceKind.topLevelPropertyAccessor); |
| 2272 } | 2263 } |
| 2273 | 2264 |
| 2274 test_export_shadowed() { | 2265 test_export_shadowed() { |
| 2275 // f() is not shown in exportNames because it is already defined at top | 2266 // f() is not shown in exportNames because it is already defined at top |
| 2276 // level in the library. | 2267 // level in the library. |
| 2277 addNamedSource('/a.dart', 'f() {}'); | 2268 addNamedSource('/a.dart', 'f() {}'); |
| 2278 serializeLibraryText('export "a.dart"; f() {}'); | 2269 serializeLibraryText('export "a.dart"; f() {}'); |
| 2279 expect(prelinked.exportNames, isEmpty); | 2270 expect(linked.exportNames, isEmpty); |
| 2280 } | 2271 } |
| 2281 | 2272 |
| 2282 test_export_shadowed_variable() { | 2273 test_export_shadowed_variable() { |
| 2283 // Neither `v` nor `v=` is shown in exportNames because both are defined at | 2274 // Neither `v` nor `v=` is shown in exportNames because both are defined at |
| 2284 // top level in the library by the declaration `var v;`. | 2275 // top level in the library by the declaration `var v;`. |
| 2285 addNamedSource('/a.dart', 'var v;'); | 2276 addNamedSource('/a.dart', 'var v;'); |
| 2286 serializeLibraryText('export "a.dart"; var v;'); | 2277 serializeLibraryText('export "a.dart"; var v;'); |
| 2287 expect(prelinked.exportNames, isEmpty); | 2278 expect(linked.exportNames, isEmpty); |
| 2288 } | 2279 } |
| 2289 | 2280 |
| 2290 test_export_shadowed_variable_const() { | 2281 test_export_shadowed_variable_const() { |
| 2291 // `v=` is shown in exportNames because the top level declaration | 2282 // `v=` is shown in exportNames because the top level declaration |
| 2292 // `const v = 0;` only shadows `v`, not `v=`. | 2283 // `const v = 0;` only shadows `v`, not `v=`. |
| 2293 addNamedSource('/a.dart', 'var v;'); | 2284 addNamedSource('/a.dart', 'var v;'); |
| 2294 serializeLibraryText('export "a.dart"; const v = 0;'); | 2285 serializeLibraryText('export "a.dart"; const v = 0;'); |
| 2295 expect(prelinked.exportNames, hasLength(1)); | 2286 expect(linked.exportNames, hasLength(1)); |
| 2296 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', | 2287 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', |
| 2297 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2288 ReferenceKind.topLevelPropertyAccessor); |
| 2298 } | 2289 } |
| 2299 | 2290 |
| 2300 test_export_shadowed_variable_final() { | 2291 test_export_shadowed_variable_final() { |
| 2301 // `v=` is shown in exportNames because the top level declaration | 2292 // `v=` is shown in exportNames because the top level declaration |
| 2302 // `final v = 0;` only shadows `v`, not `v=`. | 2293 // `final v = 0;` only shadows `v`, not `v=`. |
| 2303 addNamedSource('/a.dart', 'var v;'); | 2294 addNamedSource('/a.dart', 'var v;'); |
| 2304 serializeLibraryText('export "a.dart"; final v = 0;'); | 2295 serializeLibraryText('export "a.dart"; final v = 0;'); |
| 2305 expect(prelinked.exportNames, hasLength(1)); | 2296 expect(linked.exportNames, hasLength(1)); |
| 2306 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', | 2297 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', |
| 2307 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2298 ReferenceKind.topLevelPropertyAccessor); |
| 2308 } | 2299 } |
| 2309 | 2300 |
| 2310 test_export_show() { | 2301 test_export_show() { |
| 2311 addNamedSource('/a.dart', 'f() {} g() {}'); | 2302 addNamedSource('/a.dart', 'f() {} g() {}'); |
| 2312 serializeLibraryText('export "a.dart" show f;'); | 2303 serializeLibraryText('export "a.dart" show f;'); |
| 2313 expect(prelinked.exportNames, hasLength(1)); | 2304 expect(linked.exportNames, hasLength(1)); |
| 2314 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 2305 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', |
| 2315 PrelinkedReferenceKind.topLevelFunction); | 2306 ReferenceKind.topLevelFunction); |
| 2316 } | 2307 } |
| 2317 | 2308 |
| 2318 test_export_show_order() { | 2309 test_export_show_order() { |
| 2319 serializeLibraryText('export "dart:async" show Future, Stream;'); | 2310 serializeLibraryText('export "dart:async" show Future, Stream;'); |
| 2320 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 2311 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 2321 expect( | 2312 expect( |
| 2322 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); | 2313 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); |
| 2323 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, | 2314 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, |
| 2324 hasLength(2)); | 2315 hasLength(2)); |
| 2325 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, | 2316 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, |
| 2326 isEmpty); | 2317 isEmpty); |
| 2327 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], | 2318 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], |
| 2328 'Future'); | 2319 'Future'); |
| 2329 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1], | 2320 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1], |
| 2330 'Stream'); | 2321 'Stream'); |
| 2331 } | 2322 } |
| 2332 | 2323 |
| 2333 test_export_typedef() { | 2324 test_export_typedef() { |
| 2334 addNamedSource('/a.dart', 'typedef F();'); | 2325 addNamedSource('/a.dart', 'typedef F();'); |
| 2335 serializeLibraryText('export "a.dart";'); | 2326 serializeLibraryText('export "a.dart";'); |
| 2336 expect(prelinked.exportNames, hasLength(1)); | 2327 expect(linked.exportNames, hasLength(1)); |
| 2337 checkExportName(prelinked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F', | 2328 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F', |
| 2338 PrelinkedReferenceKind.typedef); | 2329 ReferenceKind.typedef); |
| 2339 } | 2330 } |
| 2340 | 2331 |
| 2341 test_export_uri() { | 2332 test_export_uri() { |
| 2342 addNamedSource('/a.dart', 'library my.lib;'); | 2333 addNamedSource('/a.dart', 'library my.lib;'); |
| 2343 String uriString = '"a.dart"'; | 2334 String uriString = '"a.dart"'; |
| 2344 String libraryText = 'export $uriString;'; | 2335 String libraryText = 'export $uriString;'; |
| 2345 serializeLibraryText(libraryText); | 2336 serializeLibraryText(libraryText); |
| 2346 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 2337 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 2347 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'a.dart'); | 2338 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'a.dart'); |
| 2348 } | 2339 } |
| 2349 | 2340 |
| 2350 test_export_variable() { | 2341 test_export_variable() { |
| 2351 addNamedSource('/a.dart', 'var v;'); | 2342 addNamedSource('/a.dart', 'var v;'); |
| 2352 serializeLibraryText('export "a.dart";'); | 2343 serializeLibraryText('export "a.dart";'); |
| 2353 expect(prelinked.exportNames, hasLength(2)); | 2344 expect(linked.exportNames, hasLength(2)); |
| 2354 PrelinkedExportName getter = | 2345 LinkedExportName getter = |
| 2355 prelinked.exportNames.firstWhere((e) => e.name == 'v'); | 2346 linked.exportNames.firstWhere((e) => e.name == 'v'); |
| 2356 expect(getter, isNotNull); | 2347 expect(getter, isNotNull); |
| 2357 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v', | 2348 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v', |
| 2358 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2349 ReferenceKind.topLevelPropertyAccessor); |
| 2359 PrelinkedExportName setter = | 2350 LinkedExportName setter = |
| 2360 prelinked.exportNames.firstWhere((e) => e.name == 'v='); | 2351 linked.exportNames.firstWhere((e) => e.name == 'v='); |
| 2361 expect(setter, isNotNull); | 2352 expect(setter, isNotNull); |
| 2362 checkExportName(setter, absUri('/a.dart'), 'a.dart', 'v=', | 2353 checkExportName(setter, absUri('/a.dart'), 'a.dart', 'v=', |
| 2363 PrelinkedReferenceKind.topLevelPropertyAccessor); | 2354 ReferenceKind.topLevelPropertyAccessor); |
| 2364 } | 2355 } |
| 2365 | 2356 |
| 2366 test_field() { | 2357 test_field() { |
| 2367 UnlinkedClass cls = serializeClassText('class C { int i; }'); | 2358 UnlinkedClass cls = serializeClassText('class C { int i; }'); |
| 2368 UnlinkedVariable variable = findVariable('i', variables: cls.fields); | 2359 UnlinkedVariable variable = findVariable('i', variables: cls.fields); |
| 2369 expect(variable, isNotNull); | 2360 expect(variable, isNotNull); |
| 2370 expect(variable.isConst, isFalse); | 2361 expect(variable.isConst, isFalse); |
| 2371 expect(variable.isStatic, isFalse); | 2362 expect(variable.isStatic, isFalse); |
| 2372 expect(variable.isFinal, isFalse); | 2363 expect(variable.isFinal, isFalse); |
| 2373 expect(findExecutable('i', executables: cls.executables), isNull); | 2364 expect(findExecutable('i', executables: cls.executables), isNull); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 test_import_deferred() { | 2433 test_import_deferred() { |
| 2443 serializeLibraryText( | 2434 serializeLibraryText( |
| 2444 'import "dart:async" deferred as a; main() { print(a.Future); }'); | 2435 'import "dart:async" deferred as a; main() { print(a.Future); }'); |
| 2445 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue); | 2436 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue); |
| 2446 } | 2437 } |
| 2447 | 2438 |
| 2448 test_import_dependency() { | 2439 test_import_dependency() { |
| 2449 serializeLibraryText('import "dart:async"; Future x;'); | 2440 serializeLibraryText('import "dart:async"; Future x;'); |
| 2450 // Second import is the implicit import of dart:core | 2441 // Second import is the implicit import of dart:core |
| 2451 expect(unlinkedUnits[0].imports, hasLength(2)); | 2442 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 2452 checkDependency( | 2443 checkDependency(linked.importDependencies[0], 'dart:async', 'dart:async'); |
| 2453 prelinked.importDependencies[0], 'dart:async', 'dart:async'); | |
| 2454 } | 2444 } |
| 2455 | 2445 |
| 2456 test_import_explicit() { | 2446 test_import_explicit() { |
| 2457 serializeLibraryText('import "dart:core"; int i;'); | 2447 serializeLibraryText('import "dart:core"; int i;'); |
| 2458 expect(unlinkedUnits[0].imports, hasLength(1)); | 2448 expect(unlinkedUnits[0].imports, hasLength(1)); |
| 2459 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); | 2449 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); |
| 2460 } | 2450 } |
| 2461 | 2451 |
| 2462 test_import_hide_order() { | 2452 test_import_hide_order() { |
| 2463 serializeLibraryText( | 2453 serializeLibraryText( |
| 2464 'import "dart:async" hide Future, Stream; Completer c;'); | 2454 'import "dart:async" hide Future, Stream; Completer c;'); |
| 2465 // Second import is the implicit import of dart:core | 2455 // Second import is the implicit import of dart:core |
| 2466 expect(unlinkedUnits[0].imports, hasLength(2)); | 2456 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 2467 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); | 2457 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); |
| 2468 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty); | 2458 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty); |
| 2469 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2)); | 2459 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2)); |
| 2470 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); | 2460 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); |
| 2471 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); | 2461 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); |
| 2472 } | 2462 } |
| 2473 | 2463 |
| 2474 test_import_implicit() { | 2464 test_import_implicit() { |
| 2475 // The implicit import of dart:core is represented in the model. | 2465 // The implicit import of dart:core is represented in the model. |
| 2476 serializeLibraryText(''); | 2466 serializeLibraryText(''); |
| 2477 expect(unlinkedUnits[0].imports, hasLength(1)); | 2467 expect(unlinkedUnits[0].imports, hasLength(1)); |
| 2478 checkDependency(prelinked.importDependencies[0], 'dart:core', 'dart:core'); | 2468 checkDependency(linked.importDependencies[0], 'dart:core', 'dart:core'); |
| 2479 expect(unlinkedUnits[0].imports[0].uri, isEmpty); | 2469 expect(unlinkedUnits[0].imports[0].uri, isEmpty); |
| 2480 expect(unlinkedUnits[0].imports[0].uriOffset, 0); | 2470 expect(unlinkedUnits[0].imports[0].uriOffset, 0); |
| 2481 expect(unlinkedUnits[0].imports[0].uriEnd, 0); | 2471 expect(unlinkedUnits[0].imports[0].uriEnd, 0); |
| 2482 expect(unlinkedUnits[0].imports[0].prefixReference, 0); | 2472 expect(unlinkedUnits[0].imports[0].prefixReference, 0); |
| 2483 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); | 2473 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); |
| 2484 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue); | 2474 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue); |
| 2485 } | 2475 } |
| 2486 | 2476 |
| 2487 test_import_no_combinators() { | 2477 test_import_no_combinators() { |
| 2488 serializeLibraryText('import "dart:async"; Future x;'); | 2478 serializeLibraryText('import "dart:async"; Future x;'); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 serializeLibraryText(text); | 2723 serializeLibraryText(text); |
| 2734 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); | 2724 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); |
| 2735 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart'); | 2725 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart'); |
| 2736 expect(unlinkedUnits[0].parts, hasLength(1)); | 2726 expect(unlinkedUnits[0].parts, hasLength(1)); |
| 2737 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"')); | 2727 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"')); |
| 2738 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); | 2728 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); |
| 2739 } | 2729 } |
| 2740 | 2730 |
| 2741 test_parts_defining_compilation_unit() { | 2731 test_parts_defining_compilation_unit() { |
| 2742 serializeLibraryText(''); | 2732 serializeLibraryText(''); |
| 2743 expect(prelinked.units, hasLength(1)); | 2733 expect(linked.units, hasLength(1)); |
| 2744 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty); | 2734 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty); |
| 2745 } | 2735 } |
| 2746 | 2736 |
| 2747 test_parts_included() { | 2737 test_parts_included() { |
| 2748 addNamedSource('/part1.dart', 'part of my.lib;'); | 2738 addNamedSource('/part1.dart', 'part of my.lib;'); |
| 2749 String partString = '"part1.dart"'; | 2739 String partString = '"part1.dart"'; |
| 2750 String libraryText = 'library my.lib; part $partString;'; | 2740 String libraryText = 'library my.lib; part $partString;'; |
| 2751 serializeLibraryText(libraryText); | 2741 serializeLibraryText(libraryText); |
| 2752 expect(prelinked.units, hasLength(2)); | 2742 expect(linked.units, hasLength(2)); |
| 2753 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); | 2743 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); |
| 2754 expect(unlinkedUnits[0].publicNamespace.parts[0], 'part1.dart'); | 2744 expect(unlinkedUnits[0].publicNamespace.parts[0], 'part1.dart'); |
| 2755 } | 2745 } |
| 2756 | 2746 |
| 2757 test_public_namespace_of_part() { | 2747 test_public_namespace_of_part() { |
| 2758 addNamedSource('/a.dart', 'part of foo; class C {}'); | 2748 addNamedSource('/a.dart', 'part of foo; class C {}'); |
| 2759 serializeLibraryText('library foo; part "a.dart";'); | 2749 serializeLibraryText('library foo; part "a.dart";'); |
| 2760 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2750 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2761 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1)); | 2751 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1)); |
| 2762 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C'); | 2752 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C'); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2787 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 2777 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 2788 allowTypeParameters: true, numTypeParameters: 1); | 2778 allowTypeParameters: true, numTypeParameters: 1); |
| 2789 expect(typeRef.typeArguments, isEmpty); | 2779 expect(typeRef.typeArguments, isEmpty); |
| 2790 } | 2780 } |
| 2791 | 2781 |
| 2792 test_type_arguments_explicit_dynamic_typedef() { | 2782 test_type_arguments_explicit_dynamic_typedef() { |
| 2793 UnlinkedTypeRef typeRef = | 2783 UnlinkedTypeRef typeRef = |
| 2794 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); | 2784 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); |
| 2795 checkTypeRef(typeRef, null, null, 'F', | 2785 checkTypeRef(typeRef, null, null, 'F', |
| 2796 allowTypeParameters: true, | 2786 allowTypeParameters: true, |
| 2797 expectedKind: PrelinkedReferenceKind.typedef, | 2787 expectedKind: ReferenceKind.typedef, |
| 2798 numTypeParameters: 1); | 2788 numTypeParameters: 1); |
| 2799 expect(typeRef.typeArguments, isEmpty); | 2789 expect(typeRef.typeArguments, isEmpty); |
| 2800 } | 2790 } |
| 2801 | 2791 |
| 2802 test_type_arguments_explicit_typedef() { | 2792 test_type_arguments_explicit_typedef() { |
| 2803 UnlinkedTypeRef typeRef = | 2793 UnlinkedTypeRef typeRef = |
| 2804 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); | 2794 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); |
| 2805 checkTypeRef(typeRef, null, null, 'F', | 2795 checkTypeRef(typeRef, null, null, 'F', |
| 2806 allowTypeParameters: true, | 2796 allowTypeParameters: true, |
| 2807 expectedKind: PrelinkedReferenceKind.typedef, | 2797 expectedKind: ReferenceKind.typedef, |
| 2808 numTypeParameters: 1); | 2798 numTypeParameters: 1); |
| 2809 expect(typeRef.typeArguments, hasLength(1)); | 2799 expect(typeRef.typeArguments, hasLength(1)); |
| 2810 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2800 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 2811 } | 2801 } |
| 2812 | 2802 |
| 2813 test_type_arguments_implicit() { | 2803 test_type_arguments_implicit() { |
| 2814 UnlinkedTypeRef typeRef = serializeTypeText('List'); | 2804 UnlinkedTypeRef typeRef = serializeTypeText('List'); |
| 2815 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 2805 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 2816 allowTypeParameters: true, numTypeParameters: 1); | 2806 allowTypeParameters: true, numTypeParameters: 1); |
| 2817 expect(typeRef.typeArguments, isEmpty); | 2807 expect(typeRef.typeArguments, isEmpty); |
| 2818 } | 2808 } |
| 2819 | 2809 |
| 2820 test_type_arguments_implicit_typedef() { | 2810 test_type_arguments_implicit_typedef() { |
| 2821 UnlinkedTypeRef typeRef = | 2811 UnlinkedTypeRef typeRef = |
| 2822 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); | 2812 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); |
| 2823 checkTypeRef(typeRef, null, null, 'F', | 2813 checkTypeRef(typeRef, null, null, 'F', |
| 2824 allowTypeParameters: true, | 2814 allowTypeParameters: true, |
| 2825 expectedKind: PrelinkedReferenceKind.typedef, | 2815 expectedKind: ReferenceKind.typedef, |
| 2826 numTypeParameters: 1); | 2816 numTypeParameters: 1); |
| 2827 expect(typeRef.typeArguments, isEmpty); | 2817 expect(typeRef.typeArguments, isEmpty); |
| 2828 } | 2818 } |
| 2829 | 2819 |
| 2830 test_type_arguments_order() { | 2820 test_type_arguments_order() { |
| 2831 UnlinkedTypeRef typeRef = serializeTypeText('Map<int, Object>'); | 2821 UnlinkedTypeRef typeRef = serializeTypeText('Map<int, Object>'); |
| 2832 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 2822 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 2833 allowTypeParameters: true, numTypeParameters: 2); | 2823 allowTypeParameters: true, numTypeParameters: 2); |
| 2834 expect(typeRef.typeArguments, hasLength(2)); | 2824 expect(typeRef.typeArguments, hasLength(2)); |
| 2835 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2825 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 2836 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); | 2826 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); |
| 2837 } | 2827 } |
| 2838 | 2828 |
| 2839 test_type_dynamic() { | 2829 test_type_dynamic() { |
| 2840 checkDynamicTypeRef(serializeTypeText('dynamic')); | 2830 checkDynamicTypeRef(serializeTypeText('dynamic')); |
| 2841 } | 2831 } |
| 2842 | 2832 |
| 2843 test_type_reference_from_part() { | 2833 test_type_reference_from_part() { |
| 2844 addNamedSource('/a.dart', 'part of foo; C v;'); | 2834 addNamedSource('/a.dart', 'part of foo; C v;'); |
| 2845 serializeLibraryText('library foo; part "a.dart"; class C {}'); | 2835 serializeLibraryText('library foo; part "a.dart"; class C {}'); |
| 2846 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, | 2836 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, |
| 2847 null, null, 'C', | 2837 null, null, 'C', |
| 2848 expectedKind: PrelinkedReferenceKind.classOrEnum, | 2838 expectedKind: ReferenceKind.classOrEnum, |
| 2849 prelinkedSourceUnit: prelinked.units[1], | 2839 linkedSourceUnit: linked.units[1], |
| 2850 unlinkedSourceUnit: unlinkedUnits[1]); | 2840 unlinkedSourceUnit: unlinkedUnits[1]); |
| 2851 } | 2841 } |
| 2852 | 2842 |
| 2853 test_type_reference_from_part_withPrefix() { | 2843 test_type_reference_from_part_withPrefix() { |
| 2854 addNamedSource('/a.dart', 'class C {}'); | 2844 addNamedSource('/a.dart', 'class C {}'); |
| 2855 addNamedSource('/p.dart', 'part of foo; a.C v;'); | 2845 addNamedSource('/p.dart', 'part of foo; a.C v;'); |
| 2856 serializeLibraryText( | 2846 serializeLibraryText( |
| 2857 'library foo; import "a.dart"; import "a.dart" as a; part "p.dart";', | 2847 'library foo; import "a.dart"; import "a.dart" as a; part "p.dart";', |
| 2858 allowErrors: true); | 2848 allowErrors: true); |
| 2859 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, | 2849 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, |
| 2860 absUri('/a.dart'), 'a.dart', 'C', | 2850 absUri('/a.dart'), 'a.dart', 'C', |
| 2861 expectedPrefix: 'a', | 2851 expectedPrefix: 'a', |
| 2862 prelinkedSourceUnit: prelinked.units[1], | 2852 linkedSourceUnit: linked.units[1], |
| 2863 unlinkedSourceUnit: unlinkedUnits[1]); | 2853 unlinkedSourceUnit: unlinkedUnits[1]); |
| 2864 } | 2854 } |
| 2865 | 2855 |
| 2866 test_type_reference_to_class_argument() { | 2856 test_type_reference_to_class_argument() { |
| 2867 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); | 2857 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); |
| 2868 { | 2858 { |
| 2869 UnlinkedTypeRef typeRef = | 2859 UnlinkedTypeRef typeRef = |
| 2870 findVariable('t', variables: cls.fields, failIfAbsent: true).type; | 2860 findVariable('t', variables: cls.fields, failIfAbsent: true).type; |
| 2871 checkParamTypeRef(typeRef, 2); | 2861 checkParamTypeRef(typeRef, 2); |
| 2872 } | 2862 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 null, | 2937 null, |
| 2948 null, | 2938 null, |
| 2949 'C', | 2939 'C', |
| 2950 expectedTargetUnit: 1); | 2940 expectedTargetUnit: 1); |
| 2951 } | 2941 } |
| 2952 | 2942 |
| 2953 test_type_reference_to_part() { | 2943 test_type_reference_to_part() { |
| 2954 addNamedSource('/a.dart', 'part of foo; class C { C(); }'); | 2944 addNamedSource('/a.dart', 'part of foo; class C { C(); }'); |
| 2955 serializeLibraryText('library foo; part "a.dart"; C c;'); | 2945 serializeLibraryText('library foo; part "a.dart"; C c;'); |
| 2956 checkTypeRef(unlinkedUnits[0].variables.single.type, null, null, 'C', | 2946 checkTypeRef(unlinkedUnits[0].variables.single.type, null, null, 'C', |
| 2957 expectedKind: PrelinkedReferenceKind.classOrEnum, | 2947 expectedKind: ReferenceKind.classOrEnum, expectedTargetUnit: 1); |
| 2958 expectedTargetUnit: 1); | |
| 2959 } | 2948 } |
| 2960 | 2949 |
| 2961 test_type_reference_to_typedef() { | 2950 test_type_reference_to_typedef() { |
| 2962 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'), | 2951 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'), |
| 2963 null, null, 'F', | 2952 null, null, 'F', |
| 2964 expectedKind: PrelinkedReferenceKind.typedef); | 2953 expectedKind: ReferenceKind.typedef); |
| 2965 } | 2954 } |
| 2966 | 2955 |
| 2967 test_type_unit_counts_unreferenced_units() { | 2956 test_type_unit_counts_unreferenced_units() { |
| 2968 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";'); | 2957 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";'); |
| 2969 addNamedSource('/b.dart', 'part of a;'); | 2958 addNamedSource('/b.dart', 'part of a;'); |
| 2970 addNamedSource('/c.dart', 'part of a; class C {}'); | 2959 addNamedSource('/c.dart', 'part of a; class C {}'); |
| 2971 UnlinkedTypeRef typeRef = | 2960 UnlinkedTypeRef typeRef = |
| 2972 serializeTypeText('C', otherDeclarations: 'import "a.dart";'); | 2961 serializeTypeText('C', otherDeclarations: 'import "a.dart";'); |
| 2973 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is | 2962 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is |
| 2974 // b.dart. a.dart and b.dart are counted even though nothing is imported | 2963 // b.dart. a.dart and b.dart are counted even though nothing is imported |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2993 expect(typedef.documentationComment, isNotNull); | 2982 expect(typedef.documentationComment, isNotNull); |
| 2994 checkDocumentationComment(typedef.documentationComment, text); | 2983 checkDocumentationComment(typedef.documentationComment, text); |
| 2995 } | 2984 } |
| 2996 | 2985 |
| 2997 test_typedef_name() { | 2986 test_typedef_name() { |
| 2998 String text = 'typedef F();'; | 2987 String text = 'typedef F();'; |
| 2999 UnlinkedTypedef type = serializeTypedefText(text); | 2988 UnlinkedTypedef type = serializeTypedefText(text); |
| 3000 expect(type.name, 'F'); | 2989 expect(type.name, 'F'); |
| 3001 expect(type.nameOffset, text.indexOf('F')); | 2990 expect(type.nameOffset, text.indexOf('F')); |
| 3002 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 2991 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 3003 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 2992 expect( |
| 3004 PrelinkedReferenceKind.typedef); | 2993 unlinkedUnits[0].publicNamespace.names[0].kind, ReferenceKind.typedef); |
| 3005 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'F'); | 2994 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'F'); |
| 3006 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 2995 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 3007 } | 2996 } |
| 3008 | 2997 |
| 3009 test_typedef_param_none() { | 2998 test_typedef_param_none() { |
| 3010 UnlinkedTypedef type = serializeTypedefText('typedef F();'); | 2999 UnlinkedTypedef type = serializeTypedefText('typedef F();'); |
| 3011 expect(type.parameters, isEmpty); | 3000 expect(type.parameters, isEmpty); |
| 3012 } | 3001 } |
| 3013 | 3002 |
| 3014 test_typedef_param_order() { | 3003 test_typedef_param_order() { |
| 3015 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);'); | 3004 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);'); |
| 3016 expect(type.parameters, hasLength(2)); | 3005 expect(type.parameters, hasLength(2)); |
| 3017 expect(type.parameters[0].name, 'x'); | 3006 expect(type.parameters[0].name, 'x'); |
| 3018 expect(type.parameters[1].name, 'y'); | 3007 expect(type.parameters[1].name, 'y'); |
| 3019 } | 3008 } |
| 3020 | 3009 |
| 3021 test_typedef_private() { | 3010 test_typedef_private() { |
| 3022 serializeTypedefText('typedef _F();', '_F'); | 3011 serializeTypedefText('typedef _F();', '_F'); |
| 3023 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 3012 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 3024 } | 3013 } |
| 3025 | 3014 |
| 3026 test_typedef_reference_generic() { | 3015 test_typedef_reference_generic() { |
| 3027 UnlinkedTypeRef typeRef = | 3016 UnlinkedTypeRef typeRef = |
| 3028 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); | 3017 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); |
| 3029 checkTypeRef(typeRef, null, null, 'F', | 3018 checkTypeRef(typeRef, null, null, 'F', |
| 3030 numTypeParameters: 2, expectedKind: PrelinkedReferenceKind.typedef); | 3019 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); |
| 3031 } | 3020 } |
| 3032 | 3021 |
| 3033 test_typedef_reference_generic_imported() { | 3022 test_typedef_reference_generic_imported() { |
| 3034 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); | 3023 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); |
| 3035 UnlinkedTypeRef typeRef = | 3024 UnlinkedTypeRef typeRef = |
| 3036 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); | 3025 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); |
| 3037 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', | 3026 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', |
| 3038 numTypeParameters: 2, expectedKind: PrelinkedReferenceKind.typedef); | 3027 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); |
| 3039 } | 3028 } |
| 3040 | 3029 |
| 3041 test_typedef_return_type_explicit() { | 3030 test_typedef_return_type_explicit() { |
| 3042 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); | 3031 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); |
| 3043 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); | 3032 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); |
| 3044 } | 3033 } |
| 3045 | 3034 |
| 3046 test_typedef_type_param_in_parameter() { | 3035 test_typedef_type_param_in_parameter() { |
| 3047 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); | 3036 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); |
| 3048 checkParamTypeRef(type.parameters[0].type, 1); | 3037 checkParamTypeRef(type.parameters[0].type, 1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3067 } | 3056 } |
| 3068 | 3057 |
| 3069 test_variable() { | 3058 test_variable() { |
| 3070 String text = 'int i;'; | 3059 String text = 'int i;'; |
| 3071 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); | 3060 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); |
| 3072 expect(v.nameOffset, text.indexOf('i;')); | 3061 expect(v.nameOffset, text.indexOf('i;')); |
| 3073 expect(findExecutable('i'), isNull); | 3062 expect(findExecutable('i'), isNull); |
| 3074 expect(findExecutable('i='), isNull); | 3063 expect(findExecutable('i='), isNull); |
| 3075 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); | 3064 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); |
| 3076 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 3065 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 3077 PrelinkedReferenceKind.topLevelPropertyAccessor); | 3066 ReferenceKind.topLevelPropertyAccessor); |
| 3078 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i'); | 3067 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i'); |
| 3079 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 3068 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 3080 expect(unlinkedUnits[0].publicNamespace.names[1].kind, | 3069 expect(unlinkedUnits[0].publicNamespace.names[1].kind, |
| 3081 PrelinkedReferenceKind.topLevelPropertyAccessor); | 3070 ReferenceKind.topLevelPropertyAccessor); |
| 3082 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'i='); | 3071 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'i='); |
| 3083 expect(unlinkedUnits[0].publicNamespace.names[1].numTypeParameters, 0); | 3072 expect(unlinkedUnits[0].publicNamespace.names[1].numTypeParameters, 0); |
| 3084 } | 3073 } |
| 3085 | 3074 |
| 3086 test_variable_const() { | 3075 test_variable_const() { |
| 3087 UnlinkedVariable variable = | 3076 UnlinkedVariable variable = |
| 3088 serializeVariableText('const int i = 0;', variableName: 'i'); | 3077 serializeVariableText('const int i = 0;', variableName: 'i'); |
| 3089 expect(variable.isConst, isTrue); | 3078 expect(variable.isConst, isTrue); |
| 3090 } | 3079 } |
| 3091 | 3080 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 UnlinkedVariable variable = | 3157 UnlinkedVariable variable = |
| 3169 serializeVariableText('int i;', variableName: 'i'); | 3158 serializeVariableText('int i;', variableName: 'i'); |
| 3170 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); | 3159 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); |
| 3171 } | 3160 } |
| 3172 | 3161 |
| 3173 test_varible_private() { | 3162 test_varible_private() { |
| 3174 serializeVariableText('int _i;', variableName: '_i'); | 3163 serializeVariableText('int _i;', variableName: '_i'); |
| 3175 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 3164 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 3176 } | 3165 } |
| 3177 } | 3166 } |
| OLD | NEW |