-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Broken source fixer #57
Conversation
Okay, things are hooked up now but probably not in the best way (there's a bit of repetition and you have to remember to call In any case I can already showcase the improvements. Take a look at this: It's autocompleting the Or this: It's showing the hierarchy at the top (Foo -> Bar -> foo) but the source is kind of broken. Also "Go to definition" works fine in this state. |
This is ready for review now. I've tried it with a bunch of files, removing "end" or curly braces, and it seems to be working fine. One thing I noticed is that there weren't specs before so CI didn't run them. If we are going to have specs we might want to run them in CI. |
Sorry busy week I won't be able to review until this week end, but it is looking great from what I read so far ❤️.
True! I'll plug a github actions workflow for that. |
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 perfect to me, this is a great addition! 👍
If we are going to have specs we might want to run them in CI.
It should be allright now, the CI runs specs as a required check ✔️ (which is actually pending for this PR since the workflow did not exist at the time of the latest commit)
end | ||
|
||
private def self.line_keyword(line : String) : String? | ||
if line.starts_with?(/\s* |
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.
would it make sense to add begin
to the list as well?
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.
Oh, good catch! I think I also missed macro, and rescue/ensure/else for begin and def. I'll add those on Monday.
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.
Done! I forgot to mention that Mondays happen on Wednesday in Argentina.
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.
I forgot to mention that Mondays happen on Wednesday in Argentina.
Haha no worries in France we have the same concept 😄.
I'm not seeing any new commits though, did you forget to push by any chance?
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.
Oh, I pushed to this repo instead of the fork. Now it's done.
This is for #55, but it's just a part of it.
This PR introduces a new type,
BrokenSourceFixer
. It tries to add missing "end" and closing curly braces based on the code's indentation. It assumes users will use two spaces of indentation and use the formatter so that everything is usually aligned except when they are typing an expression.The idea then would be to run this code before feeing it to the parser, if the source code is actually broken (for that we could try to parse it and if it parses fine then there's nothing to fix.)
I didn't hook up the code yet because I wasn't sure exactly where to do that.
Edit: another thing is that the fixer tries not to add new lines. In that way any code that needs parse locations will still work fine, as the fixer only adds to the end of lines.