Fixed isolated file indexing
This commit is contained in:
38
test/isolation_test.go
Normal file
38
test/isolation_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/marte-community/marte-dev-tools/internal/index"
|
||||
"github.com/marte-community/marte-dev-tools/internal/parser"
|
||||
)
|
||||
|
||||
func TestIsolatedFileIsolation(t *testing.T) {
|
||||
pt := index.NewProjectTree()
|
||||
|
||||
// File 1: Project file
|
||||
f1 := "#package P\n+A = { Class = C }"
|
||||
p1 := parser.NewParser(f1)
|
||||
c1, _ := p1.Parse()
|
||||
pt.AddFile("f1.marte", c1)
|
||||
|
||||
// File 2: Isolated file
|
||||
f2 := "+B = { Class = C }"
|
||||
p2 := parser.NewParser(f2)
|
||||
c2, _ := p2.Parse()
|
||||
pt.AddFile("f2.marte", c2)
|
||||
|
||||
pt.ResolveReferences()
|
||||
|
||||
// Try finding A from f2
|
||||
isoNode := pt.IsolatedFiles["f2.marte"]
|
||||
if pt.ResolveName(isoNode, "A", nil) != nil {
|
||||
t.Error("Isolated file f2 should not see global A")
|
||||
}
|
||||
|
||||
// Try finding B from f1
|
||||
pNode := pt.Root.Children["P"]
|
||||
if pt.ResolveName(pNode, "B", nil) != nil {
|
||||
t.Error("Project file f1 should not see isolated B")
|
||||
}
|
||||
}
|
||||
@@ -193,8 +193,8 @@ $App = {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !foundProjectDS {
|
||||
t.Error("Expected ProjectDS in isolated file suggestions (now shared root)")
|
||||
if foundProjectDS {
|
||||
t.Error("Did not expect ProjectDS in isolated file suggestions (isolation)")
|
||||
}
|
||||
|
||||
// Completion in a project file
|
||||
|
||||
@@ -45,9 +45,9 @@ func TestLSPSignalReferences(t *testing.T) {
|
||||
v.ValidateProject()
|
||||
|
||||
// Find definition of MySig in MyDS
|
||||
root := idx.Root
|
||||
root := idx.IsolatedFiles["signal_refs.marte"]
|
||||
if root == nil {
|
||||
t.Fatal("Root node not found")
|
||||
t.Fatal("Root node not found (isolated)")
|
||||
}
|
||||
|
||||
// Traverse to MySig
|
||||
|
||||
@@ -194,7 +194,7 @@ func TestIsolatedFileValidation(t *testing.T) {
|
||||
t.Fatal("Reference SharedObj not found in index")
|
||||
}
|
||||
|
||||
if ref.Target == nil {
|
||||
t.Errorf("Expected reference in root file (iso.marte) to resolve to global SharedObj")
|
||||
if ref.Target != nil {
|
||||
t.Errorf("Isolation failure: reference in isolated file resolved to global object")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user