| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 MessageKind.LIBRARY_NAME_MISMATCH.error([expectedName]), | 515 MessageKind.LIBRARY_NAME_MISMATCH.error([expectedName]), |
| 516 api.Diagnostic.WARNING); | 516 api.Diagnostic.WARNING); |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 bool get hasMembers => !localMembers.isEmpty; | 521 bool get hasMembers => !localMembers.isEmpty; |
| 522 } | 522 } |
| 523 | 523 |
| 524 class LibraryElementX extends ElementX implements LibraryElement { | 524 class LibraryElementX extends ElementX implements LibraryElement { |
| 525 final Uri uri; | 525 final Uri canonicalUri; |
| 526 CompilationUnitElement entryCompilationUnit; | 526 CompilationUnitElement entryCompilationUnit; |
| 527 Link<CompilationUnitElement> compilationUnits = | 527 Link<CompilationUnitElement> compilationUnits = |
| 528 const Link<CompilationUnitElement>(); | 528 const Link<CompilationUnitElement>(); |
| 529 Link<LibraryTag> tags = const Link<LibraryTag>(); | 529 Link<LibraryTag> tags = const Link<LibraryTag>(); |
| 530 LibraryName libraryTag; | 530 LibraryName libraryTag; |
| 531 bool canUseNative = false; | 531 bool canUseNative = false; |
| 532 Link<Element> localMembers = const Link<Element>(); | 532 Link<Element> localMembers = const Link<Element>(); |
| 533 final ScopeX localScope = new ScopeX(); | 533 final ScopeX localScope = new ScopeX(); |
| 534 | 534 |
| 535 /** | 535 /** |
| (...skipping 21 matching lines...) Expand all Loading... |
| 557 /** | 557 /** |
| 558 * Link for elements exported either through export declarations or through | 558 * Link for elements exported either through export declarations or through |
| 559 * declaration. This field should not be accessed directly but instead through | 559 * declaration. This field should not be accessed directly but instead through |
| 560 * the [exports] getter. | 560 * the [exports] getter. |
| 561 * | 561 * |
| 562 * [LibraryDependencyHandler] sets this field through [setExports] when the | 562 * [LibraryDependencyHandler] sets this field through [setExports] when the |
| 563 * library is loaded. | 563 * library is loaded. |
| 564 */ | 564 */ |
| 565 Link<Element> slotForExports; | 565 Link<Element> slotForExports; |
| 566 | 566 |
| 567 LibraryElementX(Script script, [Uri uri, LibraryElement this.origin]) | 567 LibraryElementX(Script script, [Uri canonicalUri, LibraryElement this.origin]) |
| 568 : this.uri = ((uri == null) ? script.uri : uri), | 568 : this.canonicalUri = ((canonicalUri == null) ? script.uri : canonicalUri), |
| 569 importScope = new Map<SourceString, Element>(), | 569 importScope = new Map<SourceString, Element>(), |
| 570 super(new SourceString(script.name), ElementKind.LIBRARY, null) { | 570 super(new SourceString(script.name), ElementKind.LIBRARY, null) { |
| 571 entryCompilationUnit = new CompilationUnitElementX(script, this); | 571 entryCompilationUnit = new CompilationUnitElementX(script, this); |
| 572 if (isPatch) { | 572 if (isPatch) { |
| 573 origin.patch = this; | 573 origin.patch = this; |
| 574 } | 574 } |
| 575 } | 575 } |
| 576 | 576 |
| 577 bool get isPatched => patch != null; | 577 bool get isPatched => patch != null; |
| 578 bool get isPatch => origin != null; | 578 bool get isPatch => origin != null; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 /** | 721 /** |
| 722 * Returns the library name (as defined by the #library tag) or for script | 722 * Returns the library name (as defined by the #library tag) or for script |
| 723 * (which have no #library tag) the script file name. The latter case is used | 723 * (which have no #library tag) the script file name. The latter case is used |
| 724 * to private 'library name' for scripts to use for instance in dartdoc. | 724 * to private 'library name' for scripts to use for instance in dartdoc. |
| 725 */ | 725 */ |
| 726 String getLibraryOrScriptName() { | 726 String getLibraryOrScriptName() { |
| 727 if (libraryTag != null) { | 727 if (libraryTag != null) { |
| 728 return libraryTag.name.toString(); | 728 return libraryTag.name.toString(); |
| 729 } else { | 729 } else { |
| 730 // Use the file name as script name. | 730 // Use the file name as script name. |
| 731 String path = uri.path; | 731 String path = canonicalUri.path; |
| 732 return path.substring(path.lastIndexOf('/') + 1); | 732 return path.substring(path.lastIndexOf('/') + 1); |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 | 735 |
| 736 Scope buildScope() => new LibraryScope(this); | 736 Scope buildScope() => new LibraryScope(this); |
| 737 | 737 |
| 738 bool get isPlatformLibrary => uri.scheme == "dart"; | 738 bool get isPlatformLibrary => canonicalUri.scheme == "dart"; |
| 739 |
| 740 bool get isInternalLibrary => |
| 741 isPlatformLibrary && canonicalUri.path.startsWith('_'); |
| 739 | 742 |
| 740 String toString() { | 743 String toString() { |
| 741 if (origin != null) { | 744 if (origin != null) { |
| 742 return 'patch library(${getLibraryOrScriptName()})'; | 745 return 'patch library(${getLibraryOrScriptName()})'; |
| 743 } else if (patch != null) { | 746 } else if (patch != null) { |
| 744 return 'origin library(${getLibraryOrScriptName()})'; | 747 return 'origin library(${getLibraryOrScriptName()})'; |
| 745 } else { | 748 } else { |
| 746 return 'library(${getLibraryOrScriptName()})'; | 749 return 'library(${getLibraryOrScriptName()})'; |
| 747 } | 750 } |
| 748 } | 751 } |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 | 1967 |
| 1965 MetadataAnnotation ensureResolved(Compiler compiler) { | 1968 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1966 if (resolutionState == STATE_NOT_STARTED) { | 1969 if (resolutionState == STATE_NOT_STARTED) { |
| 1967 compiler.resolver.resolveMetadataAnnotation(this); | 1970 compiler.resolver.resolveMetadataAnnotation(this); |
| 1968 } | 1971 } |
| 1969 return this; | 1972 return this; |
| 1970 } | 1973 } |
| 1971 | 1974 |
| 1972 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1975 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1973 } | 1976 } |
| OLD | NEW |