|
From: <caw...@us...> - 2007-01-21 20:19:45
|
Revision: 1837
http://svn.sourceforge.net/rubyeclipse/?rev=1837&view=rev
Author: cawilliams
Date: 2007-01-21 12:19:41 -0800 (Sun, 21 Jan 2007)
Log Message:
-----------
Fix what I borke earlier. Now our Rdoc/RI stuff should work again. There's no need to hook it to a VM/Interpreter to execute these things (though we may want to try and detect the location of the executables by getting the selected VM install and then building the path to bin/rdoc and bin/ri).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-01-21 18:37:43 UTC (rev 1836)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-01-21 20:19:41 UTC (rev 1837)
@@ -10,7 +10,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
@@ -46,7 +45,6 @@
import org.rubypeople.rdt.internal.ui.rdocexport.RdocListener;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.IVMInstallChangedListener;
-import org.rubypeople.rdt.launching.IVMRunner;
import org.rubypeople.rdt.launching.PropertyChangeEvent;
import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.ui.PreferenceConstants;
@@ -360,13 +358,10 @@
}
private abstract class RubyInvoker {
- protected abstract List getArgList();
+ protected abstract List<String> getArgList();
protected abstract void handleOutput(Process process);
protected void beforeInvoke(){}
-
-
-
public final void invoke() {
IPath riPath = new Path( RubyPlugin.getDefault().getPreferenceStore().getString( PreferenceConstants.RI_PATH ) );
@@ -382,17 +377,16 @@
return;
}
-// try {
- List args = getArgList();
+ try {
+ List<String> args = getArgList();
args.add(0, riPath.toString());
- IVMRunner runner = RubyRuntime.getDefaultVMInstall().getVMRunner("run");
- // XXX How in the world do we do these quick little background launches and grab the process?
- final Process p = null;
+ String[] argArray= (String[]) args.toArray(new String[args.size()]);
+ Process p= Runtime.getRuntime().exec(argArray);
handleOutput(p);
-// } catch (CoreException coreException) {
-// // message of RuntimeException will be displayed in the RI View
-// throw new RuntimeException(coreException.getStatus().getMessage());
-// }
+ } catch (IOException e) {
+ // message of RuntimeException will be displayed in the RI View
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java 2007-01-21 18:37:43 UTC (rev 1836)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java 2007-01-21 20:19:41 UTC (rev 1837)
@@ -2,6 +2,7 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
@@ -11,17 +12,13 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.rubypeople.rdt.internal.launching.LaunchingMessages;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyUIMessages;
import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
-import org.rubypeople.rdt.launching.IVMInstall;
-import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.ui.PreferenceConstants;
/**
@@ -32,8 +29,8 @@
* @author Chris
*/
public class RDocUtility {
-
- private static Set listeners = new HashSet();
+
+ private static Set<RdocListener> listeners = new HashSet<RdocListener>();
private static boolean isDebug = false;
public static void addRdocListener(RdocListener listener) {
@@ -85,12 +82,6 @@
public final void invoke() {
log("Generating RDoc for " + resource.getName());
- IVMInstall interpreter = RubyRuntime.getDefaultVMInstall();
- if (interpreter == null) {
- MessageDialog.openInformation(RubyPlugin.getActiveWorkbenchShell(), LaunchingMessages.RdtLaunchingPlugin_noInterpreterSelectedTitle, LaunchingMessages.RdtLaunchingPlugin_noInterpreterSelected);
- return ;
- }
-
IPath rdocPath = new Path(RubyPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.RDOC_PATH));
// check the rdoc path for existence. It might have been
@@ -103,21 +94,22 @@
MessageDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.getString("RDocPathErrorTitle"), RubyUIMessages.getString("RDocPathError")) ;
return;
}
-
- List args = new ArrayList();
+
+ List<String> args = new ArrayList<String>();
args.add(rdocPath.toString());
args.add("-r");
args.add(resource.getLocation().toOSString());
-// try {
- // XXX How do we do quick background launches of the interpreter?
-// final Process p = interpreter.exec(args, null);
- final Process p = null;
- handleOutput(p, args);
-// } catch (CoreException e) {
-// RubyPlugin.log(e);
-// log(e.getMessage());
-// ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.getString("ErrorRunningRdocTitle"), e.getMessage(), new StatusInfo(StatusInfo.ERROR, e.getMessage()));
-// }
+ String[] argArray= (String[]) args.toArray(new String[args.size()]);
+ try {
+ Process process= Runtime.getRuntime().exec(argArray);
+ if (process != null) {
+ handleOutput(process, args);
+ }
+ } catch (IOException e) {
+ RubyPlugin.log(e);
+ log(e.getMessage());
+ ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.getString("ErrorRunningRdocTitle"), e.getMessage(), new StatusInfo(StatusInfo.ERROR, e.getMessage()));
+ }
}
/**
@@ -128,7 +120,7 @@
* @param p
* The Process.
*/
- private void handleOutput(Process p, List cmdLine) {
+ private void handleOutput(Process p, List<String> cmdLine) {
BufferedReader reader = null;
String lastLine = null;
try {
@@ -166,7 +158,7 @@
*
*/
public static void notifyListeners() {
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
+ for (Iterator<RdocListener> iter = listeners.iterator(); iter.hasNext();) {
RdocListener listener = (RdocListener) iter.next();
listener.rdocChanged();
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-01-21 18:37:43 UTC (rev 1836)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-01-21 20:19:41 UTC (rev 1837)
@@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
@@ -14,8 +13,6 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.ui.IEditorInput;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.launching.IVMInstall;
-import org.rubypeople.rdt.launching.RubyRuntime;
import org.rubypeople.rdt.ui.PreferenceConstants;
import org.rubypeople.rdt.ui.extensions.ITextHoverProvider;
@@ -23,7 +20,7 @@
public class RiDocHoverProvider implements ITextHoverProvider {
public String getHoverInfo(IEditorInput input, ITextViewer textViewer, IRegion hoverRegion){
IPath riPath = new Path( RubyPlugin.getDefault().getPreferenceStore().getString( PreferenceConstants.RI_PATH ) );
- List args = new ArrayList();
+ List<String> args = new ArrayList<String>();
args.add(0, riPath.toString());
// these will get rid of some of the overhead formatting
args.add("-f");
@@ -34,11 +31,8 @@
try {
String symbol = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
args.add(symbol);
- IVMInstall selectedInterpreter = RubyRuntime.getDefault().getDefaultVMInstall();
- if (selectedInterpreter == null) return null;
-// XXX How in the world do we do these quick little background launches and grab the process?
-// Process p = selectedInterpreter.exec(args, null);
- Process p = null;
+ String[] argArray= (String[]) args.toArray(new String[args.size()]);
+ Process p = Runtime.getRuntime().exec(argArray);
if (p == null) return null;
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
// TODO: format the documentation that was fetched from RI
@@ -58,8 +52,6 @@
return "" + buf.toString();
} catch (BadLocationException e) {
RubyPlugin.log(e);
-// } catch (CoreException e) {
-// RubyPlugin.log(e);
} catch (IOException e) {
RubyPlugin.log(e);
} finally {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|