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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 abstract void reportDiagnostic(SourceSpan span, String message, | 930 abstract void reportDiagnostic(SourceSpan span, String message, |
931 api.Diagnostic kind); | 931 api.Diagnostic kind); |
932 | 932 |
933 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 933 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
934 if (begin === null || end === null) { | 934 if (begin === null || end === null) { |
935 // TODO(ahe): We can almost always do better. Often it is only | 935 // TODO(ahe): We can almost always do better. Often it is only |
936 // end that is null. Otherwise, we probably know the current | 936 // end that is null. Otherwise, we probably know the current |
937 // URI. | 937 // URI. |
938 throw 'Cannot find tokens to produce error message.'; | 938 throw 'Cannot find tokens to produce error message.'; |
939 } | 939 } |
940 if (uri === null) { | 940 if (uri === null && currentElement !== null) { |
941 uri = currentElement.getCompilationUnit().script.uri; | 941 uri = currentElement.getCompilationUnit().script.uri; |
942 } | 942 } |
943 return SourceSpan.withCharacterOffsets(begin, end, | 943 return SourceSpan.withCharacterOffsets(begin, end, |
944 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); | 944 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); |
945 } | 945 } |
946 | 946 |
947 SourceSpan spanFromNode(Node node, [Uri uri]) { | 947 SourceSpan spanFromNode(Node node, [Uri uri]) { |
948 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); | 948 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); |
949 } | 949 } |
950 | 950 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1042 static withCharacterOffsets(Token begin, Token end, | 1042 static withCharacterOffsets(Token begin, Token end, |
1043 f(int beginOffset, int endOffset)) { | 1043 f(int beginOffset, int endOffset)) { |
1044 final beginOffset = begin.charOffset; | 1044 final beginOffset = begin.charOffset; |
1045 final endOffset = end.charOffset + end.slowCharCount; | 1045 final endOffset = end.charOffset + end.slowCharCount; |
1046 | 1046 |
1047 // [begin] and [end] might be the same for the same empty token. This | 1047 // [begin] and [end] might be the same for the same empty token. This |
1048 // happens for instance when scanning '$$'. | 1048 // happens for instance when scanning '$$'. |
1049 assert(endOffset >= beginOffset); | 1049 assert(endOffset >= beginOffset); |
1050 return f(beginOffset, endOffset); | 1050 return f(beginOffset, endOffset); |
1051 } | 1051 } |
1052 | |
1053 String toString() => 'SourceSpan($uri,$begin,$end)'; | |
Bob Nystrom
2012/07/09 16:59:55
Spaces after ",".
Johnni Winther
2012/07/12 08:51:39
Done.
| |
1052 } | 1054 } |
OLD | NEW |