Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ruby_parser support #4

Closed
wants to merge 39 commits into
from

Conversation

Projects
None yet
4 participants
Member

phiggins commented Jul 2, 2012

This is a first pass at getting heckle to work with ruby_parser instead of ParseTree. Most of the difficulty came from the interfaces used to interact with ParseTree vs. ruby_parser. ParseTree's ability to grab a class/method's sexp at runtime fits heckle's use case much better than the solution I came up with for ruby_parser, iterating over the files in the project directory and parsing them all. This way is also much slower.

Other things:

  • I've only done enough work to get the unit tests to pass, I haven't actually tried running heckle on anything, so bugs probably remain.
  • I had to change two unit tests to get them to pass. Lame, I know.
  • Only tested with 1.8.7-p358.
Member

phiggins commented Jul 2, 2012

I wanted to add one more thing:

  • The method lookup code is incredibly naive, and will only work for un-nested classes, and can't handle multiple matching things in the directory tree (which is why I had to remove sample/lib/heckled.rb).
Owner

zenspider commented Jul 2, 2012

I'm having problems getting the tests to run, so let's take a whack at it Tuesday.

@dkubb dkubb and 1 other commented on an outdated diff Jul 3, 2012

lib/heckle.rb
@@ -11,6 +11,25 @@ def to_class
end
end
+class Sexp
+ # REFACTOR: move to sexp.rb
+ def deep_each(&block)
+ self.each_sexp do |sexp|
+ block[sexp]
+ sexp.deep_each(&block)
+ end
+ end
+
+ # REFACTOR: move to sexp.rb
+ def each_sexp
+ self.each do |sexp|
@dkubb

dkubb Jul 3, 2012

What about:

def each_sexp(&block)
  grep(Sexp).each(&block)
end
@phiggins

phiggins Jul 3, 2012

Member

These methods were recently added to sexp_processor so hopefully they won't exist here much longer.

@dkubb dkubb and 1 other commented on an outdated diff Jul 3, 2012

lib/heckle.rb
+ return pt if method_name.nil?
+
+ pt.deep_each do |node|
+ if class_method
+ return node if node[0] == :defs && node[2] == clean_name
+ else
+ return node if node[0] == :defn && node[1] == clean_name
+ end
+ end
+ end
+
+ nil
+ end
+
+ def expand_dirs_to_files *dirs
+ extensions = ['rb'] # + Flay.load_plugins
@dkubb

dkubb Jul 3, 2012

Did you mean to leave the reference to Flay.load_plugins here?

@phiggins

phiggins Jul 3, 2012

Member

That code was copied almost directly from Flay, so I most certainly did not. That'll have to be fixed before an actual release is done.

agrimm commented Sep 3, 2012

I have two minor commits on the branch ph_ruby_parser of my repo. Sorry this is a comment - I don't know how to do a pull request on a pull request.

@ghost ghost assigned zenspider Sep 10, 2012

Owner

zenspider commented Sep 10, 2012

@phiggins -- let's go through this Tuesday and get it reviewed and merged in.

Owner

zenspider commented Sep 10, 2012

@agrimm once we get this cleaned up and merged you should be able to do a pull req... tho we may mess up your merge in our cleanup.

Owner

zenspider commented Mar 28, 2016

@phiggins is this dead?

@zenspider zenspider closed this Mar 29, 2016

Owner

zenspider commented Mar 29, 2016

I really wish I hadn't let the code go where it went. Way too complex to deal with now. Starting over might actually be a better idea.

Member

phiggins commented Mar 29, 2016

I would like to revisit the idea some day, but yeah, lots of cruft and lots of updates to ruby and all of the dependencies made it tough to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment