update lsp
This commit is contained in:
parent
010f3082b6
commit
47867fb858
1 changed files with 30 additions and 1 deletions
31
d2js/js.go
31
d2js/js.go
|
|
@ -25,6 +25,7 @@ func main() {
|
|||
js.Global().Set("d2GetParentID", js.FuncOf(jsGetParentID))
|
||||
js.Global().Set("d2GetObjOrder", js.FuncOf(jsGetObjOrder))
|
||||
js.Global().Set("d2GetRefRanges", js.FuncOf(jsGetRefRanges))
|
||||
js.Global().Set("d2GetImportRanges", js.FuncOf(jsGetImportRanges))
|
||||
js.Global().Set("d2Compile", js.FuncOf(jsCompile))
|
||||
js.Global().Set("d2Parse", js.FuncOf(jsParse))
|
||||
js.Global().Set("d2Encode", js.FuncOf(jsEncode))
|
||||
|
|
@ -124,7 +125,7 @@ func jsGetRefRanges(this js.Value, args []js.Value) interface{} {
|
|||
return string(str)
|
||||
}
|
||||
|
||||
refs, err := d2lsp.GetRefs(file, fs, key, boardPath)
|
||||
refs, err := d2lsp.GetRefs(file, fs, boardPath, key)
|
||||
if err != nil {
|
||||
ret := jsRefRanges{D2Error: err.Error()}
|
||||
str, _ := json.Marshal(ret)
|
||||
|
|
@ -145,6 +146,34 @@ func jsGetRefRanges(this js.Value, args []js.Value) interface{} {
|
|||
return string(str)
|
||||
}
|
||||
|
||||
func jsGetImportRanges(this js.Value, args []js.Value) interface{} {
|
||||
fsRaw := args[0].String()
|
||||
path := args[1].String()
|
||||
importPath := args[2].String()
|
||||
|
||||
var fs map[string]string
|
||||
err := json.Unmarshal([]byte(fsRaw), &fs)
|
||||
if err != nil {
|
||||
ret := jsRefRanges{D2Error: err.Error()}
|
||||
str, _ := json.Marshal(ret)
|
||||
return string(str)
|
||||
}
|
||||
|
||||
ranges, err := d2lsp.GetImportRanges(path, fs, importPath)
|
||||
if err != nil {
|
||||
ret := jsRefRanges{D2Error: err.Error()}
|
||||
str, _ := json.Marshal(ret)
|
||||
return string(str)
|
||||
}
|
||||
|
||||
resp := jsRefRanges{
|
||||
Ranges: ranges,
|
||||
}
|
||||
|
||||
str, _ := json.Marshal(resp)
|
||||
return string(str)
|
||||
}
|
||||
|
||||
type jsObject struct {
|
||||
Result string `json:"result"`
|
||||
UserError string `json:"userError"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue