Fix LineInfo.getOffsetOfLineAfter().

Or we could remove it altogether.
It is not used outside of analyzer/analysis_server/analyzer_plugin.

R=brianwilkerson@google.com

Change-Id: I89c90fc0881f2b1602128f8aacdda2762c4e7920
Reviewed-on: https://dart-review.googlesource.com/54306
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2018-05-08 20:28:07 +00:00
committed by commit-bot@chromium.org
parent f2b137343c
commit cc034472bb
2 changed files with 21 additions and 4 deletions
+1 -1
View File
@@ -119,6 +119,6 @@ class LineInfo {
* containing the given [offset].
*/
int getOffsetOfLineAfter(int offset) {
return getOffsetOfLine(getLocation(offset).lineNumber + 1);
return getOffsetOfLine(getLocation(offset).lineNumber);
}
}
@@ -2546,26 +2546,43 @@ class LineInfoTest {
}, throwsArgumentError);
}
void test_firstLine() {
void test_getLocation_firstLine() {
LineInfo info = new LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(4);
expect(location.lineNumber, 1);
expect(location.columnNumber, 5);
}
void test_lastLine() {
void test_getLocation_lastLine() {
LineInfo info = new LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(36);
expect(location.lineNumber, 3);
expect(location.columnNumber, 3);
}
void test_middleLine() {
void test_getLocation_middleLine() {
LineInfo info = new LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(12);
expect(location.lineNumber, 2);
expect(location.columnNumber, 1);
}
void test_getOffsetOfLine() {
LineInfo info = new LineInfo(<int>[0, 12, 34]);
expect(0, info.getOffsetOfLine(0));
expect(12, info.getOffsetOfLine(1));
expect(34, info.getOffsetOfLine(2));
}
void test_getOffsetOfLineAfter() {
LineInfo info = new LineInfo(<int>[0, 12, 34]);
expect(info.getOffsetOfLineAfter(0), 12);
expect(info.getOffsetOfLineAfter(11), 12);
expect(info.getOffsetOfLineAfter(12), 34);
expect(info.getOffsetOfLineAfter(33), 34);
}
}
class ListGetter_NodeReplacerTest_test_adjacentStrings