|
From: Markus B. <mba...@us...> - 2005-09-19 21:46:56
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32150/src/org/rubypeople/rdt/internal/ui/rdocexport Modified Files: RDocUtility.java Log Message: use trace options to call setDebugging() and enable/disable debug messages to stdout. Added error message for exitValue <> 0. Index: RDocUtility.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RDocUtility.java 18 Sep 2005 18:46:10 -0000 1.1 --- RDocUtility.java 19 Sep 2005 21:46:49 -0000 1.2 *************** *** 29,43 **** private static Set listeners = new HashSet(); public static void addRdocListener(RdocListener listener) { listeners.add(listener); } ! public static void removeRdocListener(RdocListener listener) { listeners.remove(listener); } ! public static void generateDocumentation(IResource resource) { - RubyPlugin.log("Generating RDoc for " + resource.getName()); RubyInvoker invoker = new RubyInvoker(resource); invoker.invoke(); --- 29,47 ---- private static Set listeners = new HashSet(); + private static boolean isDebug = false ; public static void addRdocListener(RdocListener listener) { listeners.add(listener); } ! public static void removeRdocListener(RdocListener listener) { listeners.remove(listener); } ! ! public static void setDebugging(boolean isDebug) { ! RDocUtility.isDebug = isDebug ; ! } ! public static void generateDocumentation(IResource resource) { RubyInvoker invoker = new RubyInvoker(resource); invoker.invoke(); *************** *** 72,77 **** --- 76,88 ---- return " -r " + resource.getLocation().toOSString(); } + + private void log(String message) { + if (RDocUtility.isDebug) { + System.out.println(message) ; + } + } public final void invoke() { + log("Generating RDoc for " + resource.getName()); IPath rubyPath = RubyRuntime.getDefault().getSelectedInterpreter() .getInstallLocation(); *************** *** 95,107 **** } ! String riCmd = "\"" + rubyPath + "\" \"" + rdocPath.toString() ! + "\""; String call = riCmd + getArgString(); try { ! final Process p = Runtime.getRuntime().exec(call); ! RubyPlugin.log(call); ! handleOutput(p); } catch (IOException e) { RubyPlugin.log(e); } } --- 106,119 ---- } ! String riCmd = "\"" + rubyPath + "\" \"" + rdocPath.toString() + "\""; String call = riCmd + getArgString(); try { ! log(call); ! final Process p = Runtime.getRuntime().exec(call); ! handleOutput(p, call); } catch (IOException e) { RubyPlugin.log(e); + log(e.getMessage()); + ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), "Error running Rdoc", e.getMessage(), new StatusInfo(StatusInfo.ERROR, e.getMessage())); } } *************** *** 115,136 **** * The Process. */ ! private void handleOutput(Process p) { BufferedReader reader = null; try { ! reader = new BufferedReader(new InputStreamReader(p ! .getErrorStream())); String line = null; while ((line = reader.readLine()) != null) { ! RubyPlugin.log(line); } } catch (Exception e) { ! RubyPlugin.log(e); } try { p.waitFor(); } catch (InterruptedException e) { ! e.printStackTrace(); } ! RubyPlugin.log("Done generating RDoc"); } } --- 127,160 ---- * The Process. */ ! private void handleOutput(Process p, String cmdLine) { BufferedReader reader = null; + String lastLine = null ; try { ! reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); String line = null; while ((line = reader.readLine()) != null) { ! log(line); ! lastLine = line ; } } catch (Exception e) { ! log(e.getMessage()); } try { p.waitFor(); + if (p.exitValue() != 0) { + String message = "Ruby running rdoc exited abnormally. A possble reason is a wrong Rdoc path. Please check the path for rdoc in the preference page."; + String additionalMessage = null ; + if (lastLine != null) { + additionalMessage = "The process was started with: "+ cmdLine + ". The last line of stderr of the ruby process: " + lastLine ; + } + else { + additionalMessage = "The process was started with: "+ cmdLine + ". The process did not write any messages to stderr." ; + } + ErrorDialog.openError( RubyPlugin.getActiveWorkbenchShell(), "Ruby process exited with value " + p.exitValue(), message, new StatusInfo(StatusInfo.ERROR, additionalMessage)); + } } catch (InterruptedException e) { ! log("InterruptedException while waiting for rdoc process to finish." + e.getMessage()) ; } ! log("Done generating RDoc"); } } |