Title: [490] trunk/jparsetree/lib/jparsetree.rb: caught up with JRuby 0.9.9 (seems like the Java integration
Revision
490
Author
murphee
Date
2007-04-24 13:01:21 -0400 (Tue, 24 Apr 2007)

Log Message

caught up with JRuby 0.9.9 (seems like the Java integration
now handles a call like "getCPath" differently).
Also: fixed a few other issues, bringing failures down 
to 6;

Modified Paths

Diff

Modified: trunk/jparsetree/lib/jparsetree.rb (489 => 490)


--- trunk/jparsetree/lib/jparsetree.rb	2007-04-24 15:26:08 UTC (rev 489)
+++ trunk/jparsetree/lib/jparsetree.rb	2007-04-24 17:01:21 UTC (rev 490)
@@ -35,6 +35,11 @@
 
 class ParseTree       
 
+
+  # Compatibility for ParseTree which requires a boolean argument;
+  def initialize(arg)
+  end
+
 VERSION = '0.9.8.371'
 
   ##
@@ -201,6 +206,7 @@
       # I'm not sure if this is the best way... it's either this or
       # setting it to nil;
       obj.source_location = (-1..-1)
+      abc = 1 
     end
     obj
   end
@@ -496,7 +502,7 @@
     
 #    @sexpr << :class
 #    @sexpr << iVisited.CPath.name.to_sym
-    clazzname = iVisited.CPath.name.to_sym
+    clazzname = iVisited.getCPath.name.to_sym
     visit(iVisited.super_node)
 
     if iVisited.super_node != nil 
@@ -506,6 +512,8 @@
     end
     visit(iVisited.body_node)
     klazz = location([:class,clazzname, superclazz, [:scope, JParseTree.filter_nested_arrays(@stackElements.pop)]], iVisited)
+#    puts "CLASS #{klazz}"
+    
     if @stackElements == nil
       @sexpr << klazz
     else
@@ -557,19 +565,29 @@
   
   def visitDRegxNode(iVisited)
     temp = []
-   # p "REGX"
-    iVisited.child_nodes.each {|n| 
+#    p "REGX #{iVisited.child_nodes}"
+    iVisited.child_nodes.each {|n|
     # TODO: Bug? how to get rid of :dstr?
-       if !n.nil?
-        n.accept(self.to_java_object) 
-        temp << @stackElements.pop
+       if n
+        n.accept(self.to_java_object)
+        result = @stackElements.pop
+        temp << JParseTree.filter_nested_arrays(result)
        end
     }
     temp = JParseTree.filter_nested_arrays(temp)
+    # HACK: ParseTree wants DRegx Nodes like this:
+    # the first element must be a string literal, so any [:str, "FOO"] must be "Foo
+    if temp.size > 0
+      if temp.first.is_a? Array
+        if temp.first.first == :str
+          temp[0] = temp.first.last
+        end
+      end
+    end
     if iVisited.once
-     temp[0] = :dregx_once
+     temp.insert(0, :dregx_once)
     else
-     temp[0] = :dregx 
+     temp.insert(0, :dregx) 
     end
     
     @stackElements << location(temp, iVisited)
@@ -609,7 +627,7 @@
     temp = []
     if iVisited.child_nodes.size > 0
       iVisited.child_nodes[0].accept(self.to_java_object) 
-      temp << @stackElements.pop
+      temp << JParseTree.filter_nested_arrays(@stackElements.pop)
     end
 #    p "Dsym #{temp.inspect} "
     # HACK: repackage [[:dstr, ...]] -> [:dsym, ...]
@@ -618,11 +636,13 @@
     
     @stackElements << location(temp, iVisited) 
     if iVisited.child_nodes.size > 1
-     iVisited.child_nodes.each {|n| 
-        if !n.nil?
-         #p "n " 
-        n.accept(self.to_java_object) 
-         temp =  @stackElements.pop
+     # HACK: grrr... the dam child_nodes list object or the Java List object that is returned
+     # doesn't seem to understand ranges as a way to create sublists; 
+     rest = iVisited.child_nodes.subList(1, iVisited.child_nodes.size )
+     rest.each {|n|
+        if n  
+         n.accept(self.to_java_object) 
+         temp =   JParseTree.filter_nested_arrays(@stackElements.pop)
          @stackElements.last << temp
         end
      }
@@ -1160,7 +1180,15 @@
   def visitPostExeNode(iVisited)
     # puts iVisited.to_s
     @stackElements ||= [] 
-    @stackElements << location([:postexe], iVisited)
+    tmp = [:iter, [:postexe], nil]
+    if iVisited.child_nodes 
+      iVisited.child_nodes.each {|node|  
+        visit(node)
+        tmp << JParseTree.filter_nested_arrays(@stackElements.pop)
+      }     
+    end
+    @stackElements << location(tmp, iVisited)
+
     nil
   end
   
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to