|
From: Zach D. <zd...@us...> - 2005-07-12 00:03:50
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11409/src/org/rubypeople/rdt/internal/core Modified Files: RubyScriptStructureBuilder.java Added Files: RubySingletonMethod.java Log Message: Changes to fix rdt bug 959808. --- NEW FILE: RubySingletonMethod.java --- /* * Created on Jul 10, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.rubypeople.rdt.internal.core; /** * RubySingletonMethod represents a singleton method in ruby. Example: * [code] * class A * def self.method1 * end * * def A.method2 * end * * class << self * def method3 * end * end * end * [/code] * * @author zdennis */ public class RubySingletonMethod extends RubyMethod { /** * @param parent * @param name */ public RubySingletonMethod(RubyElement parent, String name) { super(parent, name); // TODO Auto-generated constructor stub } /* * (non-Javadoc) * @see org.rubypeople.rdt.core.IRubyElement#getElementType() */ public int getElementType(){ return RubyElement.SINGLETON_METHOD; } } Index: RubyScriptStructureBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RubyScriptStructureBuilder.java 12 Mar 2005 15:30:03 -0000 1.7 --- RubyScriptStructureBuilder.java 12 Jul 2005 00:03:06 -0000 1.8 *************** *** 679,709 **** } - /* - * (non-Javadoc) - * - * @see org.jruby.ast.visitor.NodeVisitor#visitDefsNode(org.jruby.ast.DefsNode) - */ - public void visitDefsNode(DefsNode iVisited) { - handleNode(iVisited); - RubyElement type = getCurrentType(); - RubyMethod method = new RubyMethod(type, iVisited.getName()); - modelStack.push(method); ! RubyMethodElementInfo info = new RubyMethodElementInfo(); ! info.setArgumentNames(getArgs(iVisited.getArgsNode())); ! // TODO Set more info! ! infoStack.push(info); ! newElements.put(method, info); ! // FIXME Evaluate the receiver! ! visitNode(iVisited.getReceiverNode()); ! visitNode(iVisited.getArgsNode()); ! visitNode(iVisited.getBodyNode()); ! modelStack.pop(); ! infoStack.pop(); ! } /* * (non-Javadoc) --- 679,746 ---- } ! /* ! * (non-Javadoc) ! * ! * @see org.jruby.ast.visitor.NodeVisitor#visitDefsNode(org.jruby.ast.DefsNode) ! */ ! public void visitDefsNode(DefsNode iVisited) { ! handleNode(iVisited); ! ! // Get the information no the current parent of this method ! RubyElementInfo parentInfo = infoStack.peek(); ! ! /* Get the name of the current static method and add the name of the ! * class or module to the beginning of it. This avoids instance method ! * naming conflicts. e.g.: ! * class A ! * def self.method; end ! * def method; end ! * end ! * will give us: ! * A.method ! * method ! * in the Outline View. ! */ ! String name; ! if( parentInfo instanceof RubyTypeElementInfo ){ ! name = new String(((RubyTypeElementInfo)parentInfo).getName()) ! + "." + iVisited.getName(); } ! else{ ! name = iVisited.getName(); } ! ! // Get the visibility of the current static method ! Visibility visibility = currentVisibility; ! ! // Get the type of the current parent element ! RubyElement type = getCurrentType(); ! RubyMethod method = new RubySingletonMethod(type, name); ! modelStack.push(method); ! ! parentInfo.addChild( method ); ! ! RubyMethodElementInfo info = new RubyMethodElementInfo(); ! ! // TODO Set more info! ! infoStack.push(info); ! ISourcePosition pos = iVisited.getPosition(); ! setKeywordRange("def", pos, info, name); ! ! info.setArgumentNames(getArgs(iVisited.getArgsNode())); ! info.setVisibility(convertVisibility(visibility)); ! newElements.put(method, info); ! // FIXME Evaluate the receiver! ! visitNode(iVisited.getReceiverNode()); ! visitNode(iVisited.getArgsNode()); ! visitNode(iVisited.getBodyNode()); ! ! modelStack.pop(); ! infoStack.pop(); ! } + /* * (non-Javadoc) |