no need to pass fs
This commit is contained in:
parent
f81d8395ce
commit
6c047431ab
2 changed files with 4 additions and 7 deletions
|
|
@ -60,11 +60,8 @@ func GetRefs(path string, fs map[string]string, boardPath []string, key string)
|
||||||
return refs, nil
|
return refs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetImportRanges(path string, fs map[string]string, importPath string) (ranges []d2ast.Range, _ error) {
|
func GetImportRanges(path, file string, importPath string) (ranges []d2ast.Range, _ error) {
|
||||||
if _, ok := fs[path]; !ok {
|
r := strings.NewReader(file)
|
||||||
return nil, fmt.Errorf(`"%s" not found`, path)
|
|
||||||
}
|
|
||||||
r := strings.NewReader(fs[path])
|
|
||||||
ast, err := d2parser.Parse(path, r, nil)
|
ast, err := d2parser.Parse(path, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -136,12 +136,12 @@ okay
|
||||||
des
|
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.Success(t, err)
|
||||||
assert.Equal(t, 1, len(ranges))
|
assert.Equal(t, 1, len(ranges))
|
||||||
assert.Equal(t, 1, ranges[0].Start.Line)
|
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.Success(t, err)
|
||||||
assert.Equal(t, 1, len(ranges))
|
assert.Equal(t, 1, len(ranges))
|
||||||
assert.Equal(t, 4, ranges[0].Start.Line)
|
assert.Equal(t, 4, ranges[0].Start.Line)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue