| 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:collection' show LinkedHashMap; | 7 import 'dart:collection' show LinkedHashMap; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 * Adds [element] to the import scope of this library. | 667 * Adds [element] to the import scope of this library. |
| 668 * | 668 * |
| 669 * If an element by the same name is already in the imported scope, an | 669 * If an element by the same name is already in the imported scope, an |
| 670 * [ErroneousElement] will be put in the imported scope, allowing for the | 670 * [ErroneousElement] will be put in the imported scope, allowing for the |
| 671 * detection of ambiguous uses of imported names. | 671 * detection of ambiguous uses of imported names. |
| 672 */ | 672 */ |
| 673 void addImport(Element element, Import import, DiagnosticListener listener) { | 673 void addImport(Element element, Import import, DiagnosticListener listener) { |
| 674 importers[element] = | 674 importers[element] = |
| 675 importers.putIfAbsent(element, () => const Link<Import>()) | 675 importers.putIfAbsent(element, () => const Link<Import>()) |
| 676 .prepend(import); | 676 .prepend(import); |
| 677 Element existing = importScope[element.name]; | 677 SourceString name = element.name; |
| 678 if (existing != null) { | 678 Element existing = importScope.putIfAbsent(name, () => element); |
| 679 // TODO(johnniwinther): Provide access to the import tags from which | 679 if (existing != element) { |
| 680 // the elements came. | 680 if (existing.getLibrary().isPlatformLibrary && |
| 681 importScope[element.name] = new AmbiguousElementX( | 681 !element.getLibrary().isPlatformLibrary) { |
| 682 MessageKind.DUPLICATE_IMPORT, {'name': element.name}, | 682 // [existing] is implicitly hidden. |
| 683 this, existing, element); | 683 importScope[name] = element; |
| 684 } else { | 684 listener.reportWarningCode(import, MessageKind.HIDDEN_IMPORT, |
| 685 importScope[element.name] = element; | 685 {'name': name, |
| 686 'hiddenUri': existing.getLibrary().canonicalUri, |
| 687 'hidingUri': element.getLibrary().canonicalUri}); |
| 688 } else if (!existing.getLibrary().isPlatformLibrary && |
| 689 element.getLibrary().isPlatformLibrary) { |
| 690 // [element] is implicitly hidden. |
| 691 listener.reportWarningCode(import, MessageKind.HIDDEN_IMPORT, |
| 692 {'name': name, |
| 693 'hiddenUri': element.getLibrary().canonicalUri, |
| 694 'hidingUri': existing.getLibrary().canonicalUri}); |
| 695 } else { |
| 696 // TODO(johnniwinther): Provide access to the import tags from which |
| 697 // the elements came. |
| 698 importScope[name] = new AmbiguousElementX( |
| 699 MessageKind.DUPLICATE_IMPORT, {'name': name}, |
| 700 this, existing, element); |
| 701 } |
| 686 } | 702 } |
| 687 } | 703 } |
| 688 | 704 |
| 689 void addMember(Element element, DiagnosticListener listener) { | 705 void addMember(Element element, DiagnosticListener listener) { |
| 690 localMembers = localMembers.prepend(element); | 706 localMembers = localMembers.prepend(element); |
| 691 addToScope(element, listener); | 707 addToScope(element, listener); |
| 692 } | 708 } |
| 693 | 709 |
| 694 void addToScope(Element element, DiagnosticListener listener) { | 710 void addToScope(Element element, DiagnosticListener listener) { |
| 695 localScope.add(element, listener); | 711 localScope.add(element, listener); |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2201 | 2217 |
| 2202 MetadataAnnotation ensureResolved(Compiler compiler) { | 2218 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2203 if (resolutionState == STATE_NOT_STARTED) { | 2219 if (resolutionState == STATE_NOT_STARTED) { |
| 2204 compiler.resolver.resolveMetadataAnnotation(this); | 2220 compiler.resolver.resolveMetadataAnnotation(this); |
| 2205 } | 2221 } |
| 2206 return this; | 2222 return this; |
| 2207 } | 2223 } |
| 2208 | 2224 |
| 2209 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2225 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2210 } | 2226 } |
| OLD | NEW |