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

Model call chains as an AbstractTokenTarget #443

Merged
merged 60 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
bcb8faf
wip
reese Jul 27, 2023
850216c
This mostly works!
reese Jul 30, 2023
285abc6
wip
reese Aug 7, 2023
b55a612
Fix line length checking for call chain breakables
reese Aug 8, 2023
f20426f
Squash some more bugs
reese Aug 10, 2023
744e817
Fix line winding in calls
reese Aug 11, 2023
7f0e36c
Fix indentation in nested breakables inside call chains
reese Aug 11, 2023
ad42bcf
Assertion fix
reese Aug 14, 2023
cff3121
wip
reese Aug 15, 2023
5be646b
its alive!
reese Aug 16, 2023
a2fa7d4
It's _even more alive_
reese Aug 16, 2023
4cb900c
Fix really long single-dot methods being multilined
reese Aug 16, 2023
c50e057
Get begin/end stuff working
reese Aug 16, 2023
09a6d8b
Fix nested heredocs
reese Aug 17, 2023
1937de0
Fix extra whitespace on empty lines
reese Aug 17, 2023
1c1862a
Fix heredocs in call chains
reese Aug 17, 2023
4fbb2f8
[might delete] try removing my dumb hack
reese Aug 17, 2023
1f08e20
Take another crack at user-multilining
reese Aug 17, 2023
96fa67b
Fix weird line reporting for ArgsAddStar...
reese Aug 17, 2023
9a39f02
Break on call chains before breaking on inner breakables
reese Aug 18, 2023
087a994
Fix precedence
reese Aug 18, 2023
5653f0f
Fix line length check for call chain breakables
reese Aug 18, 2023
dba5aa9
Fix call chains with heredocs embedded in string embedded expressions
reese Aug 18, 2023
86983b6
Reintroduce explicitly single-lining Class.call patterns
reese Aug 18, 2023
825d527
Don't force
reese Aug 18, 2023
a535184
Include leading indentation when calculating bcce line length
reese Aug 19, 2023
b6e42e9
Fix issue with calls in ternaries in embedded expressions
reese Aug 19, 2023
bbb93ba
Fix double quote length
reese Aug 19, 2023
793cf8b
Fix aref line winding
reese Aug 19, 2023
75adc46
Single-line single calls
reese Aug 19, 2023
b856ef0
Fix start_line for parens
reese Aug 19, 2023
a379f3c
Finish todos
reese Aug 19, 2023
d47eb4b
Fix method add args wrapped in parens
reese Aug 19, 2023
9b3e904
Fix comments in methods with visibility modifiers
reese Aug 19, 2023
98d309c
Don't unnecessariliy render expressions in mulitline checking
reese Aug 19, 2023
07aa735
Try simplifying call chain logic
reese Aug 20, 2023
73ecc12
Experiment with new line length checking
reese Aug 20, 2023
f56be0f
Support other user-multilined const expressions
reese Aug 20, 2023
d186036
Fix rendering for const path refs
reese Aug 20, 2023
45fef70
Fix issues with inlined methods and comments
reese Aug 20, 2023
481bf4c
Make conditional modifiers multiline if anything in the conditional i…
reese Aug 20, 2023
73602c8
Fix comment winding for brace blocks
reese Aug 20, 2023
cbc4c2b
Fix paren line winding
reese Aug 20, 2023
0898db8
Skip empty lines in indented heredocs
reese Aug 21, 2023
64d273a
Fix paren expressions with method add args
reese Aug 21, 2023
b47c0cb
Roll back a bunch of unneeded changes
reese Aug 21, 2023
c905b0b
Fix fixture
reese Aug 21, 2023
b4b17eb
Use trait methods instead
reese Aug 21, 2023
55056f7
Fix lint errors
reese Aug 21, 2023
e64fc0e
Actually fix the heredoc whitespace thing this time
reese Aug 21, 2023
7e344a2
Cleanup and some additional commenting
reese Aug 21, 2023
6d6d246
Remove some dead code
reese Aug 21, 2023
3b16c86
Use peekable
reese Aug 21, 2023
9452b63
Use Option instead of making calls unreachable
reese Aug 22, 2023
abb45af
Only clone needed expression when rendering visibility modifers
reese Aug 22, 2023
7052661
Add comment on not shifting comments in block call chain elements
reese Aug 22, 2023
791ed66
Make next_args_list_must_use_parens a bit cleaner
reese Aug 22, 2023
a2bb4e2
Make HeredocStart an actual concrete token
reese Aug 22, 2023
6bc8a3a
Use delims for empty method call parens
reese Aug 22, 2023
24f4b27
Add some tests for call chains with different comment placements
reese Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions fixtures/small/heredocs_actual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ class Foo
rubocop.smash(bad_thing)
end

this_one_is
.in_a_call_chain {
# some stuff
}
.each do
<<~MYHEREDOC
Words are pale shadows of forgotten names.
As names have power, words have power.
Words can light fires in the minds of men.
Words can wring tears from the hardest hearts.
MYHEREDOC
end


puts a
puts b
Expand Down
13 changes: 13 additions & 0 deletions fixtures/small/heredocs_expected.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ class Foo
rubocop.smash(bad_thing)
end

this_one_is
.in_a_call_chain {
# some stuff
}
.each do
<<~MYHEREDOC
Copy link
Owner

Choose a reason for hiding this comment

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

crimes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on the downside, i'm currently still debugging even more crimes

Words are pale shadows of forgotten names.
As names have power, words have power.
Words can light fires in the minds of men.
Words can wring tears from the hardest hearts.
MYHEREDOC
end

puts(a)
puts(b)
foo
12 changes: 10 additions & 2 deletions librubyfmt/src/render_queue_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ impl RenderQueueWriter {
.map(|k| k.is_squiggly())
.unwrap_or(false)
{
let mut new_contents: String =
let indent: String =
(0..(accum.additional_indent * 2)).map(|_| ' ').collect();
new_contents.push_str(part.clone().as_str());
let new_contents = part
.split('\n')
.map(|p| {
let mut line = indent.clone();
line.push_str(p);
line
})
.collect::<Vec<String>>()
.join("\n");
next_token = clats_direct_part(new_contents)
}
}
Expand Down