|
From: <caw...@us...> - 2007-06-05 15:44:55
|
Revision: 2580
http://svn.sourceforge.net/rubyeclipse/?rev=2580&view=rev
Author: cawilliams
Date: 2007-06-05 08:44:47 -0700 (Tue, 05 Jun 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-06-05 14:54:47 UTC (rev 2579)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-06-05 15:44:47 UTC (rev 2580)
@@ -52,6 +52,7 @@
org.rubypeople.rdt.core,
org.eclipse.ui.workbench,
org.eclipse.ui.forms,
+ org.eclipse.ui.navigator,
org.rubypeople.rdt.launching,
org.eclipse.search,
org.jruby,
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-06-05 14:54:47 UTC (rev 2579)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-06-05 15:44:47 UTC (rev 2580)
@@ -3,6 +3,7 @@
*/
package org.rubypeople.rdt.internal.corext.util;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
@@ -139,4 +140,35 @@
public static String getTypeQualifiedName(IType type) {
return type.getTypeQualifiedName("::");
}
+
+ /*
+ * http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
+ *
+ * Reconciling happens in a separate thread. This can cause a situation where the
+ * Java element gets disposed after an exists test has been done. So we should not
+ * log not present exceptions when they happen in working copies.
+ */
+ public static boolean isExceptionToBeLogged(CoreException exception) {
+ if (!(exception instanceof RubyModelException))
+ return true;
+ RubyModelException je= (RubyModelException)exception;
+ if (!je.isDoesNotExist())
+ return true;
+ IRubyElement[] elements= je.getRubyModelStatus().getElements();
+ for (int i= 0; i < elements.length; i++) {
+ IRubyElement element= elements[i];
+ // if the element is already a compilation unit don't log
+ // does not exist exceptions. See bug
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=75894
+ // for more details
+ if (element.getElementType() == IRubyElement.SCRIPT)
+ continue;
+ IRubyScript unit= (IRubyScript)element.getAncestor(IRubyElement.SCRIPT);
+ if (unit == null)
+ return true;
+ if (!unit.isWorkingCopy())
+ return true;
+ }
+ return false;
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java 2007-06-05 14:54:47 UTC (rev 2579)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java 2007-06-05 15:44:47 UTC (rev 2580)
@@ -1,14 +1,20 @@
package org.rubypeople.rdt.internal.ui.actions;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
import org.rubypeople.rdt.core.ICodeAssist;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.rubyeditor.EditorUtility;
import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
import org.rubypeople.rdt.ui.IWorkingCopyManager;
@@ -79,4 +85,41 @@
return EMPTY_RESULT;
}
+ /**
+ * Perform a code resolve in a separate thread.
+ * @param primaryOnly if <code>true</code> only primary working copies will be returned
+ * @throws InterruptedException
+ * @throws InvocationTargetException
+ * @since 1.0
+ */
+ public static IRubyElement[] codeResolveForked(RubyEditor editor, boolean primaryOnly) throws InvocationTargetException, InterruptedException {
+ return performForkedCodeResolve(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection());
+ }
+
+ /**
+ * @param primaryOnly if <code>true</code> only primary working copies will be returned
+ * @since 1.0
+ */
+ private static IRubyElement getInput(RubyEditor editor, boolean primaryOnly) {
+ if (editor == null)
+ return null;
+ return EditorUtility.getEditorInputRubyElement(editor, primaryOnly);
+ }
+
+ private static IRubyElement[] performForkedCodeResolve(final IRubyElement input, final ITextSelection selection) throws InvocationTargetException, InterruptedException {
+ final class CodeResolveRunnable implements IRunnableWithProgress {
+ IRubyElement[] result;
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
+ try {
+ result= codeResolve(input, selection);
+ } catch (RubyModelException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ }
+ CodeResolveRunnable runnable= new CodeResolveRunnable();
+ PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
+ return runnable.result;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-06-05 14:54:47 UTC (rev 2579)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-06-05 15:44:47 UTC (rev 2580)
@@ -41,6 +41,7 @@
import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.RubyUI;
public class EditorUtility {
@@ -352,4 +353,25 @@
return Messages.format(RubyEditorMessages.EditorUtility_concatModifierStrings, new String[] {modifierString, newModifierString});
}
+ /**
+ * Returns the given editor's input as Ruby element.
+ *
+ * @param editor the editor
+ * @param primaryOnly if <code>true</code> only primary working copies will be returned
+ * @return the given editor's input as Ruby element or <code>null</code> if none
+ * @since 1.0
+ */
+ public static IRubyElement getEditorInputRubyElement(IEditorPart editor, boolean primaryOnly) {
+ Assert.isNotNull(editor);
+ IEditorInput editorInput= editor.getEditorInput();
+ if (editorInput == null)
+ return null;
+
+ IRubyElement je= RubyUI.getEditorInputRubyElement(editorInput);
+ if (je != null || primaryOnly)
+ return je;
+
+ return RubyPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, false);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|