-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
reflow #95
reflow #95
Conversation
3b7ec2b
to
3b82651
Compare
a9eba37
to
55713f7
Compare
d9778d0
to
5225e3f
Compare
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.
Looks pretty well, I have yet to test this, a few nits as per usual 🛩️
This comment has been minimized.
This comment has been minimized.
The assumption that there is one span per line is incorrect though. Counter example: #[doc=r#"yada
yada
"#] |
Added initial hooks for args and forwarding all of that, there are still a few 🚧 areas which need resolving. Checklist moved to initial PR comment. |
Regarding the Span to line mapping: We can't really do something about that, the only (hacky) workaround I can think of is to count the number of whitespaces on multiline spans. In other words, use |
Not sure I understand your last comment. Do you mean newlines I stead of spaces? Not sure how that will help us here? I think for |
e61f1ff
to
5e8fcf4
Compare
r#" Some more text after the rule which represents a | ||
paragraph"#, | ||
]; | ||
|
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.
The reflow check here is correct, but we could never use this as a direct replacement, since it would cover additional lines.
We would need a injection suggestion with a source span length of 0 (so nothing is removed, only text is inserted at that position). If this is the case, the comment type (///
in this case ) needs to be added as a injection for any additional lines inserted.
Semantically a "change" (to disambiguate) might have multiple spans it's going to cover, where a suggestion is only for one particular span - that's how it's modelled right now. I would stick with that, since all the selection code depends on that iirc - semantically it would make sense to move suggestions into multispan handling and span -> replacement based map.
7c92555
to
a1b2868
Compare
Another rebase round to get CI going. |
Progress! 🚂 There is still one assertion that fails, but you are getting closer! > cargo run -- reflow --code 27 -r demo/src/
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/cargo-spellcheck reflow --code 27 -r demo/src/`
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs DoubleSlashEM
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: MacroDocEq vs TripleSlash
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs MacroDocEq
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: MacroDocEq vs TripleSlash
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs MacroDocEq
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs DoubleSlashEM
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs DoubleSlashEM
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: MacroDocEq vs TripleSlash
[2020-10-07T07:15:31Z ERROR cargo_spellcheck::documentation::literalset] Adjacent literal is not the same comment variant: TripleSlash vs MacroDocEq
error: spellcheck(Reflow)
--> /media/supersonic1t/projects/cargo-spellcheck/demo/src/nested/mod.rs:11
|
11 | Overly long statements that should be reflown since they are __very__ long and exceed the line limit.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(1/6) Apply this suggestion [y,n,q,a,d,j,e,?]?
» Overly long statements that should be reflown since they are __very__ long
... /// and exceed the line limit.
thread 'main' panicked at 'Extracting `Bandaid`s from `State` must not fail. qed: BUG: Found a range which does not cover its own chunk', src/action/interactive.rs:162:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace and one test is still going 💥
|
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.
Nice! 👍 I have yet to test it, but looks good!
Note that this is extremely ugly, and the concerns need to be split between the `Reflow` checker creating better replacements and defining more strictly what the concren of `fn correct_lines` truely is. Imho, it should be a dumb replacer, taking spans and doing something to them, the fact that it is line based doesn't do us any good now, it should accept arbitrary spans with replacement text, something that is derived from `BandAid`, not necessarily bandaids themselves. `fn correct_lines` then should just traverse the file content and patch the relevant Spans (inject or replace, where delete is just shortcut for replacing something with an empty string literal) removing the whole concept of lines other than as a referential system. This will also aleviate the replacing bogus issues arising from replacing newlines char types with \n.
Part one as outlined in the previous description.
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.
With this change you cannot represent insertions with BandAid anymore, can you? A span is by definition at least length 1 since the start and end members are inclusive.
We don't need any insertions. Any BandAid always replaces something. |
What does this PR accomplish?
Pushing #72 over the 🏁
Closes #39
Changes proposed by this PR:
Remaining Challenges
--code
exit code flags like we do forcheck
Notes to reviewer:
📜 Checklist
./demo
sub directory