| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 * change when we actually want more information on the erroneous element, | 290 * change when we actually want more information on the erroneous element, |
| 291 * e.g., the name of the element we were trying to resolve.) | 291 * e.g., the name of the element we were trying to resolve.) |
| 292 * | 292 * |
| 293 * Code that cannot not handle an [ErroneousElement] should use | 293 * Code that cannot not handle an [ErroneousElement] should use |
| 294 * [: Element.isInvalid(element) :] | 294 * [: Element.isInvalid(element) :] |
| 295 * to check for unresolvable elements instead of | 295 * to check for unresolvable elements instead of |
| 296 * [: element == null :]. | 296 * [: element == null :]. |
| 297 */ | 297 */ |
| 298 class ErroneousElementX extends ElementX implements ErroneousElement { | 298 class ErroneousElementX extends ElementX implements ErroneousElement { |
| 299 final MessageKind messageKind; | 299 final MessageKind messageKind; |
| 300 final List messageArguments; | 300 final Map messageArguments; |
| 301 | 301 |
| 302 ErroneousElementX(this.messageKind, this.messageArguments, | 302 ErroneousElementX(this.messageKind, this.messageArguments, |
| 303 SourceString name, Element enclosing) | 303 SourceString name, Element enclosing) |
| 304 : super(name, ElementKind.ERROR, enclosing); | 304 : super(name, ElementKind.ERROR, enclosing); |
| 305 | 305 |
| 306 isErroneous() => true; | 306 isErroneous() => true; |
| 307 | 307 |
| 308 unsupported() { | 308 unsupported() { |
| 309 throw 'unsupported operation on erroneous element'; | 309 throw 'unsupported operation on erroneous element'; |
| 310 } | 310 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 */ | 350 */ |
| 351 class AmbiguousElementX extends ElementX implements AmbiguousElement { | 351 class AmbiguousElementX extends ElementX implements AmbiguousElement { |
| 352 /** | 352 /** |
| 353 * The message to report on resolving this element. | 353 * The message to report on resolving this element. |
| 354 */ | 354 */ |
| 355 final MessageKind messageKind; | 355 final MessageKind messageKind; |
| 356 | 356 |
| 357 /** | 357 /** |
| 358 * The message arguments to report on resolving this element. | 358 * The message arguments to report on resolving this element. |
| 359 */ | 359 */ |
| 360 final List messageArguments; | 360 final Map messageArguments; |
| 361 | 361 |
| 362 /** | 362 /** |
| 363 * The first element that this ambiguous element might refer to. | 363 * The first element that this ambiguous element might refer to. |
| 364 */ | 364 */ |
| 365 final Element existingElement; | 365 final Element existingElement; |
| 366 | 366 |
| 367 /** | 367 /** |
| 368 * The second element that this ambiguous element might refer to. | 368 * The second element that this ambiguous element might refer to. |
| 369 */ | 369 */ |
| 370 final Element newElement; | 370 final Element newElement; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return; | 505 return; |
| 506 } | 506 } |
| 507 partTag = tag; | 507 partTag = tag; |
| 508 LibraryName libraryTag = getLibrary().libraryTag; | 508 LibraryName libraryTag = getLibrary().libraryTag; |
| 509 if (libraryTag != null) { | 509 if (libraryTag != null) { |
| 510 String actualName = tag.name.toString(); | 510 String actualName = tag.name.toString(); |
| 511 String expectedName = libraryTag.name.toString(); | 511 String expectedName = libraryTag.name.toString(); |
| 512 if (expectedName != actualName) { | 512 if (expectedName != actualName) { |
| 513 listener.reportMessage( | 513 listener.reportMessage( |
| 514 listener.spanFromSpannable(tag.name), | 514 listener.spanFromSpannable(tag.name), |
| 515 MessageKind.LIBRARY_NAME_MISMATCH.error([expectedName]), | 515 MessageKind.LIBRARY_NAME_MISMATCH.error( |
| 516 {'libraryName': expectedName}), |
| 516 api.Diagnostic.WARNING); | 517 api.Diagnostic.WARNING); |
| 517 } | 518 } |
| 518 } | 519 } |
| 519 } | 520 } |
| 520 | 521 |
| 521 bool get hasMembers => !localMembers.isEmpty; | 522 bool get hasMembers => !localMembers.isEmpty; |
| 522 } | 523 } |
| 523 | 524 |
| 524 class LibraryElementX extends ElementX implements LibraryElement { | 525 class LibraryElementX extends ElementX implements LibraryElement { |
| 525 final Uri canonicalUri; | 526 final Uri canonicalUri; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 * If an element by the same name is already in the imported scope, an | 597 * If an element by the same name is already in the imported scope, an |
| 597 * [ErroneousElement] will be put in the imported scope, allowing for the | 598 * [ErroneousElement] will be put in the imported scope, allowing for the |
| 598 * detection of ambiguous uses of imported names. | 599 * detection of ambiguous uses of imported names. |
| 599 */ | 600 */ |
| 600 void addImport(Element element, DiagnosticListener listener) { | 601 void addImport(Element element, DiagnosticListener listener) { |
| 601 Element existing = importScope[element.name]; | 602 Element existing = importScope[element.name]; |
| 602 if (existing != null) { | 603 if (existing != null) { |
| 603 // TODO(johnniwinther): Provide access to the import tags from which | 604 // TODO(johnniwinther): Provide access to the import tags from which |
| 604 // the elements came. | 605 // the elements came. |
| 605 importScope[element.name] = new AmbiguousElementX( | 606 importScope[element.name] = new AmbiguousElementX( |
| 606 MessageKind.DUPLICATE_IMPORT, [element.name], | 607 MessageKind.DUPLICATE_IMPORT, {'name': element.name}, |
| 607 this, existing, element); | 608 this, existing, element); |
| 608 } else { | 609 } else { |
| 609 importScope[element.name] = element; | 610 importScope[element.name] = element; |
| 610 } | 611 } |
| 611 } | 612 } |
| 612 | 613 |
| 613 void addMember(Element element, DiagnosticListener listener) { | 614 void addMember(Element element, DiagnosticListener listener) { |
| 614 localMembers = localMembers.prepend(element); | 615 localMembers = localMembers.prepend(element); |
| 615 addToScope(element, listener); | 616 addToScope(element, listener); |
| 616 } | 617 } |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 | 1968 |
| 1968 MetadataAnnotation ensureResolved(Compiler compiler) { | 1969 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1969 if (resolutionState == STATE_NOT_STARTED) { | 1970 if (resolutionState == STATE_NOT_STARTED) { |
| 1970 compiler.resolver.resolveMetadataAnnotation(this); | 1971 compiler.resolver.resolveMetadataAnnotation(this); |
| 1971 } | 1972 } |
| 1972 return this; | 1973 return this; |
| 1973 } | 1974 } |
| 1974 | 1975 |
| 1975 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1976 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1976 } | 1977 } |
| OLD | NEW |