Skip to content
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

[SR-15411] Report cursor info information for literals #57725

xAlien95 opened this issue Oct 29, 2021 · 3 comments

[SR-15411] Report cursor info information for literals #57725

xAlien95 opened this issue Oct 29, 2021 · 3 comments


Copy link

@xAlien95 xAlien95 commented Oct 29, 2021

Previous ID SR-15411
Radar None
Original Reporter @xAlien95
Type Improvement
Status Reopened
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Improvement
Assignee None
Priority Medium

md5: 085af8993d7db2679bf69ce553a24cc0

Issue Description:

In the following test case, SourceKit should provide cursor info for the literal 42, reporting its type as Double. Currently, it doesn’t return any information at all.

// RUN: %sourcekitd-test -req=cursor -pos=5:17 -print-raw-response %s -- %s

func foo() {
    let x = 1.2
    let y = x + 42

Original report:

Currently, clicking on a literal while holding the alt key in Xcode won't trigger a Quick Help pop-up. It may be useful for newcomers to be able to get the inferred type of a literal simply by invoking Quick Help.

In the Swift Forums' thread, a new user stumbled upon

3 + 0.14 // allowed

let three = 3
let rest = 0.14

3 + rest // allowed
0.14 + three // compile error
three + 0.14 // compile error

Quick Help triggered on the literal 3 at the first line or at the third-to-last line, would show

3: Double

A similar enhancement could be made to operator identifiers too, which would make easier for users to understand which overload has been chosen by the constraint solver.

Copy link

@ahoppen ahoppen commented Jan 5, 2022

IIUC you are reporting an issue that is specific to Xcode, not SourceKit-LSP. For Xcode-specific issues, could you file a feedback at

Copy link
Contributor Author

@xAlien95 xAlien95 commented Jan 5, 2022

@ahoppen, it's not specific to Xcode. As an example, in VS Code you get the Quick Help pop-up by hovering a variable.

Copy link

@ahoppen ahoppen commented Jan 7, 2022

Ah, OK, I see what you mean now: Both Xcode and SourceKit-LSP should provide QuickHelp/Document Highlight for literals. To make sure the bug report only talks about open source components, I have rephrased it around the underlying cursorInfo request to sourcekitd, which is used by both Xcode and SourceKit-LSP. I hope that’s alright with you.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants