-
Notifications
You must be signed in to change notification settings - Fork 767
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
Add logic to infer remote path automatically #44
Conversation
This PR (HEAD: 3d9a114) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/234020 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
Message from Hyang-Ah Hana Kim: Patch Set 1: (6 comments) Is it possible to have some unit tests on those local to remote/ remote to local mapping functions? (Eventually we need integration tests but given the lack of existing tests for debugging, I think that is too much for this cl.) Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
This PR (HEAD: b06821f) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/234020 to see it. Tip: You can toggle comments from me using the |
Message from Quoc Truong: Patch Set 2: Hi Hana, I've added tests and addressed the comments. PTAL. Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
Message from Hyang-Ah Hana Kim: Patch Set 2: (10 comments) Thank you for adding tests! Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
This PR (HEAD: 614a301) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/234020 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 409314c) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/234020 to see it. Tip: You can toggle comments from me using the |
Message from Quoc Truong: Patch Set 3: (6 comments) Hi Hana, I've removed typemoq and used sinon now. PTAL. Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
Message from Hyang-Ah Hana Kim: Patch Set 4: (1 comment) Thanks! Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
This PR (HEAD: 0383036) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/vscode-go/+/234020 to see it. Tip: You can toggle comments from me using the |
Message from Quoc Truong: Patch Set 5: (1 comment) Hi Hana, PTAL. I forgot to remove that when testing on my machine. Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
Message from Hyang-Ah Hana Kim: Patch Set 5: Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/234020. |
Delve has an [API](https://godoc.org/github.com/go-delve/delve/service/rpc2#ListSourcesOut) to list all the files used by the program. So we can simply get the list of files on the remote machine and map it to the files on the local machine. These include files in the `GOROOT` and `GOPATH` on the remote machine as well so we can try to map them to the files in the local machine `GOROOT` and `GOPATH`. ## Mapping local path to remote path Since we get all the remote sources, we can retrieve all the remote source files that share the same file name with the local file. We can then do a suffix match to get the best matching remote path. Mapping remote path to local path This is more complicated because there are multiple places where we can try to find a match on the local machine. However, we can use the [`ListPackagesBuildInfo`](https://godoc.org/github.com/go-delve/delve/service/rpc2#ListPackagesBuildInfoOut) to help us retrieve all the different Go packages used. Each package item returned comes with a Directory Path and an Import Path. Using Directory Path, we can determine if the remote path is in a particular package or not: - If the remote path is in a package, we can try to find whether the package exists on the local machine. We will be searching for it in 3 places: - The current user’s workspace folder. - The current user’s `GOPATH`. - The current user’s `GOMOD` folder (`%GOMOD%/pkg/mod`) if the package name contains `pkg/mod`. - If the remote path is not in any package, then we retrieve the name of the remote path and search for files with that name in the current workspace folder. We find the best matching one using a suffix match. Updates #45. Change-Id: I619c45ea4f79036db944d271169665e72dcffab8 GitHub-Last-Rev: 0383036 GitHub-Pull-Request: #44 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/234020 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This PR is being closed because golang.org/cl/234020 has been merged. |
Delve has an API to list all the files used by the program. So we can simply get the list of files on the remote machine and map it to the files on the local machine. These include files in the
GOROOT
andGOPATH
on the remote machine as well so we can try to map them to the files in the local machineGOROOT
andGOPATH
.Mapping local path to remote path
Since we get all the remote sources, we can retrieve all the remote source files that share the same file name with the local file. We can then do a suffix match to get the best matching remote path.
Mapping remote path to local path
This is more complicated because there are multiple places where we can try to find a match on the local machine.
However, we can use the
ListPackagesBuildInfo
to help us retrieve all the different Go packages used. Each package item returned comes with a Directory Path and an Import Path. Using Directory Path, we can determine if the remote path is in a particular package or not:If the remote path is in a package, we can try to find whether the package exists on the local machine. We will be searching for it in 3 places:
GOPATH
.GOMOD
folder (%GOMOD%/pkg/mod
) if the package name containspkg/mod
.If the remote path is not in any package, then we retrieve the name of the remote path and search for files with that name in the current workspace folder. We find the best matching one using a suffix match.
Updates #45.