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-8677] SourceKit: Add module references as indexSource entities #51191

Closed
swift-ci opened this issue Aug 31, 2018 · 9 comments
Closed

[SR-8677] SourceKit: Add module references as indexSource entities #51191

swift-ci opened this issue Aug 31, 2018 · 9 comments

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8677
Radar None
Original Reporter rockbruno (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Improvement
Assignee rockbruno (JIRA)
Priority Medium

md5: b9029558b34d4a83016fcd6e2393494f

Issue Description:

Forum pitch: https://forums.swift.org/t/proposal-adding-line-column-to-sourcekits-import-declarations-index/15631

Module references are currently not covered by index requests. We could add them as key.entities entries to allow imports:

import MyLibrary

and explicit references:

let foo = Swift.String()

to be recognized and indexed, including line and column positions. Could be useful for syntax highlighting and tools that need to retrieve module information.

@akyrtzi
Copy link
Member

akyrtzi commented Aug 31, 2018

For module references note that SourceEntityWalker::visitModuleReference() exists as callback but IndexSwiftASTWalker is not overriding it to take advantage of it.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Sep 3, 2018

Comment by Bruno Rocha (JIRA)

@akyrtzi Thanks! I got it to work:

    {
      key.kind: source.lang.swift.ref.module,
      key.name: "Swift",
      key.line: 7,
      key.column: 13
    },

Is there anything else I can add to it to make it feel more like an "index"? I thought about providing an USR, but since all USR generation seems to work on top of ValueDecls I wanted to be sure if this is possible in first place.

For reference: rockbruno@cde8d3d

@akyrtzi
Copy link
Member

akyrtzi commented Sep 7, 2018

How is this dumped from `swift-ide-test -print-indexed-symbols` ? Checkout test cases in `test/Index` to see how to add a test case for this.

I think we also need to define a USR for it. Try opening a PR so we can iterate on it.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Sep 8, 2018

Comment by Bruno Rocha (JIRA)

It returns an empty string unfortunately:

1:8 | module/Swift | Swift | | Ref | rel: 0

@swift-ci
Copy link
Collaborator Author

Comment by Bruno Rocha (JIRA)

Managed to generate an USR to them. #19243

@swift-ci
Copy link
Collaborator Author

Comment by Bruno Rocha (JIRA)

@akyrtzi What do you think?

@akyrtzi
Copy link
Member

akyrtzi commented Sep 17, 2018

Clang has similar need, index module references with an associated USR. That will allow us to index the same module references across Swift and Objective-C, using the same USR.
Basically, give me some time, I'll introduce some APIs on the clang side to create a USR for a module, and you'll then be able to use them for the Swift side as well.

@swift-ci
Copy link
Collaborator Author

Comment by Bruno Rocha (JIRA)

Sounds good.

@akyrtzi
Copy link
Member

akyrtzi commented Sep 28, 2018

PR has been merged.

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

No branches or pull requests

2 participants