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

Use stored source instead of Unparser to format ASTs #827

Merged
merged 3 commits into from
Jan 20, 2016

Conversation

troessner
Copy link
Owner

No description provided.

@chastell chastell mentioned this pull request Jan 16, 2016
@mvz
Copy link
Collaborator

mvz commented Jan 17, 2016

It seems the thing to do is to implement a simple formatter in each of our SexpExtensions, for the relevant node types. I wouldn't use #to_s though, since we need that to inspect the AST structure sometimes.

@troessner
Copy link
Owner Author

It seems the thing to do is to implement a simple formatter in each of our SexpExtensions, for the relevant node types.

Yes, exactly. We'd need to drop SexpFormatter completely, first of all because we'd remove unparser from it, and second of all, the logic for "unparsing" is highly specific. We could either blow up SexpFormatter out of proportion .....or put the logic where we used to call SexpFormatter.

@mvz mvz force-pushed the remove-unparser branch 4 times, most recently from fdbacea to 66be5f2 Compare January 19, 2016 09:58
@mvz mvz changed the title [Wip] Remove unparser. Use stored source instead of Unparser to format ASTs Jan 19, 2016
@mvz
Copy link
Collaborator

mvz commented Jan 19, 2016

@troessner, @chastell this is ready for review. I went a completely different route, using the actual source of the expression as provided by parser.

@@ -18,7 +18,7 @@ Feature: Offer different ways how to load configuration
"""
smelly.rb -- 3 warnings:
[4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
[4, 5]:DuplicateMethodCall: Smelly#m calls puts(@foo.bar) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
[4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
Copy link
Owner Author

Choose a reason for hiding this comment

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

Why not leave the brackets? I find this better readable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm now using the actual source text so it depends on how it's actually written there.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Makes sense ;)

@troessner
Copy link
Owner Author

First review -> done.
Couple of questions and comments but nothing bigger, looks great overall!

AST::Node stores the parsed source so we can use that directly. As a
result, some smell masking may have to be adjusted.

Since SexpFormatter is no longer needed, it is removed, as is its
dependency, Unparser.

Since Parser 2.3.0 behaves differently on certain syntax errors and support
for it is part of an upcomping change, the allowed versions of Parser
are limited, as Unparser did in the past.
@troessner
Copy link
Owner Author

Great job, merging!

troessner pushed a commit that referenced this pull request Jan 20, 2016
Use stored source instead of Unparser to format ASTs
@troessner troessner merged commit 428d850 into master Jan 20, 2016
@troessner troessner deleted the remove-unparser branch January 20, 2016 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants