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

feat: completion list suggests constructor like & builder methods first #16117

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

mustakimali
Copy link
Contributor

@mustakimali mustakimali commented Dec 13, 2023

When typing MyType:: the completion items' order could be re-ordered based on how likely we want to select those:

  • Constructors: new like functions to be able to create the type,
  • Constructors that take args: Any other function that creates Self,
  • Builder Methods: any builder methods available,
  • Regular methods & associated functions (no change there)

image

In this photo, the order is:

  • new constructor is first
  • new_builder second is a builder method
  • aaaanew is a constructor that takes arguments, is third and is irrespective of its alphabetical order among names.

Another Example using actix HttpServer shows preferring constructor without self arg first (the new method)

image

image

I've dropped my previous idea of highlighting these functions in the rustdoc (rust-lang/rust#107926)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 13, 2023
crates/ide-completion/src/item.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2024
@bors
Copy link
Collaborator

bors commented Jan 10, 2024

☔ The latest upstream changes (presumably #16274) made this pull request unmergeable. Please resolve the merge conflicts.

crates/ide-completion/src/item.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/item.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
@Veykril Veykril added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2024

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git rebase -i master
$ # delete any merge commits in the editor that appears
$ git push --force-with-lease

The following commits are merge commits:

@mustakimali mustakimali changed the title feat: completion list suggests methods in the order we most likely want feat: completion list suggests constructor like & builder methods first Jan 24, 2024
@Veykril Veykril added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits labels Feb 9, 2024
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
crates/ide-completion/src/render/function.rs Outdated Show resolved Hide resolved
@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 12, 2024
@mustakimali mustakimali force-pushed the mo-order branch 2 times, most recently from c8f9815 to ad700ed Compare February 12, 2024 22:30
@mustakimali mustakimali force-pushed the mo-order branch 2 times, most recently from 1f9e686 to 2464387 Compare February 12, 2024 23:09
@Veykril
Copy link
Member

Veykril commented Feb 13, 2024

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Feb 13, 2024

📌 Commit 2c76104 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Feb 13, 2024

⌛ Testing commit 2c76104 with merge 3c4d642...

@bors
Copy link
Collaborator

bors commented Feb 13, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 3c4d642 to master...

@bors bors merged commit 3c4d642 into rust-lang:master Feb 13, 2024
11 checks passed
@mustakimali mustakimali deleted the mo-order branch February 13, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants