no need to pass fs

This commit is contained in:
Alexander Wang 2024-10-17 09:05:18 -06:00
parent f81d8395ce
commit 6c047431ab
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
2 changed files with 4 additions and 7 deletions

View file

@ -60,11 +60,8 @@ func GetRefs(path string, fs map[string]string, boardPath []string, key string)
return refs, nil
}
func GetImportRanges(path string, fs map[string]string, importPath string) (ranges []d2ast.Range, _ error) {
if _, ok := fs[path]; !ok {
return nil, fmt.Errorf(`"%s" not found`, path)
}
r := strings.NewReader(fs[path])
func GetImportRanges(path, file string, importPath string) (ranges []d2ast.Range, _ error) {
r := strings.NewReader(file)
ast, err := d2parser.Parse(path, r, nil)
if err != nil {
return nil, err

View file

@ -136,12 +136,12 @@ okay
des
`,
}
ranges, err := d2lsp.GetImportRanges("yes/index.d2", fs, "fast/ok.d2")
ranges, err := d2lsp.GetImportRanges("yes/index.d2", fs["yes/index.d2"], "fast/ok.d2")
assert.Success(t, err)
assert.Equal(t, 1, len(ranges))
assert.Equal(t, 1, ranges[0].Start.Line)
ranges, err = d2lsp.GetImportRanges("yes/index.d2", fs, "yes/pok.d2")
ranges, err = d2lsp.GetImportRanges("yes/index.d2", fs["yes/index.d2"], "yes/pok.d2")
assert.Success(t, err)
assert.Equal(t, 1, len(ranges))
assert.Equal(t, 4, ranges[0].Start.Line)