From: <caw...@us...> - 2007-09-20 22:45:24
|
Revision: 3216 http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3216&view=rev Author: cawilliams Date: 2007-09-20 15:45:23 -0700 (Thu, 20 Sep 2007) Log Message: ----------- port fixes from Aptana SVN repo over to old RDT repo Modified Paths: -------------- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java =================================================================== --- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java 2007-09-20 22:45:17 UTC (rev 3215) +++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java 2007-09-20 22:45:23 UTC (rev 3216) @@ -540,4 +540,69 @@ } } } + + public void addPreResourceChangedListener(IResourceChangeListener listener, + int eventMask) { + for (int i = 0; i < this.preResourceChangeListenerCount; i++) { + if (this.preResourceChangeListeners[i].equals(listener)) { + this.preResourceChangeEventMasks[i] |= eventMask; + return; + } + } + // may need to grow, no need to clone, since iterators will have cached + // original arrays and max boundary and we only add to the end. + int length; + if ((length = this.preResourceChangeListeners.length) == this.preResourceChangeListenerCount) { + System + .arraycopy( + this.preResourceChangeListeners, + 0, + this.preResourceChangeListeners = new IResourceChangeListener[length * 2], + 0, length); + System.arraycopy(this.preResourceChangeEventMasks, 0, + this.preResourceChangeEventMasks = new int[length * 2], 0, + length); + } + this.preResourceChangeListeners[this.preResourceChangeListenerCount] = listener; + this.preResourceChangeEventMasks[this.preResourceChangeListenerCount] = eventMask; + this.preResourceChangeListenerCount++; + } + + public void removePreResourceChangedListener( + IResourceChangeListener listener) { + + for (int i = 0; i < this.preResourceChangeListenerCount; i++) { + + if (this.preResourceChangeListeners[i].equals(listener)) { + + // need to clone defensively since we might be in the middle of + // listener notifications (#fire) + int length = this.preResourceChangeListeners.length; + IResourceChangeListener[] newListeners = new IResourceChangeListener[length]; + int[] newEventMasks = new int[length]; + System.arraycopy(this.preResourceChangeListeners, 0, + newListeners, 0, i); + System.arraycopy(this.preResourceChangeEventMasks, 0, + newEventMasks, 0, i); + + // copy trailing listeners + int trailingLength = this.preResourceChangeListenerCount - i + - 1; + if (trailingLength > 0) { + System.arraycopy(this.preResourceChangeListeners, i + 1, + newListeners, i, trailingLength); + System.arraycopy(this.preResourceChangeEventMasks, i + 1, + newEventMasks, i, trailingLength); + } + + // update manager listener state (#fire need to iterate over + // original listeners through a local variable to hold onto + // the original ones) + this.preResourceChangeListeners = newListeners; + this.preResourceChangeEventMasks = newEventMasks; + this.preResourceChangeListenerCount--; + return; + } + } + } } Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java =================================================================== --- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-09-20 22:45:17 UTC (rev 3215) +++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-09-20 22:45:23 UTC (rev 3216) @@ -37,6 +37,7 @@ import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.internal.core.builder.RubyBuilder; +import org.rubypeople.rdt.internal.core.hierarchy.TypeHierarchy; import org.rubypeople.rdt.internal.core.search.indexing.IndexManager; import org.rubypeople.rdt.internal.core.util.CharOperation; import org.rubypeople.rdt.internal.core.util.Util; @@ -431,8 +432,7 @@ stopDeltas(); checkProjectsBeingAddedOrRemoved(delta); if (this.refreshedElements != null) { - // TODO Actually update external references too -// createExternalArchiveDelta(null); + createExternalArchiveDelta(null); } IRubyElementDelta translatedDelta = processResourceDelta(delta); if (translatedDelta != null) { @@ -447,7 +447,7 @@ listeners = this.state.elementChangedListeners; listenerCount = this.state.elementChangedListenerCount; } -// notifyTypeHierarchies(listeners, listenerCount); + notifyTypeHierarchies(listeners, listenerCount); fire(null, ElementChangedEvent.POST_CHANGE); } finally { // workaround for bug 15168 circular errors not reported @@ -470,9 +470,8 @@ } // this.processPostChange = false; if(isAffectedBy(delta)) { // avoid populating for SYNC or MARKER deltas - // FIXME Update the loadpath markers updateLoadpathMarkers(delta, updates); -// RubyBuilder.buildStarting(); + RubyBuilder.buildStarting(); } // does not fire any deltas return; @@ -480,6 +479,28 @@ } } + private void notifyTypeHierarchies(IElementChangedListener[] listeners, int listenerCount) { + for (int i= 0; i < listenerCount; i++) { + final IElementChangedListener listener = listeners[i]; + if (!(listener instanceof TypeHierarchy)) continue; + + // wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief + SafeRunner.run(new ISafeRunnable() { + public void handleException(Throwable exception) { + Util.log(exception, "Exception occurred in listener of Ruby element change notification"); //$NON-NLS-1$ + } + public void run() throws Exception { + TypeHierarchy typeHierarchy = (TypeHierarchy)listener; + if (typeHierarchy.hasFineGrainChanges()) { + // case of changes in primary working copies + typeHierarchy.needsRefresh = true; + typeHierarchy.fireChange(); + } + } + }); + } + } + /* * Update the .loadpath format, missing entries and cycle markers for the projects affected by the given delta. */ Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java =================================================================== --- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java 2007-09-20 22:45:17 UTC (rev 3215) +++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java 2007-09-20 22:45:23 UTC (rev 3216) @@ -172,4 +172,12 @@ // assume there were no problems } } + + public static void buildStarting() { + + } + + public static void buildFinished() { + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |