Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/src/scip_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class ScipVisitor extends GeneralizingAstVisitor {
range: _lineInfo.getRange(offset, length),
symbol: symbol,
diagnostics: meta.diagnostics,
enclosingRange: _lineInfo.getRange(node.parent!.offset, node.parent!.length)
));

if (!element.source!.fullName.startsWith(_projectRoot)) {
Expand Down Expand Up @@ -179,6 +180,7 @@ class ScipVisitor extends GeneralizingAstVisitor {
symbol: symbol,
symbolRoles: SymbolRole.Definition.value,
diagnostics: meta.diagnostics,
enclosingRange: _lineInfo.getRange(node.parent!.offset, node.parent!.length)
));
}
}
22 changes: 17 additions & 5 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ void display(String input, {DisplayLevel level = DisplayLevel.warn}) {

extension LineInfoExtension on LineInfo {
List<int> getRange(int offset, int nameLength) {
final loc = getLocation(offset);
return [
loc.lineNumber - 1,
loc.columnNumber - 1,
loc.columnNumber - 1 + nameLength
final start = getLocation(offset);
final end = getLocation(offset + nameLength);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enclosing_range is the first symbol that will commonly span multiple lines. as such our old getRange function wasn't built to handle this. That's what these updates are doing


final res = [
start.lineNumber - 1,
start.columnNumber - 1,
end.lineNumber - 1,
end.columnNumber - 1,
];

// if the range starts and ends on the same line, only return
// 3 elements, where the first is the line number, and the others
// are startCol and endCol. This is apart of the scip spec
if (res[0] == res[2]) {
res.removeAt(2);
}

return res;
}
}

Expand Down
Loading