-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
gopls/internal/lsp/source: show both the original declaration and the value of constants in hover #432
gopls/internal/lsp/source: show both the original declaration and the value of constants in hover #432
Conversation
… value of constants in hover This change improves the hover information for constants by showing both the original declaration and the value. The value is displayed as an inline comment. If the original declaration and the value are the same, there will be no inline comment. Examples: ```go const duration time.Duration = 15*time.Minute + 10*time.Second // 15m10s const octal untyped int = 0o777 // 511 const expr untyped int = 2 << (0b111&0b101 - 2) // 16 const boolean untyped bool = (55 - 3) == (26 * 2) // true const dec untyped int = 500 ``` Other changes: * Calls to `objectString` that format methods or variables have been replaced with `types.ObjectString`. * The logic of inferred signature formatting has been extracted from `objectString` to a new function `inferredSignatureString`. * Remove unused function `extractFieldList`. Fixes golang/go#47453
This PR (HEAD: a7fbd1e) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/tools/+/480695 to see it. Tip: You can toggle comments from me using the |
Message from Nikita Shoshin: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Robert Findley: Patch Set 2: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Gopher Robot: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from kokoro: Patch Set 2: Kokoro presubmit build starting for golang/tools/gopls-legacy/presubmit Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Gopher Robot: Patch Set 2: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from kokoro: Patch Set 2: gopls-CI-1 Kokoro presubmit build finished with status: FAILURE Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Robert Findley: Patch Set 2: Code-Review+1 (9 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Robert Findley: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
This PR (HEAD: 8cc75a7) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/tools/+/480695 to see it. Tip: You can toggle comments from me using the |
Message from Nikita Shoshin: Patch Set 3: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Nikita Shoshin: Patch Set 3: (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Robert Findley: Patch Set 4: Code-Review+2 Run-TryBot+1 (7 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Gopher Robot: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from kokoro: Patch Set 4: Kokoro presubmit build starting for golang/tools/gopls-legacy/presubmit Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from kokoro: Patch Set 4: gopls-CI+1 Kokoro presubmit build finished with status: SUCCESS Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Gopher Robot: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
Message from Gopher Robot: Patch Set 4: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/480695. |
… value of constants in hover This change improves the hover information for constants by showing both the original declaration and the value. The value is displayed as an inline comment. If the original declaration and the value are the same, there will be no inline comment. Examples: ```go const duration time.Duration = 15*time.Minute + 10*time.Second // 15m10s const octal untyped int = 0o777 // 511 const expr untyped int = 2 << (0b111&0b101 - 2) // 16 const boolean untyped bool = (55 - 3) == (26 * 2) // true const dec untyped int = 500 ``` Other changes: - Calls to `objectString` that format methods or variables have been replaced with `types.ObjectString`. - The logic of inferred signature formatting has been extracted from `objectString` to a new function `inferredSignatureString`. - Remove unused function `extractFieldList`. - Port `gopls/internal/lsp/testdata/godef/a/g.go` to the new marker tests. - Fix `-min_go` constraint for marker tests by replacing hardcoded `1.18` with an actual flag value. Fixes golang/go#47453 Change-Id: Ib9012dae8554a3b646c3059d2f8967e425974fbf GitHub-Last-Rev: 8cc75a7 GitHub-Pull-Request: #432 Reviewed-on: https://go-review.googlesource.com/c/tools/+/480695 Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]>
This PR is being closed because golang.org/cl/480695 has been merged. |
This change improves the hover information for constants by showing
both the original declaration and the value. The value is displayed
as an inline comment. If the original declaration and the value are
the same, there will be no inline comment.
Examples:
Other changes:
objectString
that format methods or variables have beenreplaced with
types.ObjectString
.objectString
to a new functioninferredSignatureString
.extractFieldList
.gopls/internal/lsp/testdata/godef/a/g.go
to the new markertests.
-min_go
constraint for marker tests by replacing hardcoded1.18
with an actual flag value.Fixes golang/go#47453