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

Side by Side Diff: utils/template/source.dart

Issue 12288040: Reapply "Make Comparable generic." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix problems. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/version.dart ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // TODO(jimhug): This should be an interface to work better with tools. 5 // TODO(jimhug): This should be an interface to work better with tools.
6 /** 6 /**
7 * Represents a file of source code. 7 * Represents a file of source code.
8 */ 8 */
9 class SourceFile implements Comparable { 9 class SourceFile implements Comparable<SourceFile> {
10 // TODO(terry): This filename for in memory buffer. May need to rework if 10 // TODO(terry): This filename for in memory buffer. May need to rework if
11 // filename is used for more than informational. 11 // filename is used for more than informational.
12 static String IN_MEMORY_FILE = '<buffer>'; 12 static String IN_MEMORY_FILE = '<buffer>';
13 13
14 /** The name of the file. */ 14 /** The name of the file. */
15 final String filename; 15 final String filename;
16 16
17 /** The text content of the file. */ 17 /** The text content of the file. */
18 String _text; 18 String _text;
19 19
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 } 126 }
127 127
128 128
129 /** 129 /**
130 * A range of characters in a [SourceFile]. Used to represent the source 130 * A range of characters in a [SourceFile]. Used to represent the source
131 * positions of [Token]s and [Node]s for error reporting or other tooling 131 * positions of [Token]s and [Node]s for error reporting or other tooling
132 * work. 132 * work.
133 */ 133 */
134 // TODO(jmesserly): Rename to Span - but first write cool refactoring tool 134 // TODO(jmesserly): Rename to Span - but first write cool refactoring tool
135 class SourceSpan implements Comparable { 135 class SourceSpan implements Comparable<SourceSpan> {
136 /** The [SourceFile] that contains this span. */ 136 /** The [SourceFile] that contains this span. */
137 final SourceFile file; 137 final SourceFile file;
138 138
139 /** The character position of the start of this span. */ 139 /** The character position of the start of this span. */
140 final int start; 140 final int start;
141 141
142 /** The character position of the end of this span. */ 142 /** The character position of the end of this span. */
143 final int end; 143 final int end;
144 144
145 SourceSpan(this.file, this.start, this.end); 145 SourceSpan(this.file, this.start, this.end);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 /** Compares two source spans by file and position. Handles nulls. */ 178 /** Compares two source spans by file and position. Handles nulls. */
179 int compareTo(SourceSpan other) { 179 int compareTo(SourceSpan other) {
180 if (file == other.file) { 180 if (file == other.file) {
181 int d = start - other.start; 181 int d = start - other.start;
182 return d == 0 ? (end - other.end) : d; 182 return d == 0 ? (end - other.end) : d;
183 } 183 }
184 return file.compareTo(other.file); 184 return file.compareTo(other.file);
185 } 185 }
186 } 186 }
OLDNEW
« no previous file with comments | « utils/pub/version.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698