make compiler errors general, and better imports
Some checks failed
/ test (push) Failing after 43s

This commit is contained in:
Neemek 2025-10-02 13:03:40 +02:00
parent f2ebcf560f
commit b95d2954ba
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
5 changed files with 77 additions and 30 deletions

View file

@ -28,17 +28,38 @@ type DirectoryResolver struct {
directories []string
}
func (r *DirectoryResolver) Resolve(path string) (string, error) {
func (r *DirectoryResolver) Resolve(from, path string) (*core.ImportResult, error) {
// relative imports
relpath := filepath.Join(filepath.Dir(from), path)
if f, err := os.ReadFile(relpath); err == nil {
return &core.ImportResult{
Source: string(f),
Path: relpath,
}, nil
}
for _, d := range r.directories {
pth := filepath.Join(d, path)
f, err := os.ReadFile(pth)
if err == nil {
return string(f), nil
return &core.ImportResult{
Source: string(f),
Path: pth,
}, nil
}
pth = filepath.Join(pth, "main.ang")
f, err = os.ReadFile(pth)
if err == nil {
return &core.ImportResult{
Source: string(f),
Path: pth,
}, nil
}
}
return "", errors.New("couldn't resolve import")
return nil, errors.New("couldn't resolve import")
}
func (r *DirectoryResolver) IsSame(a, b string) bool {