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

+68
View File
@@ -283,3 +283,71 @@ func TestExtensionHoverWithoutProse(t *testing.T) {
}
}
}
// TestDiagnosticsExtensionOwnedARM64 pins the pass-through on arm64: the
// lint on this base still reports a registered mnemonic as unknown, and the
// server filters its own presentation through the registry, while a mnemonic
// no layer registers stays reported.
func TestDiagnosticsExtensionOwnedARM64(t *testing.T) {
diags := publishedDiagnostics(t, "file:///v_arm64.s", sveDoc)
for _, d := range diags {
if strings.Contains(d.Message, "SQADD") {
t.Errorf("registry mnemonic still reported: %+v", d)
}
}
unknown := 0
for _, d := range diags {
if d.Code == "unknown-instruction" {
unknown++
if !strings.Contains(d.Message, "NOSUCHTHING") {
t.Errorf("unknown-instruction against the wrong statement: %+v", d)
}
}
}
if unknown != 1 {
t.Errorf("unknown-instruction count = %d, want the one unregistered mnemonic", unknown)
}
}
// TestDiagnosticsExtensionOwnedFocused is the focused filter test: the
// server's own diagnostic computation, without the protocol, answers nothing
// against the registered mnemonics and keeps everything else.
func TestDiagnosticsExtensionOwnedFocused(t *testing.T) {
srv := &Server{docs: map[string]string{"file:///v_arm64.s": sveDoc}}
diags := srv.diagnosticsFor("file:///v_arm64.s")
if len(diags) == 0 {
t.Fatal("diagnostics empty, want the unregistered mnemonic")
}
for _, d := range diags {
switch {
case strings.Contains(d.Message, "SQADD"):
t.Errorf("registry mnemonic still reported: %+v", d)
case d.Code == "unknown-instruction":
if !strings.Contains(d.Message, "NOSUCHTHING") {
t.Errorf("unexpected unknown-instruction: %+v", d)
}
}
}
}
// TestDiagnosticsExtensionAMD64StillReported is the per-architecture
// negative case: on amd64 the registry owns nothing, so the same source
// keeps every unknown-instruction report, the SVE mnemonics included.
func TestDiagnosticsExtensionAMD64StillReported(t *testing.T) {
diags := publishedDiagnostics(t, "file:///v_amd64.s", sveDoc)
found := map[string]bool{}
for _, d := range diags {
if d.Code == "unknown-instruction" {
for _, mnem := range []string{"SQADD", "NOSUCHTHING"} {
if strings.Contains(d.Message, mnem) {
found[mnem] = true
}
}
}
}
for _, mnem := range []string{"SQADD", "NOSUCHTHING"} {
if !found[mnem] {
t.Errorf("amd64 lost the unknown-instruction report for %q: %+v", mnem, diags)
}
}
}