Skip to content

Commit bdbc31d

Browse files
committed
feat: improve hover accuracy
chore: update changelog to describe better what 0.0.1 will include
1 parent 3f85ff1 commit bdbc31d

5 files changed

Lines changed: 107 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,76 @@ All notable changes to the "sac-language-support" extension will be documented i
44

55
## [0.0.1]: [release date]
66

7-
- Added a minimal SaC language server that publishes compiler diagnostics.
8-
- Added configurable diagnostics modes (`onSave`, `onType`, `manual`).
9-
- Added compiler resolution strategy with `system`, `stable`, and `develop` channels.
10-
- Added machine-readable diagnostics parsing support via configurable messaging arguments.
11-
- Added bundled compiler folder conventions under `vendor/sac2c/`.
7+
### Language + Editor Support
8+
9+
- Added SaC language registration for `.sac` files.
10+
- Added language configuration for editor behaviors (comments/brackets/word boundaries).
11+
- Added SaC TextMate grammar + injection support for SaC-aware highlighting inside C scopes.
12+
- Added built-in SaC snippets.
13+
- Added SaC file icon contribution and icon theme mapping.
14+
- Added multiple bundled SaC color themes (`Default`, `Warm`, `Cool`, `Vibrant`).
15+
16+
### Language Server (LSP)
17+
18+
- Added SaC language server activation and lifecycle wiring from the extension host.
19+
- Added diagnostics publication to Problems panel + inline squiggles.
20+
- Added hover provider for:
21+
- builtins + stdlib docs from `docs/builtins` and `docs/stdlib`
22+
- compiler-index-backed symbols when available
23+
- source-defined function docs/signatures fallback
24+
- Added go-to-definition provider using compiler navigation index with source/stdlib fallbacks.
25+
- Added safe server error handling (`runSafely`) so failures are logged instead of crashing server process.
26+
27+
### Diagnostics Pipeline
28+
29+
- Added diagnostics execution modes: `onSave`, `onType` (debounced), `manual`.
30+
- Added diagnostics presentation modes: `expanded`, `smart`, `hybrid`.
31+
- Added best-effort parser/grouping pipeline for `sac2c` output.
32+
- Added related information + stack/context rendering controls:
33+
- `sac.diagnostics.includeRelatedInformation`
34+
- `sac.diagnostics.includeStackInMessage`
35+
- `sac.diagnostics.maxStackFrames`
36+
- Added workspace-wide diagnostics scan controls:
37+
- `sac.diagnostics.workspaceScan.enabled`
38+
- `sac.diagnostics.workspaceScan.onInitialize`
39+
- `sac.diagnostics.workspaceScan.onConfigurationChange`
40+
- `sac.diagnostics.workspaceScan.excludeDirectories`
41+
42+
**Compiler prerequisite (current fork status):**
43+
44+
- Error-column diagnostics improvements rely on sac2c branch: <https://gitlab.sac-home.org/LuckyLuuk/sac2c/-/tree/luukk/error-end-column>
45+
- Related upstream MR draft: <https://gitlab.sac-home.org/sac-group/sac2c/-/merge_requests/633>
46+
47+
### Compiler Resolution + Execution
48+
49+
- Added compiler resolution strategy with channels: `system`, `stable`, `develop`.
50+
- Added explicit compiler path override via `sac.compiler.path`.
51+
- Added fallback behavior to system compiler when bundled channel binary is missing.
52+
- Added backend execution modes:
53+
- `local`
54+
- `wsl` (Windows host)
55+
- `docker`
56+
- Added configurable extra compiler args and deterministic messaging args:
57+
- `sac.compiler.extraArgs`
58+
- `sac.compiler.messaging.enabled`
59+
- `sac.compiler.messaging.args`
60+
61+
### Navigation + Hover Docs Infrastructure
62+
63+
- Added markdown documentation lookup + formatting pipeline for hover content.
64+
- Added heading/section parsing helpers for richer hover rendering.
65+
- Added builtin family doc resolution (for example `_add_SxS_` -> `_add_.md`).
66+
- Added hover/definition runtime tracing controls via `sac.compiler.trace` and debug logging hooks.
67+
68+
**Compiler prerequisite (current fork status):**
69+
70+
- Hover/navigation output-phase support currently depends on fork branch: <https://gitlab.sac-home.org/LuckyLuuk/sac2c/-/commits/luukk/vscode-extension-output-phase>
71+
72+
### Repository + Packaging Foundations
73+
74+
- Added diagnostics architecture docs (`docs/diagnostics-pipeline.md`, `docs/editor-agnostic-diagnostics.md`).
75+
- Added extension packaging optimization:
76+
- esbuild bundle pipeline for extension + server outputs
77+
- prepublish bundle hook before `vsce package`
78+
- lean `.vscodeignore` rules for smaller VSIX artifacts
79+
- Added initial GitHub workflow foundation for nightly/stable VSIX release automation.

src/sac2c/hover/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function lookupHoverTarget(lineText: string, column: number): HoverMatch
139139
return stdlib;
140140
}
141141

142-
return lookupAnyCallIdentifier(lineText, column);
142+
return null;
143143
}
144144

145145
/**

src/sac2c/parser/navigation/sourceDocs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,13 @@ export function findFunctionDefinitionLineByName(sourceText: string, functionNam
426426

427427
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
428428
const lineText = lines[lineIndex];
429-
if (pattern.test(lineText)) {
429+
const trimmed = lineText.trim();
430+
if (trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*")) {
431+
continue;
432+
}
433+
434+
const nextNonEmptyLine = lines.slice(lineIndex + 1).find((nextLine) => nextLine.trim().length > 0);
435+
if (pattern.test(lineText) && isPotentialFunctionDefinitionLine(lineText, nextNonEmptyLine)) {
430436
return lineIndex;
431437
}
432438
}

src/server/hover-info/hover.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,18 @@ export async function provideHover(
162162
const docComment = readDefinitionDocComment(compilerHover.definitionPath, compilerHover.definitionLine);
163163
const sourceSignature = readDefinitionSignature(compilerHover.definitionPath, compilerHover.definitionLine);
164164
const preferredSignature = pickPreferredSignature(compilerHover.signature, sourceSignature);
165+
const isUserSymbol = compilerHover.symbolProvenance === "user";
165166
let docsMarkdown: string | null = null;
166167
const docsTargets: HoverTarget[] = [];
167-
if (lexedMatch) {
168+
169+
// For user symbols, docs must come from resolved definition comments only.
170+
if (!isUserSymbol && lexedMatch) {
168171
docsTargets.push(lexedMatch.target);
169172
}
170173
if (compilerTarget) {
171174
docsTargets.push(compilerTarget);
172175
}
173-
if (compilerHover.symbolProvenance !== "user") {
176+
if (!isUserSymbol) {
174177
const symbolNameTarget = hoverTargetFromSymbolName(compilerHover.symbolName);
175178
if (symbolNameTarget) {
176179
docsTargets.push(symbolNameTarget);
@@ -184,7 +187,7 @@ export async function provideHover(
184187
}
185188
}
186189

187-
const preferStaticDocs = compilerHover.symbolProvenance !== "user";
190+
const preferStaticDocs = !isUserSymbol;
188191
const docBody = preferStaticDocs ? (docsMarkdown ?? docComment) : (docComment ?? docsMarkdown);
189192
const metadata = [
190193
`Kind: \`${compilerHover.symbolKind}\``,
@@ -199,6 +202,14 @@ export async function provideHover(
199202

200203
const hasUsefulDocs = Boolean(docBody?.trim());
201204
const hasUsefulSignature = Boolean(preferredSignature?.trim());
205+
206+
if (isUserSymbol) {
207+
return {
208+
contents: createMarkdownContent(markdown),
209+
range: compilerHover.range,
210+
};
211+
}
212+
202213
if (!hasUsefulDocs && !hasUsefulSignature) {
203214
logHoverDebug("hover-compiler-low-confidence-fallback", {
204215
symbolName: compilerHover.symbolName,
@@ -248,19 +259,18 @@ export async function provideHover(
248259
const filePath = fileURLToPath(document.uri);
249260
const docComment = readDefinitionDocComment(filePath, definitionLine);
250261
const signature = readDefinitionSignature(filePath, definitionLine);
251-
if (!docComment && !signature) {
252-
return null;
262+
if (docComment || signature) {
263+
logHoverDebug("hover-source-call-hit", {
264+
name: sourceCall.name,
265+
definitionLine,
266+
hasDocComment: Boolean(docComment),
267+
}, debugLog);
268+
269+
return {
270+
contents: createMarkdownContent(formatHoverDocumentationMarkdown(docComment ?? "", { signature })),
271+
range: createLineRange(position.line, sourceCall.startCharacter, sourceCall.endCharacter),
272+
};
253273
}
254-
logHoverDebug("hover-source-call-hit", {
255-
name: sourceCall.name,
256-
definitionLine,
257-
hasDocComment: Boolean(docComment),
258-
}, debugLog);
259-
260-
return {
261-
contents: createMarkdownContent(formatHoverDocumentationMarkdown(docComment ?? "", { signature })),
262-
range: createLineRange(position.line, sourceCall.startCharacter, sourceCall.endCharacter),
263-
};
264274
}
265275
}
266276
}

src/server/navigation/compilerCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function buildNavArgs(
6767
"-v0",
6868
"-navjson",
6969
"-nav-mode",
70-
"document-symbols",
70+
mode,
7171
"-nav-file",
7272
documentFsPath,
7373
"-nav-line",

0 commit comments

Comments
 (0)