Repository: go
Issue: x/tools/gopls: 'Check for upgrades' codelens argument can be lazily computed
Labels: gopls,Tools

Gopls version: gopls v0.14.0-pre.4

Just noticed that `textDocument/codeLens` response for `go.mod` generates a long message when the project has many dependencies. Assuming the module list can be computed when gopls.check_upgrades command is received lazily, I think it's wasteful to transmit this long list for every codelen response which is more frequent.

```
[Trace - 8:34:25 PM] Received response 'textDocument/codeLens - (34)' in 14ms.
Result: [
   ...
    {
        "range": {
            "start": {
                "line": 8,
                "character": 0
            },
            "end": {
                "line": 171,
                "character": 1
            }
        },
        "command": {
            "title": "Check for upgrades",
            "command": "gopls.check_upgrades",
            "arguments": [
                {
                    "URI": "file:///Users/hakim/projects/vulnbench/vault/go.mod",
                    "Modules": [
                        "cloud.google.com/go",
                        "cloud.google.com/go/spanner",
                        "cloud.google.com/go/storage",
                        "github.com/Azure/azure-storage-blob-go",
                        "github.com/Azure/go-autorest/autorest",
                        "github.com/Azure/go-autorest/autorest/adal",
                        "github.com/Microsoft/hcsshim",
                        "github.com/NYTimes/gziphandler",
                        "github.com/SAP/go-hdb",
                        "github.com/Sectorbob/mlab-ns2",
                        "github.com/StackExchange/wmi",
                        "github.com/aerospike/aerospike-client-go",
                        "github.com/aliyun/alibaba-cloud-sdk-go",
                        "github.com/aliyun/aliyun-oss-go-sdk",
                        "github.com/apple/foundationdb/bindings/go",
                        "github.com/armon/go-metrics",
                        "github.com/armon/go-proxyproto",
                        "github.com/armon/go-radix",
                        "github.com/asaskevich/govalidator",
                        "github.com/aws/aws-sdk-go",
                        "github.com/bitly/go-hostpool",
                        "github.com/cenkalti/backoff/v3",
                        "github.com/chrismalek/oktasdk-go",
                        "github.com/client9/misspell",
                        "github.com/cockroachdb/cockroach-go",
                        "github.com/containerd/containerd",
                        "github.com/coreos/go-semver",
                        "github.com/denisenkom/go-mssqldb",
                        "github.com/docker/docker",
                        "github.com/docker/go-connections",
                        "github.com/dsnet/compress",
                        "github.com/duosecurity/duo_api_golang",
                        "github.com/elazarl/go-bindata-assetfs",
                        "github.com/fatih/color",
                        "github.com/fatih/structs",
                        "github.com/fullsailor/pkcs7",
                        "github.com/ghodss/yaml",
                        "github.com/go-errors/errors",
                        "github.com/go-ldap/ldap/v3",
                        "github.com/go-ole/go-ole",
                        "github.com/go-sql-driver/mysql",
                        "github.com/go-test/deep",
                        "github.com/gocql/gocql",
                        "github.com/golang/protobuf",
                        "github.com/google/go-github",
                        "github.com/google/go-metrics-stackdriver",
                        "github.com/hashicorp/consul-template",
                        "github.com/hashicorp/consul/api",
                        "github.com/hashicorp/errwrap",
                        "github.com/hashicorp/go-bindata",
                        "github.com/hashicorp/go-cleanhttp",
                        "github.com/hashicorp/go-discover",
                        "github.com/hashicorp/go-gcp-common",
                        "github.com/hashicorp/go-hclog",
                        "github.com/hashicorp/go-kms-wrapping",
                        "github.com/hashicorp/go-memdb",
                        "github.com/hashicorp/go-msgpack",
                        "github.com/hashicorp/go-multierror",
                        "github.com/hashicorp/go-raftchunking",
                        "github.com/hashicorp/go-retryablehttp",
                        "github.com/hashicorp/go-rootcerts",
                        "github.com/hashicorp/go-sockaddr",
                        "github.com/hashicorp/go-syslog",
                        "github.com/hashicorp/go-uuid",
                        "github.com/hashicorp/golang-lru",
                        "github.com/hashicorp/hcl",
                        "github.com/hashicorp/nomad/api",
                        "github.com/hashicorp/raft",
                        "github.com/hashicorp/raft-autopilot",
                        "github.com/hashicorp/raft-snapshot",
                        "github.com/hashicorp/serf",
                        "github.com/hashicorp/vault-plugin-auth-alicloud",
                        "github.com/hashicorp/vault-plugin-auth-azure",
                        "github.com/hashicorp/vault-plugin-auth-centrify",
                        "github.com/hashicorp/vault-plugin-auth-cf",
                        "github.com/hashicorp/vault-plugin-auth-gcp",
                        "github.com/hashicorp/vault-plugin-auth-jwt",
                        "github.com/hashicorp/vault-plugin-auth-kerberos",
                        "github.com/hashicorp/vault-plugin-auth-kubernetes",
                        "github.com/hashicorp/vault-plugin-auth-oci",
                        "github.com/hashicorp/vault-plugin-database-couchbase",
                        "github.com/hashicorp/vault-plugin-database-elasticsearch",
                        "github.com/hashicorp/vault-plugin-database-mongodbatlas",
                        "github.com/hashicorp/vault-plugin-database-snowflake",
                        "github.com/hashicorp/vault-plugin-mock",
                        "github.com/hashicorp/vault-plugin-secrets-ad",
                        "github.com/hashicorp/vault-plugin-secrets-alicloud",
                        "github.com/hashicorp/vault-plugin-secrets-azure",
                        "github.com/hashicorp/vault-plugin-secrets-gcp",
                        "github.com/hashicorp/vault-plugin-secrets-gcpkms",
                        "github.com/hashicorp/vault-plugin-secrets-kv",
                        "github.com/hashicorp/vault-plugin-secrets-mongodbatlas",
                        "github.com/hashicorp/vault-plugin-secrets-openldap",
                        "github.com/hashicorp/vault-plugin-secrets-terraform",
                        "github.com/hashicorp/vault/api",
                        "github.com/hashicorp/vault/sdk",
                        "github.com/influxdata/influxdb",
                        "github.com/jcmturner/gokrb5/v8",
                        "github.com/jefferai/isbadcipher",
                        "github.com/jefferai/jsonx",
                        "github.com/joyent/triton-go",
                        "github.com/keybase/go-crypto",
                        "github.com/kr/pretty",
                        "github.com/kr/text",
                        "github.com/lib/pq",
                        "github.com/mattn/go-colorable",
                        "github.com/mholt/archiver",
                        "github.com/michaelklishin/rabbit-hole",
                        "github.com/miekg/dns",
                        "github.com/mitchellh/cli",
                        "github.com/mitchellh/copystructure",
                        "github.com/mitchellh/go-homedir",
                        "github.com/mitchellh/go-testing-interface",
                        "github.com/mitchellh/gox",
                        "github.com/mitchellh/mapstructure",
                        "github.com/mitchellh/reflectwalk",
                        "github.com/mongodb/go-client-mongodb-atlas",
                        "github.com/natefinch/atomic",
                        "github.com/ncw/swift",
                        "github.com/nwaples/rardecode",
                        "github.com/oklog/run",
                        "github.com/okta/okta-sdk-golang/v2",
                        "github.com/oracle/oci-go-sdk",
                        "github.com/ory/dockertest",
                        "github.com/ory/dockertest/v3",
                        "github.com/patrickmn/go-cache",
                        "github.com/petermattis/goid",
                        "github.com/pkg/errors",
                        "github.com/posener/complete",
                        "github.com/pquerna/otp",
                        "github.com/prometheus/client_golang",
                        "github.com/prometheus/common",
                        "github.com/rboyer/safeio",
                        "github.com/ryanuber/columnize",
                        "github.com/ryanuber/go-glob",
                        "github.com/samuel/go-zookeeper",
                        "github.com/sasha-s/go-deadlock",
                        "github.com/sethvargo/go-limiter",
                        "github.com/shirou/gopsutil",
                        "github.com/stretchr/testify",
                        "github.com/tidwall/pretty",
                        "github.com/ulikunitz/xz",
                        "github.com/xdg/stringprep",
                        "github.com/xi2/xz",
                        "github.com/yuin/gopher-lua",
                        "go.etcd.io/bbolt",
                        "go.etcd.io/etcd",
                        "go.mongodb.org/mongo-driver",
                        "go.uber.org/atomic",
                        "golang.org/x/crypto",
                        "golang.org/x/net",
                        "golang.org/x/oauth2",
                        "golang.org/x/sys",
                        "golang.org/x/text",
                        "golang.org/x/tools",
                        "google.golang.org/api",
                        "google.golang.org/grpc",
                        "google.golang.org/protobuf",
                        "gopkg.in/mgo.v2",
                        "gopkg.in/ory-am/dockertest.v3",
                        "gopkg.in/square/go-jose.v2",
                        "layeh.com/radius"
                    ]
                }
            ]
        }
    },
    ...