feat(lsp): leave the extension verdicts to the registry

Diagnostics no longer repeat the generated table's ignorance of a
registered mnemonic: unknown-instruction and unencodable-instruction
against a statement the registry encodes are filtered from the server's
own presentation, driven by asm.LookupExtension directly.  The filter is
a no-op once lint learns the registry, so the two compose unchanged.

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-07 00:06:05 +02:00
1 parent dadeda144a
commit 2d803e38d8
3 files changed
+116

No files matched your search

+38
View File
@@ -21,6 +21,8 @@ import (
"sourcedock.dev/petrbalvin/gasm-sdk/arch"
"sourcedock.dev/petrbalvin/gasm-sdk/asm"
"sourcedock.dev/petrbalvin/gasm-sdk/ast"
"sourcedock.dev/petrbalvin/gasm-sdk/lint"
)
// extFormDoc is the rendering of one registered form: everything hover and
@@ -346,3 +348,39 @@ func applyExtensionCompletion(items []CompletionItem, a arch.Arch) []CompletionI
}
return items
}
// extOwnedCode reports whether a lint code carries a verdict the extension
// layer owns: the two that accuse a mnemonic of not existing or of not being
// encodable. The operand-count rule stays with the generated table, whose
// bounds the relaxed architectures never fire against a registered form.
func extOwnedCode(code string) bool {
return code == lint.CodeUnknownInstr || code == lint.CodeUnencodable
}
// extensionMnemonicSites collects the source positions of the statements
// whose mnemonic the architecture's extension layer registers. The
// diagnostics pass consults it to leave the layer's verdicts to the layer:
// a registry mnemonic is neither unknown nor unencodable, the registry
// encodes it.
func extensionMnemonicSites(f *ast.File, a arch.Arch) map[[2]int]bool {
out := make(map[[2]int]bool)
if f == nil {
return out
}
for _, d := range f.Decls {
t, ok := d.(*ast.Text)
if !ok {
continue
}
for _, s := range t.Body {
in, ok := s.(*ast.Instr)
if !ok {
continue
}
if _, ok := asm.LookupExtension(a, in.Mnemonic.Text); ok {
out[[2]int{in.Mnemonic.Pos.Line, in.Mnemonic.Pos.Column}] = true
}
}
}
return out
}