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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 abstract void reportDiagnostic(SourceSpan span, String message, | 970 abstract void reportDiagnostic(SourceSpan span, String message, |
| 971 api.Diagnostic kind); | 971 api.Diagnostic kind); |
| 972 | 972 |
| 973 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 973 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 974 if (begin === null || end === null) { | 974 if (begin === null || end === null) { |
| 975 // TODO(ahe): We can almost always do better. Often it is only | 975 // TODO(ahe): We can almost always do better. Often it is only |
| 976 // end that is null. Otherwise, we probably know the current | 976 // end that is null. Otherwise, we probably know the current |
| 977 // URI. | 977 // URI. |
| 978 throw 'Cannot find tokens to produce error message.'; | 978 throw 'Cannot find tokens to produce error message.'; |
| 979 } | 979 } |
| 980 if (uri === null) { | 980 if (uri === null && currentElement !== null) { |
|
ahe
2012/08/02 19:56:23
currentElement may not be null.
| |
| 981 uri = currentElement.getCompilationUnit().script.uri; | 981 uri = currentElement.getCompilationUnit().script.uri; |
| 982 } | 982 } |
| 983 return SourceSpan.withCharacterOffsets(begin, end, | 983 return SourceSpan.withCharacterOffsets(begin, end, |
| 984 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); | 984 (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset)); |
| 985 } | 985 } |
| 986 | 986 |
| 987 SourceSpan spanFromNode(Node node, [Uri uri]) { | 987 SourceSpan spanFromNode(Node node, [Uri uri]) { |
| 988 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); | 988 return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri); |
| 989 } | 989 } |
| 990 | 990 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1082 static withCharacterOffsets(Token begin, Token end, | 1082 static withCharacterOffsets(Token begin, Token end, |
| 1083 f(int beginOffset, int endOffset)) { | 1083 f(int beginOffset, int endOffset)) { |
| 1084 final beginOffset = begin.charOffset; | 1084 final beginOffset = begin.charOffset; |
| 1085 final endOffset = end.charOffset + end.slowCharCount; | 1085 final endOffset = end.charOffset + end.slowCharCount; |
| 1086 | 1086 |
| 1087 // [begin] and [end] might be the same for the same empty token. This | 1087 // [begin] and [end] might be the same for the same empty token. This |
| 1088 // happens for instance when scanning '$$'. | 1088 // happens for instance when scanning '$$'. |
| 1089 assert(endOffset >= beginOffset); | 1089 assert(endOffset >= beginOffset); |
| 1090 return f(beginOffset, endOffset); | 1090 return f(beginOffset, endOffset); |
| 1091 } | 1091 } |
| 1092 | |
| 1093 String toString() => 'SourceSpan($uri, $begin, $end)'; | |
| 1092 } | 1094 } |
| OLD | NEW |