| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
| 9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 @override | 445 @override |
| 446 set _redirectionDeferredPrefix(_) { | 446 set _redirectionDeferredPrefix(_) { |
| 447 throw new UnsupportedError("_redirectionDeferredPrefix="); | 447 throw new UnsupportedError("_redirectionDeferredPrefix="); |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 | 450 |
| 451 /// A message attached to a [WarnOnUseElementX]. | 451 /// A message attached to a [WarnOnUseElementX]. |
| 452 class WrappedMessage { | 452 class WrappedMessage { |
| 453 /// The message position. If [:null:] the position of the reference to the | 453 /// The message position. If [:null:] the position of the reference to the |
| 454 /// [WarnOnUseElementX] is used. | 454 /// [WarnOnUseElementX] is used. |
| 455 final Spannable spannable; | 455 final SourceSpan sourceSpan; |
| 456 | 456 |
| 457 /** | 457 /** |
| 458 * The message to report on resolving a wrapped element. | 458 * The message to report on resolving a wrapped element. |
| 459 */ | 459 */ |
| 460 final MessageKind messageKind; | 460 final MessageKind messageKind; |
| 461 | 461 |
| 462 /** | 462 /** |
| 463 * The message arguments to report on resolving a wrapped element. | 463 * The message arguments to report on resolving a wrapped element. |
| 464 */ | 464 */ |
| 465 final Map messageArguments; | 465 final Map messageArguments; |
| 466 | 466 |
| 467 WrappedMessage(this.spannable, this.messageKind, this.messageArguments); | 467 WrappedMessage(this.sourceSpan, this.messageKind, this.messageArguments); |
| 468 } | 468 } |
| 469 | 469 |
| 470 class WarnOnUseElementX extends ElementX implements WarnOnUseElement { | 470 class WarnOnUseElementX extends ElementX implements WarnOnUseElement { |
| 471 /// Warning to report on resolving this element. | 471 /// Warning to report on resolving this element. |
| 472 final WrappedMessage warning; | 472 final WrappedMessage warning; |
| 473 | 473 |
| 474 /// Info to report on resolving this element. | 474 /// Info to report on resolving this element. |
| 475 final WrappedMessage info; | 475 final WrappedMessage info; |
| 476 | 476 |
| 477 /// The element whose usage cause a warning. | 477 /// The element whose usage cause a warning. |
| 478 final Element wrappedElement; | 478 final Element wrappedElement; |
| 479 | 479 |
| 480 WarnOnUseElementX(WrappedMessage this.warning, WrappedMessage this.info, | 480 WarnOnUseElementX( |
| 481 Element enclosingElement, Element wrappedElement) | 481 this.warning, this.info, Element enclosingElement, Element wrappedElement) |
| 482 : this.wrappedElement = wrappedElement, | 482 : this.wrappedElement = wrappedElement, |
| 483 super(wrappedElement.name, ElementKind.WARN_ON_USE, enclosingElement); | 483 super(wrappedElement.name, ElementKind.WARN_ON_USE, enclosingElement); |
| 484 | 484 |
| 485 Element unwrap(DiagnosticReporter reporter, Spannable usageSpannable) { | 485 Element unwrap(DiagnosticReporter reporter, Spannable usageSpannable) { |
| 486 var unwrapped = wrappedElement; | 486 var unwrapped = wrappedElement; |
| 487 if (warning != null) { | 487 if (warning != null) { |
| 488 Spannable spannable = warning.spannable; | 488 Spannable spannable = warning.sourceSpan; |
| 489 if (spannable == null) spannable = usageSpannable; | 489 if (spannable == null) spannable = usageSpannable; |
| 490 DiagnosticMessage warningMessage = reporter.createMessage( | 490 DiagnosticMessage warningMessage = reporter.createMessage( |
| 491 spannable, warning.messageKind, warning.messageArguments); | 491 spannable, warning.messageKind, warning.messageArguments); |
| 492 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; | 492 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; |
| 493 if (info != null) { | 493 if (info != null) { |
| 494 Spannable spannable = info.spannable; | 494 Spannable spannable = info.sourceSpan; |
| 495 if (spannable == null) spannable = usageSpannable; | 495 if (spannable == null) spannable = usageSpannable; |
| 496 infos.add(reporter.createMessage( | 496 infos.add(reporter.createMessage( |
| 497 spannable, info.messageKind, info.messageArguments)); | 497 spannable, info.messageKind, info.messageArguments)); |
| 498 } | 498 } |
| 499 reporter.reportWarning(warningMessage, infos); | 499 reporter.reportWarning(warningMessage, infos); |
| 500 } | 500 } |
| 501 if (unwrapped.isWarnOnUse) { | 501 if (unwrapped.isWarnOnUse) { |
| 502 unwrapped = unwrapped.unwrap(reporter, usageSpannable); | 502 unwrapped = unwrapped.unwrap(reporter, usageSpannable); |
| 503 } | 503 } |
| 504 return unwrapped; | 504 return unwrapped; |
| (...skipping 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3383 body = node.asFunctionExpression().body; | 3383 body = node.asFunctionExpression().body; |
| 3384 } | 3384 } |
| 3385 return new ParsedResolvedAst( | 3385 return new ParsedResolvedAst( |
| 3386 declaration, | 3386 declaration, |
| 3387 node, | 3387 node, |
| 3388 body, | 3388 body, |
| 3389 definingElement.treeElements, | 3389 definingElement.treeElements, |
| 3390 definingElement.compilationUnit.script.resourceUri); | 3390 definingElement.compilationUnit.script.resourceUri); |
| 3391 } | 3391 } |
| 3392 } | 3392 } |
| OLD | NEW |