|
From: Christopher W. <caw...@us...> - 2006-04-07 16:42:56
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18040/src/org/rubypeople/rdt/internal/core Modified Files: RubyModelManager.java RubyScriptStructureBuilder.java RubyProject.java Log Message: fix a nasty infinite loop that showe dup when using the RubyBrowsingPerspective. Also fix the source range/position for singleton/class methods. Index: RubyProject.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** RubyProject.java 29 Mar 2006 22:46:22 -0000 1.21 --- RubyProject.java 7 Apr 2006 16:42:45 -0000 1.22 *************** *** 725,727 **** --- 725,731 ---- } + public IRubyScript getRubyScript(IFile file) { + return new RubyScript(this, file, file.getName(), DefaultWorkingCopyOwner.PRIMARY); + } + } Index: RubyScriptStructureBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** RubyScriptStructureBuilder.java 6 Apr 2006 22:26:09 -0000 1.21 --- RubyScriptStructureBuilder.java 7 Apr 2006 16:42:45 -0000 1.22 *************** *** 817,820 **** --- 817,824 ---- if (node instanceof HashNode) return "{}"; + if (node instanceof SelfNode) + return "self"; + if (node instanceof ConstNode) + return ((ConstNode)node).getName(); if (node instanceof ZArrayNode) return "[]"; *************** *** 879,888 **** * 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(); } --- 883,892 ---- * method; end end will give us: A.method method in the Outline View. */ ! String fullName; ! String receiver = stringRepresentation(iVisited.getReceiverNode()); ! if (receiver != null && receiver.trim().length() > 0) { ! fullName = receiver + "." + iVisited.getName(); } else { ! fullName = iVisited.getName(); } *************** *** 894,898 **** // Get the type of the current parent element RubyElement type = getCurrentType(); ! RubyMethod method = new RubySingletonMethod(type, name, parameterNames); modelStack.push(method); --- 898,902 ---- // Get the type of the current parent element RubyElement type = getCurrentType(); ! RubyMethod method = new RubySingletonMethod(type, iVisited.getName(), parameterNames); modelStack.push(method); *************** *** 904,908 **** infoStack.push(info); ISourcePosition pos = iVisited.getPosition(); ! setKeywordRange("def", pos, info, name); info.setArgumentNames(parameterNames); --- 908,912 ---- infoStack.push(info); ISourcePosition pos = iVisited.getPosition(); ! setKeywordRange("def", pos, info, fullName); info.setArgumentNames(parameterNames); Index: RubyModelManager.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RubyModelManager.java 4 Apr 2006 23:06:22 -0000 1.8 --- RubyModelManager.java 7 Apr 2006 16:42:45 -0000 1.9 *************** *** 748,751 **** --- 748,776 ---- } } + + public static IRubyElement create(IFile file, IRubyProject project) { + if (file == null) { + return null; + } + if (project == null) { + project = RubyCore.create(file.getProject()); + } + + if (file.getFileExtension() != null) { + String name = file.getName(); + if (org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(name)) + return createRubyScriptFrom(file, project); + } + return null; + } + + public static IRubyElement createRubyScriptFrom(IFile file, IRubyProject project) { + if (file == null) return null; + + if (project == null) { + project = RubyCore.create(file.getProject()); + } + return project.getRubyScript(file); + } } |