|
From: Christopher W. <caw...@us...> - 2006-02-07 15:58:11
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6623/src/org/rubypeople/rdt/internal/core Modified Files: RubyScriptStructureBuilder.java Log Message: fix up our positions (so when we select items in the outline they actually match the editor in reality) Index: RubyScriptStructureBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RubyScriptStructureBuilder.java 27 Jan 2006 17:08:23 -0000 1.15 --- RubyScriptStructureBuilder.java 7 Feb 2006 15:57:52 -0000 1.16 *************** *** 377,383 **** RubyFieldElementInfo info = new RubyFieldElementInfo(); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! ISourcePosition pos = iVisited.getPosition(); ! //setTokenRange(pos, info, name); ! setClassVarRange( pos, info, name ); // TODO Add more information about the variable infoStack.push(info); --- 377,381 ---- RubyFieldElementInfo info = new RubyFieldElementInfo(); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! setTokenRange( iVisited.getPosition(), info, name ); // TODO Add more information about the variable infoStack.push(info); *************** *** 407,413 **** info.setTypeName(estimateValueType(iVisited.getValueNode())); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! ISourcePosition pos = iVisited.getPosition(); ! //setTokenRange(pos, info, name); ! setClassVarRange( pos, info, name ); parentInfo.addChild(var); --- 405,409 ---- info.setTypeName(estimateValueType(iVisited.getValueNode())); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! setTokenRange( iVisited.getPosition(), info, name ); parentInfo.addChild(var); *************** *** 536,573 **** return ""; } ! ! private Instruction setLocalVarRange( ISourcePosition pos, MemberElementInfo info, String name ){ ! int start = pos.getStartOffset() - name.length(); ! setMemberElementPosition( ! info, ! start, ! pos.getStartOffset() - 1, ! start, ! pos.getEndOffset() ); ! return null; ! } ! ! private Instruction setInstanceVarRange( ISourcePosition pos, MemberElementInfo info, String name ){ ! int start = pos.getStartOffset() - name.length(); ! setMemberElementPosition( ! info, ! start, ! pos.getStartOffset()- 1, ! start, ! pos.getEndOffset() ); ! return null; ! } ! ! private Instruction setClassVarRange( ISourcePosition pos, MemberElementInfo info, String name ){ ! int start = pos.getStartOffset() - name.length(); ! setMemberElementPosition( ! info, ! start, ! pos.getStartOffset() - 1, ! start, ! pos.getEndOffset() - 1); ! return null; ! } ! /** * @param keyword --- 532,536 ---- return ""; } ! /** * @param keyword *************** *** 576,602 **** * @param name */ ! private Instruction setKeywordRange(String keyword, ISourcePosition pos, MemberElementInfo info, String name) { ! info.setNameSourceStart( pos.getStartOffset() + 1); ! info.setNameSourceEnd(pos.getStartOffset() + name.length() ); ! info.setSourceRangeStart(pos.getStartOffset() + 1 ); ! info.setSourceRangeEnd( pos.getEndOffset() ); ! return null; ! } ! ! /** ! * Sets the position on a given MemberElementInfo object. ! * @param info ! * @param nameSourceStart ! * @param nameSourceEnd ! * @param sourceStart ! * @param sourceEnd ! */ ! private Instruction setMemberElementPosition( MemberElementInfo info, int nameSourceStart, ! int nameSourceEnd, int sourceStart, int sourceEnd ){ ! info.setNameSourceStart( nameSourceStart ); ! info.setNameSourceEnd( nameSourceEnd ); ! info.setSourceRangeStart( sourceStart ); ! info.setSourceRangeEnd( sourceEnd ); ! return null; } --- 539,549 ---- * @param name */ ! private void setKeywordRange(String keyword, ISourcePosition pos, MemberElementInfo info, String name) { ! // TODO Actually check nodes which make up the name for their position! ! int nameStart = pos.getStartOffset() + keyword.length() + 1; // the extra 1 is for a space after the keyword ! info.setNameSourceStart(nameStart); ! info.setNameSourceEnd(nameStart + name.length() - 1 ); ! info.setSourceRangeStart(pos.getStartOffset()); ! info.setSourceRangeEnd(pos.getEndOffset() - 1); } *************** *** 1047,1057 **** * @param info */ ! private Instruction setTokenRange(ISourcePosition pos, RubyFieldElementInfo info, String name) { ! int realStart = pos.getStartOffset() - name.length(); info.setNameSourceStart(realStart); ! info.setNameSourceEnd(pos.getStartOffset() - 1); info.setSourceRangeStart(realStart); ! info.setSourceRangeEnd(pos.getStartOffset() - 10); ! return null; } --- 994,1003 ---- * @param info */ ! private void setTokenRange(ISourcePosition pos, RubyFieldElementInfo info, String name) { ! int realStart = pos.getStartOffset() - name.length() + 1; info.setNameSourceStart(realStart); ! info.setNameSourceEnd(pos.getStartOffset()); info.setSourceRangeStart(realStart); ! info.setSourceRangeEnd(pos.getStartOffset()); } *************** *** 1095,1100 **** // TODO Add more information to the info object! ISourcePosition pos = iVisited.getPosition(); ! //setTokenRange(pos, info, name); ! setInstanceVarRange( pos, info, name ); info.setTypeName(estimateValueType(iVisited.getValueNode())); --- 1041,1045 ---- // TODO Add more information to the info object! ISourcePosition pos = iVisited.getPosition(); ! setTokenRange( pos, info, name ); info.setTypeName(estimateValueType(iVisited.getValueNode())); *************** *** 1190,1194 **** // TODO Set the info! ISourcePosition pos = iVisited.getPosition(); ! setLocalVarRange( pos, info, iVisited.getName() ); infoStack.push(info); --- 1135,1139 ---- // TODO Set the info! ISourcePosition pos = iVisited.getPosition(); ! setTokenRange( pos, info, iVisited.getName() ); infoStack.push(info); |