@@ -159,3 +159,37 @@ func Decode(args []js.Value) (interface{}, error) {
159
159
func GetVersion (args []js.Value ) (interface {}, error ) {
160
160
return version .Version , nil
161
161
}
162
+
163
+ func GetCompletions (args []js.Value ) (interface {}, error ) {
164
+ if len (args ) < 3 {
165
+ return nil , & WASMError {Message : "missing required arguments" , Code : 400 }
166
+ }
167
+
168
+ text := args [0 ].String ()
169
+ line := args [1 ].Int ()
170
+ column := args [2 ].Int ()
171
+
172
+ completions , err := d2lsp .GetCompletionItems (text , line , column )
173
+ if err != nil {
174
+ return nil , & WASMError {Message : err .Error (), Code : 500 }
175
+ }
176
+
177
+ // Convert to map for JSON serialization
178
+ items := make ([]map [string ]interface {}, len (completions ))
179
+ for i , completion := range completions {
180
+ items [i ] = map [string ]interface {}{
181
+ "label" : completion .Label ,
182
+ "kind" : int (completion .Kind ),
183
+ "detail" : completion .Detail ,
184
+ "insertText" : completion .InsertText ,
185
+ }
186
+ }
187
+
188
+ return CompletionResponse {
189
+ Items : items ,
190
+ }, nil
191
+ }
192
+
193
+ type CompletionResponse struct {
194
+ Items []map [string ]interface {} `json:"items"`
195
+ }
0 commit comments