better multi file support

This commit is contained in:
Martino Ferrari
2026-01-21 10:16:54 +01:00
parent fe4bb7c11e
commit d4d857bf05
7 changed files with 400 additions and 30 deletions

View File

@@ -3,6 +3,7 @@ package index
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/marte-dev/marte-dev-tools/internal/parser"
@@ -13,6 +14,26 @@ type ProjectTree struct {
References []Reference
}
func (pt *ProjectTree) ScanDirectory(rootPath string) error {
return filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() && strings.HasSuffix(info.Name(), ".marte") {
content, err := os.ReadFile(path)
if err != nil {
return err // Or log and continue
}
p := parser.NewParser(string(content))
config, err := p.Parse()
if err == nil {
pt.AddFile(path, config)
}
}
return nil
})
}
type Reference struct {
Name string
Position parser.Position