Permalink
Browse files

- Solved bug where NBPreferences were not being persisted.

  • Loading branch information...
1 parent 92fedd1 commit 33e3c8dfba563a4556378e03bd723ae98f0ead8e @willybarro willybarro committed Oct 10, 2011
@@ -5,7 +5,6 @@
package de.whitewashing.php.cs;
import de.whitewashing.php.cs.command.CodeSnifferBuilder;
-import de.whitewashing.php.cs.command.CodeSniffer;
import javax.swing.JMenuItem;
import org.openide.cookies.EditorCookie;
import org.openide.nodes.Node;
@@ -17,15 +16,13 @@
public final class CodeSnifferAction extends CookieAction {
- private CodeSniffer codeSniffer = CodeSnifferBuilder.createOrReturn();
-
protected void performAction(Node[] activatedNodes) {
if(activatedNodes.length != 1) {
return;
}
FileObject fo = getFileObject(activatedNodes[0]);
- this.codeSniffer.execute(fo, true);
+ CodeSnifferBuilder.createOrReturn().execute(fo, true);
}
/**
@@ -95,7 +92,7 @@ protected boolean asynchronous() {
protected JMenuItem setEnabledForExistingBinary(JMenuItem item)
{
- item.setEnabled(this.codeSniffer.isEnabled());
+ item.setEnabled(CodeSnifferBuilder.createOrReturn().isEnabled());
return item;
}
}
@@ -19,6 +19,7 @@
import org.netbeans.api.extexecution.ExternalProcessBuilder;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
+import org.openide.cookies.EditorCookie;
import org.openide.cookies.LineCookie;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -173,11 +174,11 @@ private void annotateWithCodingStandardHints(FileObject fo, CodeSnifferXmlLogRes
CodeSnifferFileListener l = new CodeSnifferFileListener();
l.setLogResult(rs);
fo.addFileChangeListener(l);
-
+
try {
DataObject d = DataObject.find(fo);
LineCookie cookie = d.getCookie(LineCookie.class);
-
+
Line.Set lineSet = null;
Line line = null;
for (int i = 0; i < rs.getCsErrors().size(); i++) {
@@ -261,14 +262,14 @@ public void handlePhpExceptions(Reader reader)
if(ln.indexOf("Fatal error:") >= 0 || ln.indexOf("Parse error:") >= 0) {
if(ln.indexOf("Fatal error:") >= 0) {
Matcher m = Pattern.compile(
- "Fatal error:\\s+ (.*?:[0-9]+)",
+ "Fatal error:\\s+(.*(?:line\\s+|:)[0-9]+)",
Pattern.CASE_INSENSITIVE
).matcher(ln);
if(m.find())
message = m.group(1);
} else if(ln.indexOf("Parse error:") >= 0) {
Matcher m = Pattern.compile(
- "Parse error:\\s+(.*line [0-9]+)",
+ "Parse error:\\s+(.*(?:line\\s+|:)[0-9]+)",
Pattern.CASE_INSENSITIVE
).matcher(ln);
if(m.find())
@@ -6,7 +6,6 @@
package de.whitewashing.php.cs.command;
import de.whitewashing.php.cs.ui.options.CodeSnifferOptions;
-import java.util.ArrayList;
/**
* Simple factory/singleton that creates a unique CodeSniffer instance based
@@ -27,7 +26,6 @@ public static CodeSniffer createOrReturn() {
public static CodeSniffer create() {
CodeSnifferOptions options = new CodeSnifferOptions();
-
return (codeSniffer = new CodeSniffer(options.getShellScript(), options.getCodingStandard(), options.hasShowWarnings()));
}
}
@@ -265,7 +265,7 @@ void store(boolean assumeValid) {
options.setShowWarnings(checkBoxShowWarnings.isSelected());
options.setShellScript(codeSnifferTextField.getText());
-
+
// or:
// SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
}

0 comments on commit 33e3c8d

Please sign in to comment.