Move LSP semantics into typed analysis

This commit is contained in:
pavel 2026-08-27 21:28:11 +02:00
commit bac1183593
26 changed files with 1232 additions and 637 deletions

View file

@ -450,6 +450,21 @@ fun main() {
}
}
func TestBuildDocumentStateUsesStructuredSemanticDiagnostics(t *testing.T) {
text := "package demo\nfun main() { println(missing) }"
state := buildDocumentState(text)
if len(state.diagnostics) != 1 {
t.Fatalf("diagnostics = %#v", state.diagnostics)
}
diagnostic := state.diagnostics[0]
if diagnostic.Code != "undefined-symbol" || diagnostic.Severity != diagnosticSeverityError || diagnostic.Message != "undefined identifier missing" {
t.Fatalf("unexpected diagnostic: %#v", diagnostic)
}
if diagnostic.Range.Start.Line != 1 || diagnostic.Range.Start.Character != 21 {
t.Fatalf("unexpected diagnostic range: %#v", diagnostic.Range)
}
}
func TestBuildDocumentStateInfersHttpServerVariableTypes(t *testing.T) {
text := strings.TrimSpace(`
package demo
@ -460,7 +475,7 @@ import github.com.uptrace.bun
class C(val db: *bun.DB) {
fun run() {
val ctx = context.Background()
val total = db.NewSelect().ColumnExpr("1").Count(ctx)
val total = db.NewSelect().ColumnExpr("1").Count(ctx).unwrap()
println(total)
}
}