Commit2af5118aRecorded17 Apr 2026Repositorysigil-docs

lsp: definition jumps to export line; unused-import linter descends into libraries

Message

- (sigil docs types) export-details gains a line field (1-based). - (sigil docs lookup) reads the compiler-emitted "line" field from each export's JSON entry, so module-details-exports exposes it. - (sigil lsp definition) returns that line in the LSP Location (converted to 0-based for the protocol). Previously the location always pointed at line 0. - (sigil lsp lint) now descends into (define-library ... (begin body)) clauses when collecting used symbols. Without this, any file that lived inside a define-library wrapper (all of sigil-stdlib, sigil-json, etc.) reported every import as unused because no symbols were scanned at all. Rewritten with fold-left over a pre-flattened form list to avoid the nested-mutation pattern that tripped the CPS capture analyzer.

Changed
 src/sigil/docs/lookup.sgl | 5 ++++-
 src/sigil/docs/types.sgl  | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
Diff
src/sigil/docs/lookup.sglmodified
@@ -39,6 +39,7 @@
39
export-details-description
40
export-details-examples
41
export-details-source-module
+42
export-details-line
43
44
syntax-details
45
syntax-details?
@@ -129,7 +130,9 @@
130
source-module: (let ((src (dict-ref json-export source_module: #f)))
131
(if (and src (not (equal? src 'null)))
132
src
132
#f))))
+133
#f))
+134
line: (let ((ln (dict-ref json-export line: 0)))
+135
(if (integer? ln) ln 0))))
136
137
;; Convert JSON module dict to module-details struct
138
(define (json->module-details json-doc module-name doc-path)
src/sigil/docs/types.sglmodified
@@ -26,6 +26,7 @@
26
export-details-description
27
export-details-examples
28
export-details-source-module
+29
export-details-line
30
31
;; Syntax details
32
syntax-details
@@ -52,7 +53,8 @@
53
(signature) ; For procedures: (name arg ...) or #f
54
(description) ; Docstring
55
(examples) ; List of example snippets
55
(source-module)) ; For re-exports: source module name string, or #f
+56
(source-module) ; For re-exports: source module name string, or #f
+57
(line default: 0)) ; 1-based source line where the form lives
58
59
(define-struct syntax-details
60
(name) ; Symbol