Skip to content

Commit

Permalink
check return code
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMoresmau committed Oct 26, 2012
1 parent a4ce338 commit 773e416
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions docs/releasenotes/net.sf.eclipsefp.haskell_2.3.2.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Fixes:
- synchronize operations do not block other operations - synchronize operations do not block other operations
- Terminating a debugging session when stopped at a breakpoint removes correctly breakpoint marker in code - Terminating a debugging session when stopped at a breakpoint removes correctly breakpoint marker in code
- Terminating a debugging session correctly forbids to resume execution (restart a new session) - Terminating a debugging session correctly forbids to resume execution (restart a new session)
- Do not try to parse hlint output if the process returned in error


Features: Features:
- Specify the cabal stanza you want to use settings from when checking a file in the editor - Specify the cabal stanza you want to use settings from when checking a file in the editor
Expand Down
2 changes: 1 addition & 1 deletion net.sf.eclipsefp.haskell-feature/feature.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ available at http://www.eclipse.org/legal/epl-v10.html.
id="net.sf.eclipsefp.haskell.hlint" id="net.sf.eclipsefp.haskell.hlint"
download-size="0" download-size="0"
install-size="0" install-size="0"
version="2.3.1" version="2.3.2"
unpack="false"/> unpack="false"/>


<plugin <plugin
Expand Down
2 changes: 1 addition & 1 deletion net.sf.eclipsefp.haskell.hlint/META-INF/MANIFEST.MF
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %bundleName Bundle-Name: %bundleName
Bundle-SymbolicName: net.sf.eclipsefp.haskell.hlint;singleton:=true Bundle-SymbolicName: net.sf.eclipsefp.haskell.hlint;singleton:=true
Bundle-Version: 2.3.1 Bundle-Version: 2.3.2
Bundle-Activator: net.sf.eclipsefp.haskell.hlint.HLintPlugin Bundle-Activator: net.sf.eclipsefp.haskell.hlint.HLintPlugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,53 +1,54 @@
/** /**
* (c) 2011, Alejandro Serrano * (c) 2011, Alejandro Serrano
* Released under the terms of the EPL. * Released under the terms of the EPL.
*/ */
package net.sf.eclipsefp.haskell.hlint; package net.sf.eclipsefp.haskell.hlint;


import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;


import net.sf.eclipsefp.haskell.hlint.parser.OutputParser; import net.sf.eclipsefp.haskell.hlint.parser.OutputParser;
import net.sf.eclipsefp.haskell.hlint.util.HLintText; import net.sf.eclipsefp.haskell.hlint.util.HLintText;
import net.sf.eclipsefp.haskell.util.ProcessRunner; import net.sf.eclipsefp.haskell.util.ProcessRunner;


import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;


/** /**
* Class the encapsulates the logic of calling hlint and * Class the encapsulates the logic of calling hlint and
* sending the output to the parser to generate a list * sending the output to the parser to generate a list
* of suggestions. * of suggestions.
* *
* @author Alejandro Serrano * @author Alejandro Serrano
* @author JP Moresmau * @author JP Moresmau
* *
*/ */
public class HLintRunner { public class HLintRunner {


public List<Suggestion> run(IPath path) { public List<Suggestion> run(IPath path) {
StringWriter err=new StringWriter(); StringWriter err=new StringWriter();
StringWriter out=new StringWriter(); StringWriter out=new StringWriter();
try { try {
String exe=HLintPlugin.getHlintPath(); String exe=HLintPlugin.getHlintPath();
if (exe==null || exe.length()==0){ if (exe==null || exe.length()==0){
exe="hlint"; // hope it's in the path exe="hlint"; // hope it's in the path
} }
new ProcessRunner().executeBlocking(path.toFile().getParentFile(), out, err, exe, path.toOSString()); int code=new ProcessRunner().executeBlocking(path.toFile().getParentFile(), out, err, exe, path.toOSString());

if (code==0){
OutputParser parser = new OutputParser(new StringReader(out.toString())); OutputParser parser = new OutputParser(new StringReader(out.toString()));
return parser.suggestions(); return parser.suggestions();
} catch (Throwable ex) { }
String msg=err.toString().length()>0?err.toString():out.toString(); } catch (Throwable ex) {
HLintPlugin.logError(NLS.bind(HLintText.error_run,msg), ex); String msg=err.toString().length()>0?err.toString():out.toString();
} HLintPlugin.logError(NLS.bind(HLintText.error_run,msg), ex);
return new ArrayList<Suggestion>(); }
} return new ArrayList<Suggestion>();

}
public static List<Suggestion> runHLintOn(IPath path) {
HLintRunner runner = new HLintRunner(); public static List<Suggestion> runHLintOn(IPath path) {
return runner.run(path); HLintRunner runner = new HLintRunner();
} return runner.run(path);
} }
}

0 comments on commit 773e416

Please sign in to comment.