|
From: Christopher W. <caw...@us...> - 2006-02-10 18:29:30
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3759/src/org/rubypeople/rdt/internal/core Modified Files: RubySingletonMethod.java RubyElementDelta.java RubyType.java RubyModelManager.java RubyScriptStructureBuilder.java RubyScriptProblemFinder.java RubyElement.java RubyLocalVar.java RubyElementDeltaBuilder.java RubyProject.java RubyMethod.java Log Message: add hashCode methods - I kept running into wacky problems where RubyElementDelats were interpreted wrongly (because we had defined equals() but not hashCode() and the items compared where in HashMaps) Index: RubyMethod.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RubyMethod.java 12 Mar 2005 15:30:04 -0000 1.3 --- RubyMethod.java 10 Feb 2006 18:29:16 -0000 1.4 *************** *** 25,32 **** package org.rubypeople.rdt.internal.core; - import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IMethod; import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; /** --- 25,33 ---- package org.rubypeople.rdt.internal.core; import org.rubypeople.rdt.core.IMethod; + import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; + import org.rubypeople.rdt.internal.core.util.Util; /** *************** *** 36,44 **** public class RubyMethod extends NamedMember implements IMethod { ! /** * @param name */ ! public RubyMethod(RubyElement parent, String name) { super(parent, name); } --- 37,48 ---- public class RubyMethod extends NamedMember implements IMethod { ! private String[] parameterNames; ! ! /** * @param name */ ! public RubyMethod(RubyElement parent, String name, String[] parameterNames) { super(parent, name); + this.parameterNames = parameterNames; } *************** *** 58,62 **** // FIXME We need to send more info than the method name. Number of // params? ! return ((IType) primaryParent).getMethod(this.name); } --- 62,66 ---- // FIXME We need to send more info than the method name. Number of // params? ! return ((IType) primaryParent).getMethod(this.name, parameterNames); } *************** *** 69,72 **** --- 73,87 ---- return super.equals(o); } + + /** + * @see org.rubypeople.rdt.internal.core.RubyElement#hashCode() + */ + public int hashCode() { + int hash = super.hashCode(); + for (int i = 0, length = parameterNames.length; i < length; i++) { + hash = Util.combineHashCodes(hash, parameterNames[i].hashCode()); + } + return hash; + } /* *************** *** 76,80 **** */ public IType getDeclaringType() { ! // TODO Auto-generated method stub return null; } --- 91,96 ---- */ public IType getDeclaringType() { ! IRubyElement parent = getParent(); ! if (parent instanceof IType) return (IType) parent; return null; } *************** *** 90,92 **** --- 106,116 ---- } + public String[] getParameterNames() throws RubyModelException { + return parameterNames; + } + + public boolean isSingleton() { + return false; + } + } \ No newline at end of file Index: RubyProject.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RubyProject.java 13 Dec 2005 19:58:55 -0000 1.17 --- RubyProject.java 10 Feb 2006 18:29:16 -0000 1.18 *************** *** 188,191 **** --- 188,195 ---- return this.project.equals(other.getProject()); } + + public int hashCode() { + return this.project.hashCode(); + } public boolean exists() { Index: RubyScriptStructureBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** RubyScriptStructureBuilder.java 7 Feb 2006 15:57:52 -0000 1.16 --- RubyScriptStructureBuilder.java 10 Feb 2006 18:29:16 -0000 1.17 *************** *** 181,185 **** if( name.equals("initialize") ) visibility = Visibility.PROTECTED; ! RubyMethod method = new RubyMethod( getCurrentType(), name ); modelStack.push( method ); --- 181,187 ---- if( name.equals("initialize") ) visibility = Visibility.PROTECTED; ! // TODO Find the existing method and steal it's parameter names ! String[] parameterNames = new String[0]; ! RubyMethod method = new RubyMethod( getCurrentType(), name, parameterNames ); modelStack.push( method ); *************** *** 695,699 **** RubyElement type = getCurrentType(); ! RubyMethod method = new RubyMethod(type, name); modelStack.push(method); --- 697,702 ---- RubyElement type = getCurrentType(); ! String[] parameterNames = getArgs(iVisited.getArgsNode()); ! RubyMethod method = new RubyMethod(type, name, parameterNames); modelStack.push(method); *************** *** 702,706 **** RubyMethodElementInfo info = new RubyMethodElementInfo(); ! info.setArgumentNames(getArgs(iVisited.getArgsNode())); // TODO Set more information info.setVisibility(convertVisibility(visibility)); --- 705,709 ---- RubyMethodElementInfo info = new RubyMethodElementInfo(); ! info.setArgumentNames(parameterNames); // TODO Set more information info.setVisibility(convertVisibility(visibility)); *************** *** 792,798 **** Visibility visibility = currentVisibility; // Get the type of the current parent element RubyElement type = getCurrentType(); ! RubyMethod method = new RubySingletonMethod(type, name); modelStack.push(method); --- 795,803 ---- Visibility visibility = currentVisibility; + String[] parameterNames = getArgs(iVisited.getArgsNode()); + // Get the type of the current parent element RubyElement type = getCurrentType(); ! RubyMethod method = new RubySingletonMethod(type, name, parameterNames); modelStack.push(method); *************** *** 807,811 **** setKeywordRange("def", pos, info, name); ! info.setArgumentNames(getArgs(iVisited.getArgsNode())); info.setVisibility(convertVisibility(visibility)); --- 812,816 ---- setKeywordRange("def", pos, info, name); ! info.setArgumentNames(parameterNames); info.setVisibility(convertVisibility(visibility)); *************** *** 1124,1128 **** public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) { handleNode(iVisited); ! RubyLocalVar var = new RubyLocalVar(modelStack.peek(), iVisited.getName()); modelStack.push(var); --- 1129,1136 ---- public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) { handleNode(iVisited); ! ! int start = iVisited.getPosition().getStartOffset() - iVisited.getName().length() + 1; ! int end = start + iVisited.getName().length(); ! RubyLocalVar var = new RubyLocalVar(modelStack.peek(), iVisited.getName(), start, end); modelStack.push(var); *************** *** 1132,1139 **** RubyFieldElementInfo info = new RubyFieldElementInfo(); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! ! // TODO Set the info! ISourcePosition pos = iVisited.getPosition(); ! setTokenRange( pos, info, iVisited.getName() ); infoStack.push(info); --- 1140,1146 ---- RubyFieldElementInfo info = new RubyFieldElementInfo(); info.setTypeName(estimateValueType(iVisited.getValueNode())); ! ISourcePosition pos = iVisited.getPosition(); ! setTokenRange( pos, info, iVisited.getName() ); infoStack.push(info); Index: RubyModelManager.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RubyModelManager.java 14 Dec 2005 03:03:29 -0000 1.6 --- RubyModelManager.java 10 Feb 2006 18:29:16 -0000 1.7 *************** *** 20,25 **** --- 20,29 ---- import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Preferences; + import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; + import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener; + import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IPreferencesService; + import org.eclipse.core.runtime.preferences.InstanceScope; import org.rubypeople.rdt.core.ILoadpathEntry; import org.rubypeople.rdt.core.IParent; *************** *** 39,43 **** * */ ! public class RubyModelManager { private static final String BUFFER_MANAGER_DEBUG = RubyCore.PLUGIN_ID + "/debug/buffermanager"; //$NON-NLS-1$ --- 43,47 ---- * */ ! public class RubyModelManager implements IContentTypeChangeListener { private static final String BUFFER_MANAGER_DEBUG = RubyCore.PLUGIN_ID + "/debug/buffermanager"; //$NON-NLS-1$ *************** *** 115,118 **** --- 119,134 ---- /** + * Update the classpath variable cache + */ + public static class EclipsePreferencesListener implements IEclipsePreferences.IPreferenceChangeListener { + /** + * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) + */ + public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { + // TODO Listen for loadpath changes! + } + } + + /** * Constructs a new RubyModelManager */ *************** *** 127,130 **** --- 143,185 ---- return MANAGER; } + + /** + * Initialize preferences lookups for JavaCore plugin. + */ + public void initializePreferences() { + + // Create lookups + preferencesLookup[PREF_INSTANCE] = new InstanceScope().getNode(RubyCore.PLUGIN_ID); + preferencesLookup[PREF_DEFAULT] = new DefaultScope().getNode(RubyCore.PLUGIN_ID); + + // Listen to instance preferences node removal from parent in order to refresh stored one + IEclipsePreferences.INodeChangeListener listener = new IEclipsePreferences.INodeChangeListener() { + public void added(IEclipsePreferences.NodeChangeEvent event) { + // do nothing + } + public void removed(IEclipsePreferences.NodeChangeEvent event) { + if (event.getChild() == preferencesLookup[PREF_INSTANCE]) { + preferencesLookup[PREF_INSTANCE] = new InstanceScope().getNode(RubyCore.PLUGIN_ID); + preferencesLookup[PREF_INSTANCE].addPreferenceChangeListener(new EclipsePreferencesListener()); + } + } + }; + ((IEclipsePreferences) preferencesLookup[PREF_INSTANCE].parent()).addNodeChangeListener(listener); + preferencesLookup[PREF_INSTANCE].addPreferenceChangeListener(new EclipsePreferencesListener()); + + // Listen to default preferences node removal from parent in order to refresh stored one + listener = new IEclipsePreferences.INodeChangeListener() { + public void added(IEclipsePreferences.NodeChangeEvent event) { + // do nothing + } + public void removed(IEclipsePreferences.NodeChangeEvent event) { + if (event.getChild() == preferencesLookup[PREF_DEFAULT]) { + preferencesLookup[PREF_DEFAULT] = new DefaultScope().getNode(RubyCore.PLUGIN_ID); + } + } + }; + ((IEclipsePreferences) preferencesLookup[PREF_DEFAULT].parent()).addNodeChangeListener(listener); + } + /** *************** *** 581,584 **** --- 636,642 ---- // request state folder creation (workaround 19885) RubyCore.getPlugin().getStateLocation(); + + // Initialize eclipse preferences + initializePreferences(); // Listen to preference changes *************** *** 591,594 **** --- 649,655 ---- RubyCore.getPlugin().getPluginPreferences().addPropertyChangeListener(propertyListener); + // Listen to content-type changes + Platform.getContentTypeManager().addContentTypeChangeListener(this); + final IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(this.deltaState, *************** *** 660,662 **** --- 721,728 ---- } + public void contentTypeChanged(ContentTypeChangeEvent event) { + // TODO Change our classes which determine if a file is "Ruby-like" + //Util.resetRubyLikeExtensions(); + } + } Index: RubySingletonMethod.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubySingletonMethod.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubySingletonMethod.java 12 Jul 2005 00:03:06 -0000 1.1 --- RubySingletonMethod.java 10 Feb 2006 18:29:16 -0000 1.2 *************** *** 31,47 **** * @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; ! } } --- 31,43 ---- * @param parent * @param name + * @param parameterNames */ ! public RubySingletonMethod(RubyElement parent, String name, String[] parameterNames) { ! super(parent, name, parameterNames); } ! public boolean isSingleton() { ! return true; ! } } Index: RubyType.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RubyType.java 12 Mar 2005 15:30:03 -0000 1.4 --- RubyType.java 10 Feb 2006 18:29:16 -0000 1.5 *************** *** 60,63 **** --- 60,70 ---- return info.getIncludedModuleNames(); } + + /** + * @see IType#isMember() + */ + public boolean isMember() { + return getDeclaringType() != null; + } /* *************** *** 87,92 **** } ! public RubyMethod getMethod(String name) { ! return new RubyMethod(this, name); } --- 94,99 ---- } ! public RubyMethod getMethod(String name, String[] parameterNames) { ! return new RubyMethod(this, name, parameterNames); } *************** *** 135,139 **** case IRubyElement.CLASS_VAR: case IRubyElement.BLOCK: ! case IRubyElement.LOCAL_VAR: case IRubyElement.METHOD: return ((IMember) primaryParent).getType(this.name, this.occurrenceCount); --- 142,146 ---- case IRubyElement.CLASS_VAR: case IRubyElement.BLOCK: ! case IRubyElement.LOCAL_VARIABLE: case IRubyElement.METHOD: return ((IMember) primaryParent).getType(this.name, this.occurrenceCount); Index: RubyElement.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElement.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RubyElement.java 13 Dec 2005 19:58:55 -0000 1.5 --- RubyElement.java 10 Feb 2006 18:29:16 -0000 1.6 *************** *** 43,46 **** --- 43,47 ---- import org.rubypeople.rdt.core.ISourceReference; import org.rubypeople.rdt.core.RubyModelException; + import org.rubypeople.rdt.internal.core.util.Util; /** *************** *** 64,68 **** /** ! * Returns true if this handle represents the same Java element as the given * handle. By default, two handles represent the same element if they are * identical or if they represent the same type of element, have equal --- 65,69 ---- /** ! * Returns true if this handle represents the same Ruby element as the given * handle. By default, two handles represent the same element if they are * identical or if they represent the same type of element, have equal *************** *** 237,240 **** --- 238,252 ---- } + /** + * Returns the hash code for this Ruby element. By default, + * the hash code for an element is a combination of its name + * and parent's hash code. Elements with other requirements must + * override this method. + */ + public int hashCode() { + if (this.parent == null) return super.hashCode(); + return Util.combineHashCodes(getElementName().hashCode(), this.parent.hashCode()); + } + /* * (non-Javadoc) *************** *** 399,404 **** /** * Returns the info for this handle. If this element is not already open, it ! * and all of its parents are opened. Does not return null. NOTE: BinaryType ! * infos are NOT rooted under RubyElementInfo. * * @exception RubyModelException --- 411,415 ---- /** * Returns the info for this handle. If this element is not already open, it ! * and all of its parents are opened. Does not return null. * * @exception RubyModelException Index: RubyLocalVar.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyLocalVar.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RubyLocalVar.java 10 Mar 2005 04:10:31 -0000 1.3 --- RubyLocalVar.java 10 Feb 2006 18:29:16 -0000 1.4 *************** *** 29,32 **** --- 29,33 ---- import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; + import org.rubypeople.rdt.internal.core.util.Util; /** *************** *** 36,43 **** public class RubyLocalVar extends RubyField { /** * @param name */ ! public RubyLocalVar(RubyElement parent, String name) { super(parent, name); } --- 37,47 ---- public class RubyLocalVar extends RubyField { + private int start; + private int end; + /** * @param name */ ! public RubyLocalVar(RubyElement parent, String name, int start, int end) { super(parent, name); } *************** *** 49,53 **** */ public int getElementType() { ! return RubyElement.LOCAL_VAR; } --- 53,57 ---- */ public int getElementType() { ! return RubyElement.LOCAL_VARIABLE; } *************** *** 60,63 **** --- 64,80 ---- return null; } + + public int hashCode() { + return Util.combineHashCodes(this.parent.hashCode(), this.start); + } + + public boolean equals(Object o) { + if (!(o instanceof RubyLocalVar)) return false; + RubyLocalVar other = (RubyLocalVar)o; + return + this.start == other.start + && this.end == other.end + && super.equals(o); + } protected void generateInfos(Object info, HashMap newElements, IProgressMonitor pm) { Index: RubyElementDeltaBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RubyElementDeltaBuilder.java 24 Dec 2005 01:43:57 -0000 1.2 --- RubyElementDeltaBuilder.java 10 Feb 2006 18:29:16 -0000 1.3 *************** *** 34,43 **** /** ! * The java element handle */ ! IRubyElement javaElement; /** ! * The maximum depth in the java element children we should look into */ int maxDepth = Integer.MAX_VALUE; --- 34,43 ---- /** ! * The ruby element handle */ ! IRubyElement rubyElement; /** ! * The maximum depth in the ruby element children we should look into */ int maxDepth = Integer.MAX_VALUE; *************** *** 88,109 **** /** ! * Creates a java element comparator on a java element looking as deep as * necessary. */ ! public RubyElementDeltaBuilder(IRubyElement javaElement) { ! this.javaElement = javaElement; this.initialize(); ! this.recordElementInfo(javaElement, (RubyModel) this.javaElement.getRubyModel(), 0); } /** ! * Creates a java element comparator on a java element looking only * 'maxDepth' levels deep. */ ! public RubyElementDeltaBuilder(IRubyElement javaElement, int maxDepth) { ! this.javaElement = javaElement; this.maxDepth = maxDepth; this.initialize(); ! this.recordElementInfo(javaElement, (RubyModel) this.javaElement.getRubyModel(), 0); } --- 88,109 ---- /** ! * Creates a ruby element comparator on a ruby element looking as deep as * necessary. */ ! public RubyElementDeltaBuilder(IRubyElement rubyElement) { ! this.rubyElement = rubyElement; this.initialize(); ! this.recordElementInfo(rubyElement, (RubyModel) this.rubyElement.getRubyModel(), 0); } /** ! * Creates a ruby element comparator on a ruby element looking only * 'maxDepth' levels deep. */ ! public RubyElementDeltaBuilder(IRubyElement rubyElement, int maxDepth) { ! this.rubyElement = rubyElement; this.maxDepth = maxDepth; this.initialize(); ! this.recordElementInfo(rubyElement, (RubyModel) this.rubyElement.getRubyModel(), 0); } *************** *** 122,133 **** /** ! * Builds the java element deltas between the old content of the compilation ! * unit and its new content. */ public void buildDeltas() { ! this.recordNewPositions(this.javaElement, 0); ! this.findAdditions(this.javaElement, 0); this.findDeletions(); ! this.findChangesInPositioning(this.javaElement, 0); this.trimDelta(this.delta); if (this.delta.getAffectedChildren().length == 0) { --- 122,133 ---- /** ! * Builds the ruby element deltas between the old content of the ruby script ! * and its new content. */ public void buildDeltas() { ! this.recordNewPositions(this.rubyElement, 0); ! this.findAdditions(this.rubyElement, 0); this.findDeletions(); ! this.findChangesInPositioning(this.rubyElement, 0); this.trimDelta(this.delta); if (this.delta.getAffectedChildren().length == 0) { *************** *** 271,281 **** this.oldPositions = new HashMap(20); this.newPositions = new HashMap(20); ! this.putOldPosition(this.javaElement, new ListItem(null, null)); ! this.putNewPosition(this.javaElement, new ListItem(null, null)); ! this.delta = new RubyElementDelta(javaElement); ! // if building a delta on a compilation unit or below, // it's a fine grained delta ! if (javaElement.getElementType() >= IRubyElement.SCRIPT) { this.delta.fineGrained(); } --- 271,281 ---- this.oldPositions = new HashMap(20); this.newPositions = new HashMap(20); ! this.putOldPosition(this.rubyElement, new ListItem(null, null)); ! this.putNewPosition(this.rubyElement, new ListItem(null, null)); ! this.delta = new RubyElementDelta(rubyElement); ! // if building a delta on a ruby script or below, // it's a fine grained delta ! if (rubyElement.getElementType() >= IRubyElement.SCRIPT) { this.delta.fineGrained(); } *************** *** 343,347 **** RubyElementInfo info = (RubyElementInfo) RubyModelManager.getRubyModelManager().getInfo( element); ! if (info == null) // no longer in the java model. return; this.putElementInfo(element, info); --- 343,347 ---- RubyElementInfo info = (RubyElementInfo) RubyModelManager.getRubyModelManager().getInfo( element); ! if (info == null) // no longer in the ruby model. return; this.putElementInfo(element, info); Index: RubyScriptProblemFinder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RubyScriptProblemFinder.java 1 Oct 2005 23:01:01 -0000 1.6 --- RubyScriptProblemFinder.java 10 Feb 2006 18:29:16 -0000 1.7 *************** *** 11,18 **** import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IProgressMonitor; - import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.jruby.lexer.yacc.SyntaxException; import org.rubypeople.rdt.core.IProblemRequestor; - import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.core.parser.IProblem; import org.rubypeople.rdt.internal.core.parser.Error; --- 11,16 ---- *************** *** 28,53 **** // DSC convert to ImmediateWarnings ! public static void process(RubyScript script, char[] charContents, IProblemRequestor problemRequestor, IProgressMonitor pm) { ! RdtWarnings warnings = new RdtWarnings(); ! RubyParser parser = new RubyParser(warnings); ! String contents = new String(charContents); ! try { ! parser.parse((IFile) script.getUnderlyingResource(), new StringReader(contents)); ! } catch (SyntaxException e) { ! problemRequestor.acceptProblem(new Error(e.getPosition(), "Syntax Error")); ! } ! IEclipsePreferences preferences = RubyCore.getInstancePreferences(); ! TaskParser taskParser = new TaskParser(preferences); ! taskParser.parse(contents); ! List problems = new ArrayList(); ! problems.addAll(warnings.getWarnings()); ! problems.addAll(taskParser.getTasks()); ! for (Iterator iter = problems.iterator(); iter.hasNext();) { ! IProblem problem = (IProblem) iter.next(); ! problemRequestor.acceptProblem(problem); ! } ! } } --- 26,51 ---- // DSC convert to ImmediateWarnings ! public static void process(RubyScript script, char[] charContents, ! IProblemRequestor problemRequestor, IProgressMonitor pm) { ! RdtWarnings warnings = new RdtWarnings(); ! RubyParser parser = new RubyParser(warnings); ! String contents = new String(charContents); ! try { ! parser.parse((IFile) script.getUnderlyingResource(), new StringReader(contents)); ! } catch (SyntaxException e) { ! problemRequestor.acceptProblem(new Error(e.getPosition(), "Syntax Error")); ! } ! TaskParser taskParser = new TaskParser(script.getRubyProject().getOptions(true)); ! taskParser.parse(contents); ! List problems = new ArrayList(); ! problems.addAll(warnings.getWarnings()); ! problems.addAll(taskParser.getTasks()); ! for (Iterator iter = problems.iterator(); iter.hasNext();) { ! IProblem problem = (IProblem) iter.next(); ! problemRequestor.acceptProblem(problem); ! } ! } } Index: RubyElementDelta.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDelta.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyElementDelta.java 13 Dec 2005 19:58:55 -0000 1.1 --- RubyElementDelta.java 10 Feb 2006 18:29:16 -0000 1.2 *************** *** 30,34 **** * The AST created during the last reconcile operation. Non-null only iff: - * in a POST_RECONCILE event - an AST was requested during the last ! * reconcile operation - the changed element is an ICompilationUnit in * working copy mode */ --- 30,34 ---- * The AST created during the last reconcile operation. Non-null only iff: - * in a POST_RECONCILE event - an AST was requested during the last ! * reconcile operation - the changed element is an IRubyScript in * working copy mode */ |