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

Side by Side Diff: pkg/analyzer/lib/src/generated/source.dart

Issue 1622713002: Add a count of total lines to status performance page (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixed bug Created 4 years, 11 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/analysis_server/lib/src/status/get_handler.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.source; 5 library analyzer.src.generated.source;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 /** 171 /**
172 * Return `true` if the given URI is a `dart:` URI. 172 * Return `true` if the given URI is a `dart:` URI.
173 * 173 *
174 * @param uri the URI being tested 174 * @param uri the URI being tested
175 * @return `true` if the given URI is a `dart:` URI 175 * @return `true` if the given URI is a `dart:` URI
176 */ 176 */
177 static bool isDartUri(Uri uri) => DART_SCHEME == uri.scheme; 177 static bool isDartUri(Uri uri) => DART_SCHEME == uri.scheme;
178 } 178 }
179 179
180 /** 180 /**
181 * Instances of the class `LineInfo` encapsulate information about line and colu mn information 181 * Information about line and column information within a source file.
182 * within a source file.
183 */ 182 */
184 class LineInfo { 183 class LineInfo {
185 /** 184 /**
186 * An array containing the offsets of the first character of each line in the source code. 185 * A list containing the offsets of the first character of each line in the
186 * source code.
187 */ 187 */
188 final List<int> _lineStarts; 188 final List<int> _lineStarts;
189 189
190 /** 190 /**
191 * The zero-based [_lineStarts] index resulting from the last call to 191 * The zero-based [_lineStarts] index resulting from the last call to
192 * [getLocation]. 192 * [getLocation].
193 */ 193 */
194 int _previousLine = 0; 194 int _previousLine = 0;
195 195
196 /** 196 /**
197 * Initialize a newly created set of line information to represent the data en coded in the given 197 * Initialize a newly created set of line information to represent the data
198 * array. 198 * encoded in the given list of [_lineStarts].
199 *
200 * @param lineStarts the offsets of the first character of each line in the so urce code
201 */ 199 */
202 LineInfo(this._lineStarts) { 200 LineInfo(this._lineStarts) {
203 if (_lineStarts == null) { 201 if (_lineStarts == null) {
204 throw new IllegalArgumentException("lineStarts must be non-null"); 202 throw new IllegalArgumentException("lineStarts must be non-null");
205 } else if (_lineStarts.length < 1) { 203 } else if (_lineStarts.length < 1) {
206 throw new IllegalArgumentException("lineStarts must be non-empty"); 204 throw new IllegalArgumentException("lineStarts must be non-empty");
207 } 205 }
208 } 206 }
209 207
210 /** 208 /**
211 * Return the location information for the character at the given offset. 209 * Return the number of lines in the file.
212 * 210 */
213 * @param offset the offset of the character for which location information is to be returned 211 int get lineCount => _lineStarts.length;
214 * @return the location information for the character at the given offset 212
213 /**
214 * Return the location information for the character at the given [offset].
215 */ 215 */
216 LineInfo_Location getLocation(int offset) { 216 LineInfo_Location getLocation(int offset) {
217 var min = 0; 217 var min = 0;
218 var max = _lineStarts.length - 1; 218 var max = _lineStarts.length - 1;
219 219
220 // Subsequent calls to [getLocation] are often for offsets near each other. 220 // Subsequent calls to [getLocation] are often for offsets near each other.
221 // To take advantage of that, we cache the index of the line start we found 221 // To take advantage of that, we cache the index of the line start we found
222 // when this was last called. If the current offset is on that line or 222 // when this was last called. If the current offset is on that line or
223 // later, we'll skip those early indices completely when searching. 223 // later, we'll skip those early indices completely when searching.
224 if (offset >= _lineStarts[_previousLine]) { 224 if (offset >= _lineStarts[_previousLine]) {
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 Source resolveAbsolute(Uri uri, [Uri actualUri]); 1096 Source resolveAbsolute(Uri uri, [Uri actualUri]);
1097 1097
1098 /** 1098 /**
1099 * Return an absolute URI that represents the given [source], or `null` if a 1099 * Return an absolute URI that represents the given [source], or `null` if a
1100 * valid URI cannot be computed. 1100 * valid URI cannot be computed.
1101 * 1101 *
1102 * The computation should be based solely on [source.fullName]. 1102 * The computation should be based solely on [source.fullName].
1103 */ 1103 */
1104 Uri restoreAbsolute(Source source) => null; 1104 Uri restoreAbsolute(Source source) => null;
1105 } 1105 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/status/get_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698