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

Side by Side Diff: pkg/compiler/lib/src/diagnostics/source_span.dart

Issue 1661853005: Introduce getPrefixEndToken to avoid too big context in messages. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library dart2js.diagnostics.source_span; 5 library dart2js.diagnostics.source_span;
6 6
7 import '../tokens/token.dart' show 7 import '../tokens/token.dart' show
8 Token; 8 Token;
9 import '../tree/tree.dart' show 9 import '../tree/tree.dart' show
10 Node; 10 Node;
11 import 'spannable.dart' show 11 import 'spannable.dart' show
12 Spannable; 12 Spannable;
13 13
14 class SourceSpan implements Spannable { 14 class SourceSpan implements Spannable {
15 final Uri uri; 15 final Uri uri;
16 final int begin; 16 final int begin;
17 final int end; 17 final int end;
18 18
19 const SourceSpan(this.uri, this.begin, this.end); 19 const SourceSpan(this.uri, this.begin, this.end);
20 20
21 factory SourceSpan.fromNode(Uri uri, Node node) { 21 factory SourceSpan.fromNode(Uri uri, Node node) {
22 return new SourceSpan.fromTokens( 22 return new SourceSpan.fromTokens(
23 uri, node.getBeginToken(), node.getEndToken()); 23 uri, node.getBeginToken(), node.getPrefixEndToken());
24 } 24 }
25 25
26 factory SourceSpan.fromTokens(Uri uri, Token begin, Token end) { 26 factory SourceSpan.fromTokens(Uri uri, Token begin, Token end) {
27 final beginOffset = begin.charOffset; 27 final beginOffset = begin.charOffset;
28 final endOffset = end.charOffset + end.charCount; 28 final endOffset = end.charOffset + end.charCount;
29 29
30 // [begin] and [end] might be the same for the same empty token. This 30 // [begin] and [end] might be the same for the same empty token. This
31 // happens for instance when scanning '$$'. 31 // happens for instance when scanning '$$'.
32 assert(endOffset >= beginOffset); 32 assert(endOffset >= beginOffset);
33 return new SourceSpan(uri, beginOffset, endOffset); 33 return new SourceSpan(uri, beginOffset, endOffset);
34 } 34 }
35 35
36 int get hashCode { 36 int get hashCode {
37 return 13 * uri.hashCode + 37 return 13 * uri.hashCode +
38 17 * begin.hashCode + 38 17 * begin.hashCode +
39 19 * end.hashCode; 39 19 * end.hashCode;
40 } 40 }
41 41
42 bool operator ==(other) { 42 bool operator ==(other) {
43 if (identical(this, other)) return true; 43 if (identical(this, other)) return true;
44 if (other is! SourceSpan) return false; 44 if (other is! SourceSpan) return false;
45 return uri == other.uri && 45 return uri == other.uri &&
46 begin == other.begin && 46 begin == other.begin &&
47 end == other.end; 47 end == other.end;
48 } 48 }
49 49
50 String toString() => 'SourceSpan($uri, $begin, $end)'; 50 String toString() => 'SourceSpan($uri, $begin, $end)';
51 } 51 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698