Skip to content

Commit

Permalink
Fix execution on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthagen committed Jan 19, 2016
1 parent 8ad1a37 commit 37eb6c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
5 changes: 2 additions & 3 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>com.github.johnthagen.cppcheck</id>
<name>cppcheck</name>
<version>1.0.1</version>
<version>1.0.2</version>
<vendor email="johnthagen@gmail.com" url="http://github.com/johnthagen">johnthagen</vendor>

<description><![CDATA[
Expand All @@ -19,8 +19,7 @@
]]></description>

<change-notes><![CDATA[
1.0.1 Fix possible out of bounds line number when cppcheck
gets out of sync with in memory file.<br>
1.0.2 Fix plugin execution on Linux.<br>
]]>
</change-notes>

Expand Down
45 changes: 32 additions & 13 deletions src/com/github/johnthagen/cppcheck/CppcheckInspection.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,21 @@ public ProblemDescriptor[] checkFile(@NotNull PsiFile file,
true);
descriptors.add(problemDescriptor);
}
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ex) {
Notifications.Bus.notify(new Notification("cppcheck",
"Error",
"IOException: " + ex.getMessage(),
NotificationType.INFORMATION));
ex.printStackTrace();
}

return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}

private static String executeCommandOnFile(String command,
String options,
@NotNull PsiFile file) throws IOException {
final String executionString = "\"" + command + "\" "+
private static String executeCommandOnFile(final String command,
final String options,
@NotNull final PsiFile file) throws IOException {
final String executionString = command + " " +
options + " " +
"\"" + file.getVirtualFile().getCanonicalPath() + "\"";

Expand All @@ -131,13 +135,24 @@ public void run() {
while ((line = errStream.readLine()) != null) {
errString.append(line).append("\n");
}
} catch (IOException ex) {
}
catch (IOException ex) {
Notifications.Bus.notify(new Notification("cppcheck",
"Error",
"IOException: " + ex.getMessage(),
NotificationType.INFORMATION));
ex.printStackTrace();
} finally {
}
finally {
try {
errStream.close();
} catch (IOException e) {
e.printStackTrace();
}
catch (IOException ex) {
Notifications.Bus.notify(new Notification("cppcheck",
"Error",
"IOException: " + ex.getMessage(),
NotificationType.INFORMATION));
ex.printStackTrace();
}
}
}
Expand All @@ -146,14 +161,18 @@ public void run() {

try {
errorThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
Notifications.Bus.notify(new Notification("cppcheck",
"Error",
"IOException: " + ex.getMessage(),
NotificationType.INFORMATION));
ex.printStackTrace();
}

return errString.toString();
}

private static boolean isCFamilyFile(@NotNull PsiFile file){
private static boolean isCFamilyFile(@NotNull final PsiFile file){
final String lowerFileExtension = file.getVirtualFile().getExtension().toLowerCase();
if (lowerFileExtension.equals("c") ||
lowerFileExtension.equals("cc") ||
Expand Down

0 comments on commit 37eb6c1

Please sign in to comment.