implemented ordering preservation
This commit is contained in:
@@ -26,14 +26,14 @@ func loadConfig(t *testing.T, filename string) *parser.Configuration {
|
||||
func TestLSPDiagnostics(t *testing.T) {
|
||||
inputFile := "integration/check_dup.marte"
|
||||
config := loadConfig(t, inputFile)
|
||||
|
||||
|
||||
// Simulate LSP logic: Build Index -> Validate
|
||||
idx := index.NewProjectTree()
|
||||
idx.AddFile(inputFile, config)
|
||||
|
||||
|
||||
v := validator.NewValidator(idx, ".")
|
||||
v.ValidateProject()
|
||||
|
||||
|
||||
// Check for expected diagnostics
|
||||
found := false
|
||||
for _, d := range v.Diagnostics {
|
||||
@@ -51,7 +51,7 @@ func TestLSPDiagnostics(t *testing.T) {
|
||||
}
|
||||
|
||||
// For GoToDefinition and References, we need to test the Indexer's ability to resolve symbols.
|
||||
// Currently, my Indexer (ProjectTree) stores structure but doesn't explicitly track
|
||||
// Currently, my Indexer (ProjectTree) stores structure but doesn't explicitly track
|
||||
// "references" in a way that maps a source position to a target symbol yet.
|
||||
// The ProjectTree is built for structure merging.
|
||||
// To support LSP "Go To Definition", we need to map usage -> definition.
|
||||
@@ -63,7 +63,7 @@ func TestLSPDiagnostics(t *testing.T) {
|
||||
// Previously (before rewrite), `index.go` had `References []Reference`.
|
||||
// I removed it during the rewrite to ProjectTree!
|
||||
|
||||
// I need to re-implement reference tracking in `ProjectTree` or a parallel structure
|
||||
// I need to re-implement reference tracking in `ProjectTree` or a parallel structure
|
||||
// to support LSP features.
|
||||
func TestLSPDefinition(t *testing.T) {
|
||||
// Create a virtual file content with a definition and a reference
|
||||
@@ -94,15 +94,15 @@ func TestLSPDefinition(t *testing.T) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if foundRef == nil {
|
||||
t.Fatal("Reference to MyObject not found in index")
|
||||
}
|
||||
|
||||
|
||||
if foundRef.Target == nil {
|
||||
t.Fatal("Reference to MyObject was not resolved to a target")
|
||||
}
|
||||
|
||||
|
||||
if foundRef.Target.RealName != "+MyObject" {
|
||||
t.Errorf("Expected target to be +MyObject, got %s", foundRef.Target.RealName)
|
||||
}
|
||||
@@ -123,19 +123,19 @@ func TestLSPHover(t *testing.T) {
|
||||
idx := index.NewProjectTree()
|
||||
file := "hover.marte"
|
||||
idx.AddFile(file, config)
|
||||
|
||||
|
||||
// +MyObject is at line 2.
|
||||
// Query at line 2, col 2 (on 'M' of MyObject)
|
||||
res := idx.Query(file, 2, 2)
|
||||
|
||||
|
||||
if res == nil {
|
||||
t.Fatal("Query returned nil")
|
||||
}
|
||||
|
||||
|
||||
if res.Node == nil {
|
||||
t.Fatal("Expected Node result")
|
||||
}
|
||||
|
||||
|
||||
if res.Node.RealName != "+MyObject" {
|
||||
t.Errorf("Expected +MyObject, got %s", res.Node.RealName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user