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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 abstract void reportDiagnostic(SourceSpan span, String message, | 879 abstract void reportDiagnostic(SourceSpan span, String message, |
| 880 api.Diagnostic kind); | 880 api.Diagnostic kind); |
| 881 | 881 |
| 882 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 882 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 883 if (begin === null || end === null) { | 883 if (begin === null || end === null) { |
| 884 // TODO(ahe): We can almost always do better. Often it is only | 884 // TODO(ahe): We can almost always do better. Often it is only |
| 885 // end that is null. Otherwise, we probably know the current | 885 // end that is null. Otherwise, we probably know the current |
| 886 // URI. | 886 // URI. |
| 887 throw 'Cannot find tokens to produce error message.'; | 887 throw 'Cannot find tokens to produce error message.'; |
| 888 } | 888 } |
| 889 if (uri === null) { | 889 if (uri === null && currentElement !== null) { |
| 890 uri = currentElement.getCompilationUnit().script.uri; | 890 uri = currentElement.getCompilationUnit().script.uri; |
| 891 } | 891 } |
| 892 return SourceSpan.withCharacterOffsets(begin, end, | 892 return SourceSpan.withCharacterOffsets(begin, end, |
| 893 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); | 893 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); |
| 894 } | 894 } |
| 895 | 895 |
| 896 SourceSpan spanFromNode(Node node, [Uri uri]) { | 896 SourceSpan spanFromNode(Node node, [Uri uri]) { |
| 897 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); | 897 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); |
| 898 } | 898 } |
| 899 | 899 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 991 static withCharacterOffsets(Token begin, Token end, | 991 static withCharacterOffsets(Token begin, Token end, |
| 992 f(int beginOffset, int endOffset)) { | 992 f(int beginOffset, int endOffset)) { |
| 993 final beginOffset = begin.charOffset; | 993 final beginOffset = begin.charOffset; |
| 994 final endOffset = end.charOffset + end.slowCharCount; | 994 final endOffset = end.charOffset + end.slowCharCount; |
| 995 | 995 |
| 996 // [begin] and [end] might be the same for the same empty token. This | 996 // [begin] and [end] might be the same for the same empty token. This |
| 997 // happens for instance when scanning '$$'. | 997 // happens for instance when scanning '$$'. |
| 998 assert(endOffset >= beginOffset); | 998 assert(endOffset >= beginOffset); |
| 999 return f(beginOffset, endOffset); | 999 return f(beginOffset, endOffset); |
| 1000 } | 1000 } |
| 1001 | |
| 1002 String toString() { | |
|
kasperl
2012/07/06 12:40:41
Use => notation?
Johnni Winther
2012/07/09 14:57:18
Done.
| |
| 1003 return 'SourceSpan($uri,$begin,$end)'; | |
| 1004 } | |
| 1001 } | 1005 } |
| OLD | NEW |