@@ -11,6 +11,7 @@ import (
11
11
"golang.org/x/tools/internal/jsonrpc2"
12
12
"golang.org/x/tools/internal/lsp/protocol"
13
13
"golang.org/x/tools/internal/lsp/source"
14
+ "golang.org/x/tools/internal/lsp/telemetry/log"
14
15
"golang.org/x/tools/internal/semver"
15
16
"golang.org/x/tools/internal/span"
16
17
"io/ioutil"
@@ -188,11 +189,9 @@ type WorkspaceFolderMeta struct {
188
189
// manageDeps will explore the workspace folders sent from the client and give a whole picture of them. Besides that,
189
190
// manageDeps will try its best to convert the folders to modules. The core functions, like deps downloading and deps
190
191
// management, will be implemented in the package 'cache'.
191
- func (s ElasticServer ) ManageDeps (folders * []protocol.WorkspaceFolder ) error {
192
- // Note: For the upstream go langserver, granularity of the workspace folders is repository. But for the elastic go
193
- // language server, there are repositories contain multiple modules. In order to handle the modules separately, we
194
- // consider different modules as different workspace folders, so we can manage the dependency of different modules
195
- // separately.
192
+ func (s ElasticServer ) ManageDeps (ctx context.Context , folders * []protocol.WorkspaceFolder ) error {
193
+ // In order to handle the modules separately, we consider different modules as different workspace folders, so we
194
+ // can manage the dependency of different modules separately.
196
195
for _ , folder := range * folders {
197
196
metadata := & WorkspaceFolderMeta {}
198
197
if folder .URI != "" {
@@ -215,6 +214,13 @@ func (s ElasticServer) ManageDeps(folders *[]protocol.WorkspaceFolder) error {
215
214
}
216
215
}
217
216
}
217
+ for _ , folder := range * folders {
218
+ cmd := exec .Command ("go" , "mod" , "download" )
219
+ cmd .Dir = span .NewURI (folder .URI ).Filename ()
220
+ if err := cmd .Run (); err != nil {
221
+ log .Error (ctx , "failed to download the dependencies" , err )
222
+ }
223
+ }
218
224
return nil
219
225
}
220
226
0 commit comments