Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some Bugfixes and additions

  • Loading branch information...
commit 9bfa5ccde193ca760885b3e71c74da8cf066eed5 1 parent 3ab88c4
@willybarro willybarro authored
View
2  .gitignore
@@ -1,2 +1,2 @@
build
-nbproject
+nbproject/
View
16 build.xml
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
-<!-- for some information on what you could do (e.g. targets to override). -->
-<!-- If you delete this file and reopen the project it will be recreated. -->
-<project name="de.whitewashing.php.cs" default="netbeans" basedir=".">
- <description>Builds, tests, and runs the project de.whitewashing.php.cs.</description>
- <import file="nbproject/build-impl.xml"/>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="de.whitewashing.php.cs" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project de.whitewashing.php.cs.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
View
10 manifest.mf
@@ -1,5 +1,5 @@
-Manifest-Version: 1.0
-OpenIDE-Module: de.whitewashing.php.cs/0
-OpenIDE-Module-Implementation-Version: 1
-OpenIDE-Module-Layer: de/whitewashing/php/cs/layer.xml
-OpenIDE-Module-Localizing-Bundle: de/whitewashing/php/cs/Bundle.properties
+Manifest-Version: 1.0
+OpenIDE-Module: de.whitewashing.php.cs/0
+OpenIDE-Module-Implementation-Version: 1
+OpenIDE-Module-Layer: de/whitewashing/php/cs/layer.xml
+OpenIDE-Module-Localizing-Bundle: de/whitewashing/php/cs/Bundle.properties
View
84 nbproject/build-impl.xml
@@ -1,42 +1,42 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
--->
-<project name="de.whitewashing.php.cs-impl" basedir="..">
- <fail message="Please build using Ant 1.7.1 or higher.">
- <condition>
- <not>
- <antversion atleast="1.7.1"/>
- </not>
- </condition>
- </fail>
- <property file="nbproject/private/platform-private.properties"/>
- <property file="nbproject/platform.properties"/>
- <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
- <attribute name="property"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{property}" value="@{value}"/>
- </sequential>
- </macrodef>
- <property file="${user.properties.file}"/>
- <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
- <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
- <condition>
- <not>
- <contains string="${cluster.path.evaluated}" substring="platform"/>
- </not>
- </condition>
- </fail>
- <import file="${harness.dir}/build.xml"/>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="de.whitewashing.php.cs-impl" basedir="..">
+ <fail message="Please build using Ant 1.7.1 or higher.">
+ <condition>
+ <not>
+ <antversion atleast="1.7.1"/>
+ </not>
+ </condition>
+ </fail>
+ <property file="nbproject/private/platform-private.properties"/>
+ <property file="nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="property"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{property}" value="@{value}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
+ <condition>
+ <not>
+ <contains string="${cluster.path.evaluated}" substring="platform"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
View
16 nbproject/genfiles.properties
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=cf839f5c
-build.xml.script.CRC32=4128fe19
-build.xml.stylesheet.CRC32=a56c6a5b@1.46.1
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=cf839f5c
-nbproject/build-impl.xml.script.CRC32=8aa25b8f
-nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.1
+build.xml.data.CRC32=11b337b4
+build.xml.script.CRC32=4128fe19
+build.xml.stylesheet.CRC32=a56c6a5b@1.46.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=11b337b4
+nbproject/build-impl.xml.script.CRC32=8aa25b8f
+nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.1
View
1  nbproject/private/platform-private.properties
@@ -1,2 +1,3 @@
user.properties.file=/home/willy/.netbeans/7.0/build.properties
nbplatform.default.harness.dir=/home/willy/netbeans-7.0.1/harness
+#nbplatform.default.harness.dir=C:\\Program Files\\NetBeans 7.0.1\\harness
View
8 nbproject/private/private.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
- <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
-</project-private>
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
View
288 nbproject/project.xml
@@ -1,140 +1,148 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.apisupport.project</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
- <code-name-base>de.whitewashing.php.cs</code-name-base>
- <standalone/>
- <module-dependencies>
- <dependency>
- <code-name-base>org.jdesktop.layout</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.7.1.103</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.extexecution</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>2</release-version>
- <specification-version>1.14.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.options.api</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.12.2</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.39.1.6</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.modules.settings</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.18.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.netbeans.spi.tasklist</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.4.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.actions</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>6.11.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.awt</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.8.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.filesystems</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.21.1.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.loaders</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.5.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.nodes</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.9.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.text</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>6.22.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.util</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>7.22.1.1</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
- <code-name-base>org.openide.windows</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <specification-version>6.26.1</specification-version>
- </run-dependency>
- </dependency>
- </module-dependencies>
- <test-dependencies>
- <test-type>
- <name>unit</name>
- <test-dependency>
- <code-name-base>org.netbeans.libs.junit4</code-name-base>
- <compile-dependency/>
- </test-dependency>
- </test-type>
- </test-dependencies>
- <public-packages/>
- </data>
- </configuration>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>de.whitewashing.php.cs</code-name-base>
+ <standalone/>
+ <module-dependencies>
+ <dependency>
+ <code-name-base>org.jdesktop.layout</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.7.1.103</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.extexecution</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>2</release-version>
+ <specification-version>1.14.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.options.api</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.12.2</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.39.1.6</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.settings</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.18.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.spi.tasklist</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.4.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.actions</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.11.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.awt</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.8.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.dialogs</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.20.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.filesystems</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.21.1.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.loaders</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.5.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.nodes</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.9.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.text</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.22.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.22.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.26.1</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <test-dependencies>
+ <test-type>
+ <name>unit</name>
+ <test-dependency>
+ <code-name-base>org.netbeans.libs.junit4</code-name-base>
+ <compile-dependency/>
+ </test-dependency>
+ </test-type>
+ </test-dependencies>
+ <public-packages/>
+ </data>
+ </configuration>
+</project>
View
108 src/de/whitewashing/php/cs/command/CodeSniffer.java
@@ -8,14 +8,18 @@
import java.io.File;
import java.io.IOException;
import java.io.Reader;
+import java.lang.String;
import java.util.ArrayList;
import java.util.List;
+import java.util.List;
import java.util.concurrent.Future;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.netbeans.api.extexecution.ExecutionDescriptor;
import org.netbeans.api.extexecution.ExecutionService;
import org.netbeans.api.extexecution.ExternalProcessBuilder;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
import org.openide.cookies.LineCookie;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -23,7 +27,6 @@
import org.openide.util.Exceptions;
import org.openide.loaders.DataObject;
import org.openide.text.Line;
-import sun.misc.Regexp;
/**
*
@@ -68,7 +71,12 @@ public String getVersion() {
try {
ProcessExecutor executor = new ProcessExecutor();
- String versionLine = this.getStringFromReader(executor.execute(procBuilder));
+ Reader executedProcess = executor.execute(procBuilder);
+
+ // Handle PHP Exceptions
+ handlePhpExceptions(executedProcess);
+
+ String versionLine = this.getStringFromReader(executedProcess);
Pattern pattern = Pattern.compile("(?:CodeSniffer.*?)(?:v\\.?(?:ersion)?\\s+)([0-9]+\\.[0-9]+(?:\\.[0-9]+)?)", Pattern.CASE_INSENSITIVE);
Matcher m = pattern.matcher(versionLine);
if(!m.find()) {
@@ -76,7 +84,10 @@ public String getVersion() {
}
return m.group(1);
- } catch(IOException e) {
+ } catch(CodeSnifferPhpException e) {
+ DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
+ return "?";
+ } catch(java.io.IOException e) {
return "?";
}
}
@@ -86,12 +97,24 @@ public String getVersion() {
return new ArrayList<String>();
}
- ExternalProcessBuilder procBuilder = new ExternalProcessBuilder(this.shellScript)
- .addArgument("-i");
+ try {
+ ExternalProcessBuilder procBuilder = new ExternalProcessBuilder(this.shellScript)
+ .addArgument("-i");
+
+ ProcessExecutor executor = new ProcessExecutor();
+ StupidStandardsOutputParser parser = new StupidStandardsOutputParser();
+
+ Reader executedProcess = executor.execute(procBuilder);
- ProcessExecutor executor = new ProcessExecutor();
- StupidStandardsOutputParser parser = new StupidStandardsOutputParser();
- return parser.parse(executor.execute(procBuilder));
+ // Handle PHP Exceptions
+ handlePhpExceptions(executedProcess);
+
+ return parser.parse(executedProcess);
+ } catch(java.io.IOException e) {
+ DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
+ }
+
+ return new ArrayList<String>();
}
public CodeSnifferXmlLogResult execute(FileObject fo) {
@@ -104,9 +127,9 @@ public CodeSnifferXmlLogResult execute(FileObject fo, boolean annotateLines) {
if(parent == null || this.isEnabled() == false) {
return CodeSnifferXmlLogResult.empty();
}
-
+
+ // Executes PHPCS
ExternalProcessBuilder externalProcessBuilder;
-
if (this.showWarnings) {
externalProcessBuilder = new ExternalProcessBuilder(this.shellScript)
.workingDirectory(parent)
@@ -123,11 +146,27 @@ public CodeSnifferXmlLogResult execute(FileObject fo, boolean annotateLines) {
}
CodeSnifferXmlLogParser parser = new CodeSnifferXmlLogParser();
- CodeSnifferXmlLogResult rs = parser.parse(new ProcessExecutor().execute(externalProcessBuilder));
+ Reader executedProcess = new ProcessExecutor().execute(externalProcessBuilder);
+
+ CodeSnifferXmlLogResult rs = CodeSnifferXmlLogResult.empty();
+ try {
+ // Handle PHP Exceptions
+ handlePhpExceptions(executedProcess);
- if(annotateLines) {
- annotateWithCodingStandardHints(fo, rs);
+ // Parse response
+ rs = parser.parse(executedProcess);
+ if(annotateLines) {
+ annotateWithCodingStandardHints(fo, rs);
+ }
+
+ // Check if we have no errors at all
+ if(rs.getCsErrors().isEmpty() && rs.getCsWarnings().isEmpty())
+ DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Great!\nNo errors or warnings found.", NotifyDescriptor.INFORMATION_MESSAGE));
+ } catch(java.io.IOException e) {
+ DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
}
+
+ // Progress bar finish
return rs;
}
@@ -211,6 +250,49 @@ public Reader execute(ExternalProcessBuilder builder) {
return output.getReader();
}
}
+
+ /**
+ * Reads the stream searching for fatal errors when executing PHPCS
+ */
+ public void handlePhpExceptions(Reader reader)
+ throws CodeSnifferPhpException, IOException
+ {
+ // Check if no fatal errors occured in PHPCS
+ char[] buffer = new char[1024];
+ int numCharsRead;
+ while((numCharsRead = reader.read(buffer)) > 0) {
+ String ln = (new String(buffer, 0, numCharsRead));
+ String message = "";
+
+ // Treats fatal errors and parse errors that PHP may throw
+ if(ln.indexOf("Fatal error:") >= 0 || ln.indexOf("Parse error:") >= 0) {
+ if(ln.indexOf("Fatal error:") >= 0) {
+ Matcher m = Pattern.compile(
+ "Fatal error: (.*?:[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: (.*line [0-9]+)",
+ Pattern.CASE_INSENSITIVE
+ ).matcher(ln);
+ if(m.find())
+ message = m.group(1);
+ }
+
+ String finalMessage = "A fatal error occured, check your PHPCS installation.";
+ if(!message.equals(""))
+ finalMessage += "\nError:\n" + message;
+
+ reader.reset();
+ throw new CodeSnifferPhpException(finalMessage);
+ }
+ }
+
+ reader.reset();
+ }
/**
* Utility class that parses the textual output of the CodeSniffer -i option
View
13 src/de/whitewashing/php/cs/command/CodeSnifferPhpException.java
@@ -0,0 +1,13 @@
+package de.whitewashing.php.cs.command;
+
+/**
+ * Default exception when
+ * @author Willy Barro
+ */
+public class CodeSnifferPhpException extends java.io.IOException {
+
+ CodeSnifferPhpException(String finalMessage) {
+ super(finalMessage);
+ }
+
+}
View
3  src/de/whitewashing/php/cs/command/CodeSnifferXmlLogParser.java
@@ -46,6 +46,7 @@ CodeSnifferXmlLogResult parse(Reader reader)
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
+ String exception = "";
try {
builder = factory.newDocumentBuilder();
Document document;
@@ -70,7 +71,7 @@ CodeSnifferXmlLogResult parse(Reader reader)
} catch (ParserConfigurationException ex) {
} catch(SAXParseException ex) {
-
+ exception = ex.getMessage();
} catch (SAXException ex) {
}
View
18 src/de/whitewashing/php/cs/layer.xml
@@ -16,6 +16,22 @@
</file>
</folder>
</folder>
+ <folder name="javascript">
+ <folder name="Popup">
+ <file name="de-whitewashing-php-cs-CodeSnifferAction.shadow">
+ <attr name="originalFile" stringvalue="Actions/PHP/de-whitewashing-php-cs-CodeSnifferAction.instance"/>
+ <attr name="position" intvalue="875"/>
+ </file>
+ </folder>
+ </folder>
+ <folder name="x-css">
+ <folder name="Popup">
+ <file name="de-whitewashing-php-cs-CodeSnifferAction.shadow">
+ <attr name="originalFile" stringvalue="Actions/PHP/de-whitewashing-php-cs-CodeSnifferAction.instance"/>
+ <attr name="position" intvalue="875"/>
+ </file>
+ </folder>
+ </folder>
</folder>
<folder name="AnnotationTypes">
<file name="de-whitewashing-php-cs-annotation-warning.xml" url="nbresloc:/de/whitewashing/php/cs/resources/cs-warn-annotation.xml"/>
@@ -23,7 +39,7 @@
</folder>
</folder>
<folder name="Shortcuts">
- <file name="S-F9.shadow">
+ <file name="S-F12.shadow">
<attr name="originalFile" stringvalue="Actions/PHP/de-whitewashing-php-cs-CodeSnifferAction.instance"/>
</file>
</folder>
View
2  src/de/whitewashing/php/cs/resources/cs-error-annotation.xml
@@ -6,5 +6,7 @@
visible="true"
glyph="nbresloc:/de/whitewashing/php/cs/resources/cserror.png"
highlight="#FFCFCF"
+ custom_sidebar_color="#FF0000"
type="line"
+ severity="warning"
/>
View
2  src/de/whitewashing/php/cs/resources/cs-warn-annotation.xml
@@ -6,5 +6,7 @@
visible="true"
glyph="nbresloc:/de/whitewashing/php/cs/resources/cswarn.png"
highlight="#FFFBCF"
+ custom_sidebar_color="#FFBE00"
type="line"
+ severity="warning"
/>
View
1  src/de/whitewashing/php/cs/ui/options/CodeSnifferOptions.java
@@ -9,7 +9,6 @@
import de.whitewashing.php.cs.command.CodeSnifferBinary;
import java.util.ArrayList;
import java.util.List;
-import java.util.prefs.Preferences;
import org.openide.util.NbPreferences;
/**
View
70 src/de/whitewashing/php/cs/ui/options/CodeSnifferOptionsPanel.form
@@ -29,50 +29,40 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
- <Group type="102" alignment="1" attributes="0">
- <EmptySpace min="-2" pref="65" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="74" max="-2" attributes="0"/>
- <Component id="checkBoxShowWarnings" pref="506" max="32767" attributes="1"/>
- </Group>
- <Group type="102" alignment="0" attributes="0">
- <Component id="labelStandard" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Component id="inputBoxStandard" min="-2" pref="350" max="-2" attributes="1"/>
- </Group>
+ <Component id="labelStandard" min="-2" max="-2" attributes="0"/>
+ <Component id="codeSnifferLabel" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="statusLabel" alignment="1" max="32767" attributes="1"/>
+ <Component id="versionLabel" alignment="1" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="versionTextLabel" max="32767" attributes="1"/>
+ <Component id="statusTextLabel" alignment="0" pref="261" max="32767" attributes="1"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="codeSnifferLabel" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <Component id="codeSnifferTextField" min="-2" pref="347" max="-2" attributes="1"/>
- <EmptySpace max="-2" attributes="0"/>
- <Component id="browseButton" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
- <Component id="refreshButton" min="-2" max="-2" attributes="0"/>
- </Group>
- <Group type="102" alignment="0" attributes="0">
- <Group type="103" groupAlignment="1" max="-2" attributes="0">
- <Component id="statusLabel" alignment="1" max="32767" attributes="1"/>
- <Component id="versionLabel" alignment="1" max="32767" attributes="1"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" max="-2" attributes="0">
- <Component id="versionTextLabel" max="32767" attributes="1"/>
- <Component id="statusTextLabel" alignment="0" pref="261" max="32767" attributes="1"/>
- </Group>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="codeSnifferTextField" min="-2" pref="350" max="-2" attributes="1"/>
+ <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+ <Component id="checkBoxShowWarnings" alignment="0" min="-2" pref="230" max="-2" attributes="1"/>
+ <Component id="inputBoxStandard" alignment="0" min="-2" pref="350" max="-2" attributes="1"/>
</Group>
</Group>
- <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="browseButton" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="refreshButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
- <EmptySpace min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -81,10 +71,10 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
- <Component id="codeSnifferLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="codeSnifferTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="refreshButton" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="codeSnifferLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@@ -96,14 +86,14 @@
<Component id="versionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="versionTextLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="inputBoxStandard" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelStandard" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
<Component id="checkBoxShowWarnings" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="168" max="32767" attributes="0"/>
+ <EmptySpace pref="185" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
View
115 src/de/whitewashing/php/cs/ui/options/CodeSnifferOptionsPanel.java
@@ -101,48 +101,41 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
+ .add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(labelStandard)
+ .add(codeSnifferLabel))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(versionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(versionTextLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(statusTextLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
- .add(65, 65, 65)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(74, 74, 74)
- .add(checkBoxShowWarnings, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE))
- .add(layout.createSequentialGroup()
- .add(labelStandard)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(inputBoxStandard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 350, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
- .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
- .addContainerGap()
- .add(codeSnifferLabel)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(codeSnifferTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 350, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(checkBoxShowWarnings, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 230, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(inputBoxStandard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 350, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(codeSnifferTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 347, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(browseButton)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(refreshButton))
- .add(layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
- .add(statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .add(versionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
- .add(versionTextLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .add(statusTextLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE))))
- .add(18, 18, 18)))
- .addContainerGap())
+ .add(browseButton)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(refreshButton)))
+ .add(18, 18, 18))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(codeSnifferLabel)
.add(codeSnifferTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(browseButton)
- .add(refreshButton))
+ .add(refreshButton)
+ .add(codeSnifferLabel))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(statusLabel)
@@ -157,7 +150,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.add(labelStandard))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(checkBoxShowWarnings)
- .addContainerGap(168, Short.MAX_VALUE))
+ .addContainerGap(185, Short.MAX_VALUE))
);
getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CodeSnifferOptionsPanel.class, "CodeSnifferPanel.AccessibleContext.accessibleDescription")); // NOI18N
@@ -185,6 +178,13 @@ private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN
void load() {
command = CodeSnifferBuilder.createOrReturn();
+ // Gets available standards
+ options = new CodeSnifferOptions(command.getAvailableStandards());
+
+ // Fill inputs with previously saved preferences
+ fillForm();
+
+ //
refresh();
}
@@ -193,23 +193,20 @@ void load() {
* Validates if PHPCS is installed and loads latest code standards
*/
void refresh() {
- // Remove all old standards
- inputBoxStandard.removeAllItems();
+ String csPath = codeSnifferTextField.getText();
+ command.setShellScript(csPath);
if(valid()) {
+ store(true);
+
statusTextLabel.setText("Activated");
statusTextLabel.setForeground(new Color(16, 110, 0));
inputBoxStandard.setEnabled(true);
checkBoxShowWarnings.setEnabled(true);
- for(String standard : this.options.getCodingStandards()) {
- inputBoxStandard.addItem(standard);
- }
-
- inputBoxStandard.setSelectedItem(options.getCodingStandard());
- checkBoxShowWarnings.setSelected(options.hasShowWarnings());
- codeSnifferTextField.setText(options.getShellScript());
+ // Updates inputs with new provided data (if any)
+ fillForm();
} else {
inputBoxStandard.setEnabled(false);
checkBoxShowWarnings.setEnabled(false);
@@ -227,11 +224,6 @@ void refresh() {
boolean valid() {
boolean isValid;
- String csPath = codeSnifferTextField.getText();
- if(!csPath.equals("")) {
- command.setShellScript(codeSnifferTextField.getText());
- }
-
// Gets PHPCS version, if "?" then, valid PHPCS were not found
if(command.getVersion().equals("?")) {
isValid = false;
@@ -250,10 +242,21 @@ boolean valid() {
}
return isValid;
- }
+ }
+ /**
+ * Store method as NB need it (without arguments)
+ */
void store() {
- if(valid()) {
+ store(false);
+ }
+
+ /**
+ * Store method, will persist set NBPreferences
+ * @param assumeValid If validation should be run again. If true, avoids unnecessary validations.
+ */
+ void store(boolean assumeValid) {
+ if(assumeValid || valid()) {
// Only add when a standard exists
String selectedItem = (String) inputBoxStandard.getSelectedItem();
if(selectedItem != null) {
@@ -267,6 +270,22 @@ void store() {
// SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
}
}
+
+ /**
+ * Fill form input's and checkboxes with nbpreferences data
+ */
+ void fillForm() {
+ // Remove all standards
+ inputBoxStandard.removeAllItems();
+
+ for(String standard : options.getCodingStandards()) {
+ inputBoxStandard.addItem(standard);
+ }
+
+ inputBoxStandard.setSelectedItem(options.getCodingStandard());
+ checkBoxShowWarnings.setSelected(options.hasShowWarnings());
+ codeSnifferTextField.setText(options.getShellScript());
+ }
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton browseButton;
Please sign in to comment.
Something went wrong with that request. Please try again.