Skip to content

feat: Respect #[doc(hidden)] in dot-completion #9681

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 2 commits into from
Jul 23, 2021
Merged

feat: Respect #[doc(hidden)] in dot-completion #9681

merged 2 commits into from
Jul 23, 2021

Conversation

jonas-schievink
Copy link
Contributor

This adds CompletionContext::is_visible as a convenience method that checks visibility, presence of doc(hidden), and whether the completed item is in the same crate as the completion site or not. We only complete doc(hidden) items from the same crate.

This doesn't yet work for all completions: qualified_path completions use Module::scope and ScopeDef, which doesn't work with this.

Part of #7718

None => return false,
};
if !vis.is_visible_from(self.db, module.into()) {
// FIXME: if the definition location is editable, also show private items
Copy link
Member

@Veykril Veykril Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like

let root_file = defining_crate.root_file(db);
let source_root_id = db.file_source_root(root_file);
!db.source_root(source_root_id).is_library

tells us whether the file is in the workspace or not.
we use that logic for trying to prevent renames in dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to need some improvements to the test fixture code so it doesn't break tests for item privacy

@jonas-schievink
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 23, 2021

@bors bors bot merged commit 6494193 into rust-lang:master Jul 23, 2021
@lnicola lnicola changed the title Respect #[doc(hidden)] in dot-completion feat: Respect #[doc(hidden)] in dot-completion Jul 23, 2021
@jonas-schievink jonas-schievink deleted the doc-hidden-completion branch July 23, 2021 15:22
bors bot added a commit that referenced this pull request Jul 28, 2021
9715: feat: Make most completions respect `#[doc(hidden)]` r=jonas-schievink a=jonas-schievink

Closes #2003

This continues #9681 and makes most other completion sources respect `#[doc(hidden)]`. After this, only flyimport is missing support for this.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
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