diff --git a/go.mod b/go.mod index 45ae125..abf7cfc 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/bufbuild/protocompile v0.4.0 github.com/bufbuild/protovalidate-go v0.3.4 - github.com/gogo/protobuf v1.3.2 github.com/google/cel-go v0.18.1 github.com/kralicky/gpkg v0.0.0-20220311205216-0d8ea9557555 github.com/mattn/go-tty v0.0.5 diff --git a/go.sum b/go.sum index aba8bb7..af252d0 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -32,8 +30,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kralicky/gpkg v0.0.0-20220311205216-0d8ea9557555 h1:w/v9aYd9gdL0pEofCiOM7MWNroB9+HWxHT29Wj2NMYc= github.com/kralicky/gpkg v0.0.0-20220311205216-0d8ea9557555/go.mod h1:EJrGSfmocDg2CBjHDm3zy9oxNKCSGhf+MNTiN1DRbKA= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= diff --git a/pkg/lsp/compat.go b/pkg/lsp/compat.go deleted file mode 100644 index c0dbebc..0000000 --- a/pkg/lsp/compat.go +++ /dev/null @@ -1,6 +0,0 @@ -package lsp - -// gogoproto compatibility -import ( - _ "github.com/gogo/protobuf/gogoproto" -) diff --git a/pkg/lsp/resolver.go b/pkg/lsp/resolver.go index c4b6866..419246b 100644 --- a/pkg/lsp/resolver.go +++ b/pkg/lsp/resolver.go @@ -17,7 +17,6 @@ import ( "github.com/bufbuild/protocompile" "github.com/bufbuild/protocompile/linker" - gogo "github.com/gogo/protobuf/proto" "github.com/kralicky/protols/pkg/format" "golang.org/x/tools/gopls/pkg/lsp/cache" "golang.org/x/tools/gopls/pkg/lsp/protocol" @@ -287,6 +286,13 @@ func (r *Resolver) findFileByPathLocked(path string, whence protocompile.ImportC } } + if filepath.Base(path) == "gogo.proto" { + if result, err := r.checkGoModule("github.com/gogo/protobuf/gogoproto/gogo.proto", whence); err == nil { + lg.Debug("resolved to special case (go module: gogo.proto)") + return result, nil + } + } + lg.Debug("could not resolve path") return protocompile.SearchResult{}, os.ErrNotExist } @@ -295,29 +301,6 @@ func (r *Resolver) checkWellKnownImportPath(path string) (protocompile.SearchRes if strings.HasPrefix(path, "google/") { return r.checkGlobalCache(path) } - if filepath.Base(path) == "gogo.proto" { - descriptorBytes := gogo.FileDescriptor("gogo.proto") - if descriptorBytes != nil { - fd, err := DecodeRawFileDescriptor(descriptorBytes) - if err != nil { - return protocompile.SearchResult{}, err - } - *fd.Name = path - syntheticURI := url.URL{ - Scheme: "proto", - Path: path, - Fragment: r.folder.Name, - } - uri := span.URI(syntheticURI.String()) - r.filePathsByURI[uri] = path - r.fileURIsByPath[path] = uri - r.importSourcesByURI[uri] = SourceWellKnown - return protocompile.SearchResult{ - ResolvedPath: protocompile.ResolvedPath(path), - Proto: fd, - }, nil - } - } return protocompile.SearchResult{}, os.ErrNotExist }