From ebaa62f28e0a365a4ce7fb7af0d260dd5cbad9a8 Mon Sep 17 00:00:00 2001 From: Hiroaki Kamei Date: Fri, 20 Mar 2015 12:49:45 +0900 Subject: [PATCH] add --encoding with workspace character encoding --- .../pti/tools/codesniffer/core/PHPCodeSniffer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/org/phpsrc/eclipse/pti/tools/codesniffer/core/PHPCodeSniffer.java b/src/org/phpsrc/eclipse/pti/tools/codesniffer/core/PHPCodeSniffer.java index fd0392f..6ee8eb2 100644 --- a/src/org/phpsrc/eclipse/pti/tools/codesniffer/core/PHPCodeSniffer.java +++ b/src/org/phpsrc/eclipse/pti/tools/codesniffer/core/PHPCodeSniffer.java @@ -16,6 +16,7 @@ import org.apache.xerces.parsers.DOMParser; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -225,7 +226,7 @@ protected PHPToolLauncher getPHPToolLauncher(IProject project, .getSessionProperty(QUALIFIED_NAME); if (launcher != null) { launcher.setCommandLineArgs(getCommandLineArgs(standard, - prefs.getTabWidth())); + prefs.getTabWidth(), ResourcesPlugin.getEncoding())); return launcher; } } catch (CoreException e) { @@ -234,7 +235,7 @@ protected PHPToolLauncher getPHPToolLauncher(IProject project, launcher = new PHPToolLauncher(QUALIFIED_NAME, getPHPExecutable(prefs.getPhpExecutable()), getScriptFile(), - getCommandLineArgs(standard, prefs.getTabWidth()), + getCommandLineArgs(standard, prefs.getTabWidth(), ResourcesPlugin.getEncoding()), getPHPINIEntries(prefs, project, standard)); launcher.setPrintOuput(prefs.isPrintOutput()); @@ -279,7 +280,7 @@ public static IPath getScriptFile() { "/php/tools/phpcs.php"); } - private String getCommandLineArgs(Standard standard, int tabWidth) { + private String getCommandLineArgs(Standard standard, int tabWidth, String encoding) { String args = "--report=xml --standard=" + (standard.custom ? OperatingSystem @@ -289,6 +290,9 @@ private String getCommandLineArgs(Standard standard, int tabWidth) { if (tabWidth > 0) args += " --tab-width=" + tabWidth; + if (encoding != null && !encoding.isEmpty()) + args += " --encoding=" + encoding; + return args + " " + PHPToolLauncher.COMMANDLINE_PLACEHOLDER_FILE; } }