-
Notifications
You must be signed in to change notification settings - Fork 419
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
chapel-py: fix "IDs available in scope" #24988
chapel-py: fix "IDs available in scope" #24988
Conversation
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
The names of used modules appear via the imports that bring them in. Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Could you please add a C++ test for getSymbolsAvailableInScope ? It'll be much easier to check that it's working correctly that way (make sure to check import Module.Item
and use Module
and use Module only Thing1 as Thing2
). Also it'll be much easier to avoid future problems with the language server if we have a C++ test for this.
const IdAndFlags::FlagSet& excludeFilter, | ||
const Scope* scope) { | ||
auto scopeAst = parsing::idToAst(context, scope->id()); | ||
auto visibility = scopeAst->toDecl()->visibility(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you are just moving this code, but could you fix this issue with it?
It should use parsing::idIsPrivateDecl
to avoid calling idToAst
which is both slow and unlikely to be reusable from revision to revision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't quite work because the argument expects a Visibility
, not a boolean. But I'll add a new parsing query to retrieve the visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, we don't need to distinguish here between default visibility and public. You could just write
auto visibility = idIsPrivateDecl(context, scope->id()) ? Decl::PRIVATE : Decl::Public
Distinguishing between public and default visibility is useful in the uAST but I can't imagine any reason it would matter in scope resolution (and in fact, if it does matter, it's probably a bug, because the default visibility is public).
Of course you could put this in a helper in parsing-queries.
if (kind == VisibilitySymbols::ONLY_CONTENTS || | ||
kind == VisibilitySymbols::CONTENTS_EXCEPT) { | ||
auto& namePairs = inVisibilitySymbols->names(); | ||
// Should we even bother checking the names? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove this comment? Checking the names seems reasonable to handle use X as Y
etc. And it does check the names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewing the changes in chpl-language-server.py
, looks great
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test! I think it'll really help us to maintain this functionality.
|
||
const ModuleVec& vec = parseToplevel(context, path); | ||
|
||
checkScopeContents(context, vec[0], {"x", "f1", "f2"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably, it should also include M
(but oddly enough, only for use in use
/ import
). Also, arguably, it should include the included-by-default symbols. It's not important to me that it change behavior from what we have right now, but might be worth a comment here just to make updating the test easier.
Signed-off-by: Danila Fedorin <[email protected]>
The
doLookupInScope
family of functions have special logic to introduce the symbol-to-be-imported into the search results. Specifically, use statements in the formuse IO
bringIO
into scope in addition the symbols fromIO
. Prior to this PR,getSymbolsAvailableInScope
did not handle this, assuming that iteration overscope->declared()
was sufficient. This PR addresses that problem.As a result, renaming modules now works properly with autocompletions in CLS, and the language server doesn't need to rely on
findUsedImportedIds
.Reviewed by @jabraham17 and @mppf -- thanks!
Testing