Skip to content

Conversation

popzxc
Copy link
Contributor

@popzxc popzxc commented Sep 12, 2020

This pull request adds a bunch of new postfix completions for format-like string literls.

For example, "{32} {some_var:?}".println will expand to println!("{} {:?}", 32, some_var).

Postfix completions were added for most common format-like macros:

  • println -> println!(...)
  • fmt -> format!(...)
  • panic -> panic!(...)
  • log macros:
    • logi -> log::info!(...)
    • logw -> log::warn!(...)
    • loge -> log::error!(...)
    • logt -> log::trace!(...)
    • logd -> log::debug!(...)

fmt_postfix

Copy link
Contributor

@matklad matklad left a comment

Choose a reason for hiding this comment

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

Nice!

This looks good overall to me, but I've added a bunch of code-style style comments

@popzxc popzxc force-pushed the fmt-like-postfix-completions branch from fadb0a0 to 97f2905 Compare October 2, 2020 11:51
@popzxc
Copy link
Contributor Author

popzxc commented Oct 2, 2020

Hopefully all the issues are addressed.

@matklad
Copy link
Contributor

matklad commented Oct 2, 2020

bors r+

👍

@bors
Copy link
Contributor

bors bot commented Oct 2, 2020

@bors bors bot merged commit 6574a6f into rust-lang:master Oct 2, 2020
@popzxc popzxc deleted the fmt-like-postfix-completions branch October 2, 2020 12:19
bors added a commit that referenced this pull request Sep 12, 2022
…esmondWillowbrook

New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args
bors added a commit that referenced this pull request Sep 12, 2022
…esmondWillowbrook

New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args
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