Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: pkg/compiler/lib/src/diagnostics/source_span.dart

Issue 1314973003: Add support for analyzing individual URIs. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/diagnostics/source_span.dart
diff --git a/pkg/compiler/lib/src/diagnostics/source_span.dart b/pkg/compiler/lib/src/diagnostics/source_span.dart
index bd5ed57b3f88935d386a835085f9b8190349967a..9fe080ca8797ec592000edb1cdce6d0c0fed1624 100644
--- a/pkg/compiler/lib/src/diagnostics/source_span.dart
+++ b/pkg/compiler/lib/src/diagnostics/source_span.dart
@@ -6,6 +6,8 @@ library dart2js.diagnostics.source_span;
import '../scanner/scannerlib.dart' show
Token;
+import '../tree/tree.dart' show
+ Node;
import 'spannable.dart' show
Spannable;
@@ -16,15 +18,19 @@ class SourceSpan implements Spannable {
const SourceSpan(this.uri, this.begin, this.end);
- static withCharacterOffsets(Token begin, Token end,
- f(int beginOffset, int endOffset)) {
+ factory SourceSpan.fromNode(Uri uri, Node node) {
+ return new SourceSpan.fromTokens(
+ uri, node.getBeginToken(), node.getEndToken());
+ }
+
+ factory SourceSpan.fromTokens(Uri uri, Token begin, Token end) {
final beginOffset = begin.charOffset;
final endOffset = end.charOffset + end.charCount;
// [begin] and [end] might be the same for the same empty token. This
// happens for instance when scanning '$$'.
assert(endOffset >= beginOffset);
- return f(beginOffset, endOffset);
+ return new SourceSpan(uri, beginOffset, endOffset);
}
int get hashCode {
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698