Issue 43152. Use existing LineInfo in newDiagnosticMessage().

R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/43152
Change-Id: I1e88df0a5d2b1695b45ddfe22c84a354a9e33c4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-08-24 14:34:03 +00:00 committed by commit-bot@chromium.org
parent e868d3076c
commit 675891ae0c

View file

@ -152,16 +152,11 @@ DiagnosticMessage newDiagnosticMessage(
var file = message.filePath;
var offset = message.offset;
var length = message.length;
var startLine = -1;
var startColumn = -1;
var lineInfo = result.session.getFile(file).lineInfo;
if (lineInfo != null) {
CharacterLocation lineLocation = lineInfo.getLocation(offset);
if (lineLocation != null) {
startLine = lineLocation.lineNumber;
startColumn = lineLocation.columnNumber;
}
}
var lineLocation = result.lineInfo.getLocation(offset);
var startLine = lineLocation.lineNumber;
var startColumn = lineLocation.columnNumber;
return DiagnosticMessage(
message.message, Location(file, offset, length, startLine, startColumn));
}