@@ -25,7 +25,6 @@ func main() {
25
25
js .Global ().Set ("d2GetParentID" , js .FuncOf (jsGetParentID ))
26
26
js .Global ().Set ("d2GetObjOrder" , js .FuncOf (jsGetObjOrder ))
27
27
js .Global ().Set ("d2GetRefRanges" , js .FuncOf (jsGetRefRanges ))
28
- js .Global ().Set ("d2GetImportRanges" , js .FuncOf (jsGetImportRanges ))
29
28
js .Global ().Set ("d2Compile" , js .FuncOf (jsCompile ))
30
29
js .Global ().Set ("d2Parse" , js .FuncOf (jsParse ))
31
30
js .Global ().Set ("d2Encode" , js .FuncOf (jsEncode ))
@@ -90,10 +89,11 @@ func jsGetParentID(this js.Value, args []js.Value) interface{} {
90
89
}
91
90
92
91
type jsRefRanges struct {
93
- Ranges []d2ast.Range `json:"ranges"`
94
- ParseError string `json:"parseError"`
95
- UserError string `json:"userError"`
96
- D2Error string `json:"d2Error"`
92
+ Ranges []d2ast.Range `json:"ranges"`
93
+ ImportRanges []d2ast.Range `json:"importRanges"`
94
+ ParseError string `json:"parseError"`
95
+ UserError string `json:"userError"`
96
+ D2Error string `json:"d2Error"`
97
97
}
98
98
99
99
func jsGetRefRanges (this js.Value , args []js.Value ) interface {} {
@@ -125,49 +125,16 @@ func jsGetRefRanges(this js.Value, args []js.Value) interface{} {
125
125
return string (str )
126
126
}
127
127
128
- refs , err := d2lsp .GetRefs (file , fs , boardPath , key )
129
- if err != nil {
130
- ret := jsRefRanges {D2Error : err .Error ()}
131
- str , _ := json .Marshal (ret )
132
- return string (str )
133
- }
134
-
135
- var ranges []d2ast.Range
136
-
137
- for _ , ref := range refs {
138
- ranges = append (ranges , ref .AST ().GetRange ())
139
- }
140
-
141
- resp := jsRefRanges {
142
- Ranges : ranges ,
143
- }
144
-
145
- str , _ := json .Marshal (resp )
146
- return string (str )
147
- }
148
-
149
- func jsGetImportRanges (this js.Value , args []js.Value ) interface {} {
150
- fsRaw := args [0 ].String ()
151
- path := args [1 ].String ()
152
- importPath := args [2 ].String ()
153
-
154
- var fs map [string ]string
155
- err := json .Unmarshal ([]byte (fsRaw ), & fs )
156
- if err != nil {
157
- ret := jsRefRanges {D2Error : err .Error ()}
158
- str , _ := json .Marshal (ret )
159
- return string (str )
160
- }
161
-
162
- ranges , err := d2lsp .GetImportRanges (path , fs , importPath )
128
+ ranges , importRanges , err := d2lsp .GetRefRanges (file , fs , boardPath , key )
163
129
if err != nil {
164
130
ret := jsRefRanges {D2Error : err .Error ()}
165
131
str , _ := json .Marshal (ret )
166
132
return string (str )
167
133
}
168
134
169
135
resp := jsRefRanges {
170
- Ranges : ranges ,
136
+ Ranges : ranges ,
137
+ ImportRanges : importRanges ,
171
138
}
172
139
173
140
str , _ := json .Marshal (resp )
0 commit comments