-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: improve support for users of cgo packages #35720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
#34345 says that completions don't work, I'll test those too. |
Change https://golang.org/cl/208101 mentions this issue: |
Change https://golang.org/cl/208100 mentions this issue: |
When line directives are in use, we want the logical file name, not the one we found the bytes in. This matters most for cgo, where the file we parsed is not the one the user wants to see. Updates golang/go#35720. Change-Id: I495328071d8865e6895cb731467f1601f11e93db Reviewed-on: https://go-review.googlesource.com/c/tools/+/208100 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
As we improve support for cgo we'll need to reference GoFiles, not just CompiledGoFiles. "Files" is right out. I think I got everything that needs renaming but please let me know if not. Updates golang/go#35720. Change-Id: I97a6ebf5b395535de0d5f4f8b3f84b46ca34643f Reviewed-on: https://go-review.googlesource.com/c/tools/+/208101 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Change https://golang.org/cl/208501 mentions this issue: |
Change https://golang.org/cl/208502 mentions this issue: |
Change https://golang.org/cl/208503 mentions this issue: |
When //line directives are in play, the ast.File's Offset function will return offsets in the generated file. We want offsets in the authored file, so we need to pass a Converter for the authored file, in addition to the ast.File for the generated file. For the same reason, we have to start (Range).Span() by translating into positions in the authored file, then calculate offsets from that. A lot of call sites outside of the LSP don't pass the Converter, but they probably don't matter much. I think everything inside does because it ends up using mappedRange. Updates golang/go#35720. Change-Id: I7be09b3a50720b078e862d48cfdb02208f8187ae Reviewed-on: https://go-review.googlesource.com/c/tools/+/208501 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
When packages.Load'ing cgo packages, the authored files show up in GoFiles, and the generated files show up in CompiledGoFiles. We need the AST and type information for the latter, since they're the only thing we can type check. But we also need the contents (and column mapper) for the authored file so that we can navigate into it. Store GoFiles in package metadata and checked Packages. Parse the extra files, just for their mappers. Refactor the View functions a little bit, since there's only one place that actually needs to find the mapper for a file. Updates golang/go#35720. Change-Id: I9f96872a9a592bf0e11da27ebd8976c6db8752c9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/208502 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Thank you for improving this. Does |
Forked from #31561. This issue is not for packages that directly import "C"; that issue is #35721.
Various features, notably Go to Definition and friends, fail when the declaring package uses cgo. That's because the Go code for cgo files is actually in a generated file in the build cache, not the .go file the user might expect. The generated file has //line directives that point to the original code, but gopls is currently not honoring those directives. Fixing that should improve the experience for people who depend on a cgo library.
If there are other features that break when depending on a cgo package, please note them here so that we can make sure they're fixed and add tests.
The text was updated successfully, but these errors were encountered: