-
Notifications
You must be signed in to change notification settings - Fork 33
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
Process comments (and extra nodes) separately from the rest of the code #500
base: main
Are you sure you want to change the base?
Changes from all commits
c578f8b
fdc91da
36b8ac4
5ea447c
b406479
e2c24c3
2a39567
6b625f9
6334269
e12a5c9
c346f75
bd04124
0e1d3a1
e2a01c9
e965cd7
7a31f23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,7 @@ | |
x, | ||
|
||
# let blocks | ||
|
||
let x = 1, y = 2 in x + y, | ||
let | ||
x = 1, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,10 @@ pub fn node_kind_for_id(&self, id: u16) -> &'static str { | |
|
||
// More comments. | ||
|
||
enum OneLine { Leaf { content: String, /* comment */ id: usize /* another comment */, size: usize, }, Hardline { content: String, id: usize, }, Space, } // End of line comment | ||
enum OneLine { Leaf { content: String, id: usize, size: usize, }, Hardline { content: String, id: usize, }, Space, } /* comment */ /* another comment */ // End of line comment | ||
|
||
enum ExpandEnum { | ||
Leaf { content: String, /* Comment between fields. */ id: usize, size: usize, }, | ||
Leaf { content: String, id: usize, size: usize, }, /* Comment between fields. */ | ||
Hardline { content: String, id: usize, }, | ||
Space, | ||
} | ||
|
@@ -91,21 +91,25 @@ enum Mode6 { | |
fn inline_let() { let hi = 1; } | ||
|
||
// While loop spacing | ||
while i == true { | ||
let i = 42; | ||
fn my_while() { | ||
while i == true { | ||
let i = 42; | ||
} | ||
} | ||
|
||
// Scoped blocks | ||
{ | ||
let i = 42; | ||
} | ||
{ | ||
let i = 43; | ||
fn foo() { | ||
{ | ||
let i = 42; | ||
} | ||
{ | ||
let i = 43; | ||
} | ||
} | ||
|
||
// Empty block inside of impl function | ||
impl MyTrait for MyStruct { | ||
fn foo() { | ||
// ... logic ... | ||
// ... logic ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not a case of an only child comment? How come this one doesn't bail out? |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1023,8 +1023,8 @@ | |
":" @append_indent_start | ||
(_) @append_indent_end | ||
. | ||
; just doing _ above doesn't work, because it matches the final named node as | ||
; well as the final non-named node, causing double indentation. | ||
; just doing _ above doesn't work, because it matches the final named node as | ||
; well as the final non-named node, causing double indentation. | ||
Comment on lines
+1026
to
+1027
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the second sentence of this part of the heuristic happen?
I haven't looked at the implementation yet, so perhaps that part is not done. |
||
) | ||
|
||
(value_specification | ||
|
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.
So if
--query
is used, then the comment query isNone
? That feels a bit surprising and that ought to be clearly documented.Alternatively, what do you think about: If the query file is
p
, then the comment query file is:Some(q)
, whereq := replace(p, '${language}.scm', '${language}.comment.scm')
, ifq
exists.None
, otherwise.Similar to what you do in
topiary-config/src/language.rs
... Too magical?