| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 } | 798 } |
| 799 | 799 |
| 800 SourceSpan spanFromNode(Node node, [Uri uri]) { | 800 SourceSpan spanFromNode(Node node, [Uri uri]) { |
| 801 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); | 801 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); |
| 802 } | 802 } |
| 803 | 803 |
| 804 SourceSpan spanFromElement(Element element) { | 804 SourceSpan spanFromElement(Element element) { |
| 805 if (Elements.isErroneousElement(element)) { | 805 if (Elements.isErroneousElement(element)) { |
| 806 element = element.enclosingElement; | 806 element = element.enclosingElement; |
| 807 } | 807 } |
| 808 if (element.position() == null) { | 808 if (element.position() == null && !element.isCompilationUnit()) { |
| 809 // Sometimes, the backend fakes up elements that have no | 809 // Sometimes, the backend fakes up elements that have no |
| 810 // position. So we use the enclosing element instead. It is | 810 // position. So we use the enclosing element instead. It is |
| 811 // not a good error location, but cancel really is "internal | 811 // not a good error location, but cancel really is "internal |
| 812 // error" or "not implemented yet", so the vicinity is good | 812 // error" or "not implemented yet", so the vicinity is good |
| 813 // enough for now. | 813 // enough for now. |
| 814 element = element.enclosingElement; | 814 element = element.enclosingElement; |
| 815 // TODO(ahe): I plan to overhaul this infrastructure anyways. | 815 // TODO(ahe): I plan to overhaul this infrastructure anyways. |
| 816 } | 816 } |
| 817 if (element == null) { | 817 if (element == null) { |
| 818 element = currentElement; | 818 element = currentElement; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 940 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 941 // information on assertion errors. | 941 // information on assertion errors. |
| 942 if (condition is Function){ | 942 if (condition is Function){ |
| 943 condition = condition(); | 943 condition = condition(); |
| 944 } | 944 } |
| 945 if (spannable == null || !condition) { | 945 if (spannable == null || !condition) { |
| 946 throw new SpannableAssertionFailure(spannable, message); | 946 throw new SpannableAssertionFailure(spannable, message); |
| 947 } | 947 } |
| 948 return true; | 948 return true; |
| 949 } | 949 } |
| OLD | NEW |