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

Unified Diff: pkg/analyzer/lib/src/generated/source.dart

Issue 1625783002: Rework recent changes to LineInfo to be backward compatible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/source.dart
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 8d5d3fde643866a2d7d5c6141faf7ce670766b64..0fae83a01853d234957ecf8969010ff3314a0e34 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -197,7 +197,13 @@ class LineInfo {
* Initialize a newly created set of line information to represent the data
* encoded in the given list of [_lineStarts].
*/
- LineInfo(this._lineStarts) {
+ factory LineInfo(List<int> _lineStarts) => new LineInfoWithCount(_lineStarts);
+
+ /**
+ * Initialize a newly created set of line information to represent the data
+ * encoded in the given list of [_lineStarts].
+ */
+ LineInfo._(this._lineStarts) {
if (_lineStarts == null) {
throw new IllegalArgumentException("lineStarts must be non-null");
} else if (_lineStarts.length < 1) {
@@ -206,11 +212,6 @@ class LineInfo {
}
/**
- * Return the number of lines in the file.
- */
- int get lineCount => _lineStarts.length;
-
- /**
* Return the location information for the character at the given [offset].
*/
LineInfo_Location getLocation(int offset) {
@@ -288,6 +289,26 @@ class LineInfo_Location {
}
/**
+ * Information about line and column information within a source file,
+ * including a count of the total number of lines.
+ *
+ * TODO(paulberry): in the next major version roll of analyzer, merge this
+ * class into [LineInfo].
+ */
+class LineInfoWithCount extends LineInfo {
+ /**
+ * Initialize a newly created set of line information to represent the data
+ * encoded in the given list of [_lineStarts].
+ */
+ LineInfoWithCount(List<int> _lineStarts) : super._(_lineStarts);
+
+ /**
+ * Return the number of lines in the file.
+ */
+ int get lineCount => _lineStarts.length;
+}
+
+/**
* Instances of interface `LocalSourcePredicate` are used to determine if the given
* [Source] is "local" in some sense, so can be updated.
*/
« 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