Skip to content

AST: refactor getLoc() of decls to have a single entry point for all decl kinds, NFC #27398

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

Merged
merged 1 commit into from
Sep 27, 2019

Conversation

nkcsgexi
Copy link
Contributor

After we start to serialize the result of getLoc() in the
.swiftsourceinfo file, getLoc() needs a single entry point to look up via
USRs in the serialized format.

…decl kinds, NFC

After we start to serialize the result of getLoc() in the
.swiftsourceinfo file, getLoc() needs a single entry point to look up via
USRs in the serialized format.
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please smoke test Linux platform

@nkcsgexi nkcsgexi merged commit aeed242 into swiftlang:master Sep 27, 2019
@nkcsgexi nkcsgexi deleted the get-loc-refactor branch September 27, 2019 03:45
@jrose-apple
Copy link
Contributor

This doesn't seem right. swiftsourceinfo still isn't going to be able to provide SourceLocs, which are references into open buffers.

@nkcsgexi
Copy link
Contributor Author

hmm, that seems to be our plan. When getLoc() is invoked for a module-imported decl, the local source file is lazily loaded and a SourceLoc instance is formed pointing to that buffer.

@jrose-apple
Copy link
Contributor

:-/ I guess you could do that. I was thinking you'd put line/column information in the file rather than offsets, so that it was already in user display form. But I guess LSP wants line/column and offset, so either we record all of it or we need to read the buffer in some way anyway.

@nkcsgexi
Copy link
Contributor Author

:) One design goal of this is to be entirely transparent to the rest of the compiler pipeline. Plus translating from SourceLoc to line:column isn't so heavy for diagnostic cases

@jrose-apple
Copy link
Contributor

I was thinking being transparent to the rest of the compiler pipeline could mean modifying DiagnosticEngine rather than modifying getLoc. DiagnosticEngine's already where the fake pretty-printed SourceLocs come from.

@nkcsgexi
Copy link
Contributor Author

We have to channel through getLoc() to be compatible with how merge module works, right?

@jrose-apple
Copy link
Contributor

You have to do something, but whether that means going through getLoc or having your source info serializer call getSourceInfo explicitly is up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants