mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Inverted the match logic to skip comments, attribute macros, and whitespace before the appropriate keywords.
This commit is contained in:
parent
09da74a35d
commit
6df414faa2
1 changed files with 4 additions and 13 deletions
|
@ -382,19 +382,10 @@ impl Module {
|
||||||
for (vis, syntax) in replacements {
|
for (vis, syntax) in replacements {
|
||||||
let item = syntax.children_with_tokens().find(|node_or_token| {
|
let item = syntax.children_with_tokens().find(|node_or_token| {
|
||||||
match node_or_token.kind() {
|
match node_or_token.kind() {
|
||||||
// We're looking for the start of functions, impls, structs, traits, and other documentable/attribute
|
// We're skipping comments, doc comments, and attribute macros that may precede the keyword
|
||||||
// macroable items that would have pub(crate) in front of it
|
// that the visibility should be placed before.
|
||||||
SyntaxKind::FN_KW
|
SyntaxKind::COMMENT | SyntaxKind::ATTR | SyntaxKind::WHITESPACE => false,
|
||||||
| SyntaxKind::STRUCT_KW
|
_ => true,
|
||||||
| SyntaxKind::ENUM_KW
|
|
||||||
| SyntaxKind::TRAIT_KW
|
|
||||||
| SyntaxKind::TYPE_KW
|
|
||||||
| SyntaxKind::CONST_KW
|
|
||||||
| SyntaxKind::MOD_KW => true,
|
|
||||||
// If we didn't find a keyword, we want to cover the record fields in a struct
|
|
||||||
SyntaxKind::NAME => true,
|
|
||||||
// Otherwise, the token shouldn't have pub(crate) before it
|
|
||||||
_ => false,
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue