Chromium Code Reviews| 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 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 // URI. | 774 // URI. |
| 775 throw 'Cannot find tokens to produce error message.'; | 775 throw 'Cannot find tokens to produce error message.'; |
| 776 } | 776 } |
| 777 if (uri === null) { | 777 if (uri === null) { |
| 778 uri = currentElement.getCompilationUnit().script.uri; | 778 uri = currentElement.getCompilationUnit().script.uri; |
| 779 } | 779 } |
| 780 return SourceSpan.withOffsets(begin, end, (beginOffset, endOffset) => | 780 return SourceSpan.withOffsets(begin, end, (beginOffset, endOffset) => |
| 781 new SourceSpan(uri, beginOffset, endOffset)); | 781 new SourceSpan(uri, beginOffset, endOffset)); |
| 782 } | 782 } |
| 783 | 783 |
| 784 SourceSpan spanFromNode(Node node) { | 784 SourceSpan spanFromNode(Node node, [Uri uri]) { |
| 785 return spanFromTokens(node.getBeginToken(), node.getEndToken()); | 785 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); |
| 786 } | 786 } |
| 787 | 787 |
| 788 SourceSpan spanFromElement(Element element) { | 788 SourceSpan spanFromElement(Element element) { |
| 789 if (element.position() === null) { | 789 if (element.position() === null) { |
| 790 // Sometimes, the backend fakes up elements that have no | 790 // Sometimes, the backend fakes up elements that have no |
| 791 // position. So we use the enclosing element instead. It is | 791 // position. So we use the enclosing element instead. It is |
| 792 // not a good error location, but cancel really is "internal | 792 // not a good error location, but cancel really is "internal |
| 793 // error" or "not implemented yet", so the vicinity is good | 793 // error" or "not implemented yet", so the vicinity is good |
| 794 // enough for now. | 794 // enough for now. |
| 795 element = element.enclosingElement; | 795 element = element.enclosingElement; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 } | 869 } |
| 870 } | 870 } |
| 871 | 871 |
| 872 class SourceSpan { | 872 class SourceSpan { |
| 873 final Uri uri; | 873 final Uri uri; |
| 874 final int begin; | 874 final int begin; |
| 875 final int end; | 875 final int end; |
| 876 | 876 |
| 877 const SourceSpan(this.uri, this.begin, this.end); | 877 const SourceSpan(this.uri, this.begin, this.end); |
| 878 | 878 |
| 879 static withOffsets(Token begin, Token end, | 879 static withOffsets(Token begin, Token end, |
|
Lasse Reichstein Nielsen
2012/06/27 09:22:16
withOffsets -> withCharacterOffsets ?
| |
| 880 f(int beginOffset, int endOffset)) { | 880 f(int beginOffset, int endOffset)) { |
| 881 final beginOffset = begin.charOffset; | 881 final beginOffset = begin.charOffset; |
| 882 // TODO(ahe): Compute proper end offset in token. Right now we use | 882 final endOffset = end.charOffset + end.slowCharLength; |
|
Lasse Reichstein Nielsen
2012/06/27 09:22:16
slowCharLength -> slowCharCount
| |
| 883 // the position of the next token. We want to preserve the | 883 |
| 884 // invariant that endOffset > beginOffset, but for EOF the | 884 // [begin] and [end] might be the same empty token. This happens for |
|
Lasse Reichstein Nielsen
2012/06/27 09:22:16
"the same empty token" -> "the same for the empty
| |
| 885 // charoffset of the next token may be [beginOffset]. This can | 885 // instance when parsing '$$'. |
|
Lasse Reichstein Nielsen
2012/06/27 09:22:16
parsing -> scanning.
| |
| 886 // also happen for synthetized tokens that are produced during | 886 assert(endOffset >= beginOffset); |
| 887 // error handling. | |
| 888 final endOffset = | |
| 889 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); | |
| 890 assert(endOffset > beginOffset); | |
| 891 return f(beginOffset, endOffset); | 887 return f(beginOffset, endOffset); |
| 892 } | 888 } |
| 893 } | 889 } |
| OLD | NEW |