| OLD | NEW |
| 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 engine.source; | 5 library engine.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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 * @param lineStarts the offsets of the first character of each line in the so
urce code | 201 * @param lineStarts the offsets of the first character of each line in the so
urce code |
| 202 */ | 202 */ |
| 203 LineInfo(this._lineStarts) { | 203 LineInfo(this._lineStarts) { |
| 204 if (_lineStarts == null) { | 204 if (_lineStarts == null) { |
| 205 throw new IllegalArgumentException("lineStarts must be non-null"); | 205 throw new IllegalArgumentException("lineStarts must be non-null"); |
| 206 } else if (_lineStarts.length < 1) { | 206 } else if (_lineStarts.length < 1) { |
| 207 throw new IllegalArgumentException("lineStarts must be non-empty"); | 207 throw new IllegalArgumentException("lineStarts must be non-empty"); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 // /** | |
| 212 // * Return the offset of the first character on the line with the given | |
| 213 // * [lineNumber]. | |
| 214 // */ | |
| 215 // int getLineOffset(int lineNumber) { | |
| 216 // if (lineNumber < 0 || lineNumber >= _lineStarts.length) { | |
| 217 // throw new ArgumentError('Invalid line number: $lineNumber'); | |
| 218 // } | |
| 219 // return _lineStarts[lineNumber]; | |
| 220 // } | |
| 221 | |
| 222 /** | 211 /** |
| 223 * Return the location information for the character at the given offset. | 212 * Return the location information for the character at the given offset. |
| 224 * | 213 * |
| 225 * @param offset the offset of the character for which location information is
to be returned | 214 * @param offset the offset of the character for which location information is
to be returned |
| 226 * @return the location information for the character at the given offset | 215 * @return the location information for the character at the given offset |
| 227 */ | 216 */ |
| 228 LineInfo_Location getLocation(int offset) { | 217 LineInfo_Location getLocation(int offset) { |
| 229 var min = 0; | 218 var min = 0; |
| 230 var max = _lineStarts.length - 1; | 219 var max = _lineStarts.length - 1; |
| 231 | 220 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 251 max = midpoint - 1; | 240 max = midpoint - 1; |
| 252 } else { | 241 } else { |
| 253 min = midpoint; | 242 min = midpoint; |
| 254 } | 243 } |
| 255 } | 244 } |
| 256 | 245 |
| 257 _previousLine = min; | 246 _previousLine = min; |
| 258 | 247 |
| 259 return new LineInfo_Location(min + 1, offset - _lineStarts[min] + 1); | 248 return new LineInfo_Location(min + 1, offset - _lineStarts[min] + 1); |
| 260 } | 249 } |
| 250 |
| 251 /** |
| 252 * Return the offset of the first character on the line with the given |
| 253 * [lineNumber]. |
| 254 */ |
| 255 int getOffsetOfLine(int lineNumber) { |
| 256 if (lineNumber < 0 || lineNumber >= _lineStarts.length) { |
| 257 throw new ArgumentError('Invalid line number: $lineNumber'); |
| 258 } |
| 259 return _lineStarts[lineNumber]; |
| 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * Instances of the class `Location` represent the location of a character as a
line and | 264 * Instances of the class `Location` represent the location of a character as a
line and |
| 265 * column pair. | 265 * column pair. |
| 266 */ | 266 */ |
| 267 class LineInfo_Location { | 267 class LineInfo_Location { |
| 268 /** | 268 /** |
| 269 * The one-based index of the line containing the character. | 269 * The one-based index of the line containing the character. |
| 270 */ | 270 */ |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 Source resolveAbsolute(Uri uri, [Uri actualUri]); | 1088 Source resolveAbsolute(Uri uri, [Uri actualUri]); |
| 1089 | 1089 |
| 1090 /** | 1090 /** |
| 1091 * Return an absolute URI that represents the given [source], or `null` if a | 1091 * Return an absolute URI that represents the given [source], or `null` if a |
| 1092 * valid URI cannot be computed. | 1092 * valid URI cannot be computed. |
| 1093 * | 1093 * |
| 1094 * The computation should be based solely on [source.fullName]. | 1094 * The computation should be based solely on [source.fullName]. |
| 1095 */ | 1095 */ |
| 1096 Uri restoreAbsolute(Source source) => null; | 1096 Uri restoreAbsolute(Source source) => null; |
| 1097 } | 1097 } |
| OLD | NEW |