Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Unreleased
- Added support for `enclosing_range` on occurrences definitions

## 1.6.2
- Fixed a few minor bugs found in pubspec.yaml indexing (skips publish_to: none pubspecs, and considers "version" optional)
- Updates version constraints to support running on dart 3
Expand Down
10 changes: 6 additions & 4 deletions lib/src/scip_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ class ScipVisitor extends GeneralizingAstVisitor {
)) {
final meta = getSymbolMetadata(element, offset, _analysisErrors);
globalExternalSymbols.add(SymbolInformation(
symbol: symbol,
documentation: meta.documentation,
signatureDocumentation: meta.signatureDocumentation,
kind: symbolKindFor(element)));
symbol: symbol,
documentation: meta.documentation,
signatureDocumentation: meta.signatureDocumentation,
kind: symbolKindFor(element),
));
}
}
}
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.offset, node.end),
));
}
}
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