diff --git a/d2lsp/d2lsp.go b/d2lsp/d2lsp.go index 5a345afae..b80fa5770 100644 --- a/d2lsp/d2lsp.go +++ b/d2lsp/d2lsp.go @@ -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 diff --git a/d2lsp/d2lsp_test.go b/d2lsp/d2lsp_test.go index 57327711e..4c25c8dae 100644 --- a/d2lsp/d2lsp_test.go +++ b/d2lsp/d2lsp_test.go @@ -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)