Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-03-09 08:40:53 +0000
committerAlexander Kurtakov2018-03-09 08:40:53 +0000
commit84d6fdefaa5aa03e452616e153ad9c3c1338297f (patch)
tree1b0ed72d8bc76a58030171cf210000aaff992437 /build/org.eclipse.cdt.meson.ui
parentc158b0bdd2171bb1ae3b05dd1eeff6c64841dc48 (diff)
downloadorg.eclipse.cdt-84d6fdefaa5aa03e452616e153ad9c3c1338297f.tar.gz
org.eclipse.cdt-84d6fdefaa5aa03e452616e153ad9c3c1338297f.tar.xz
org.eclipse.cdt-84d6fdefaa5aa03e452616e153ad9c3c1338297f.zip
Sonar fixes in Meson plugins.
Change-Id: I27a75d6dac41ae820d6af0b7c30922eb5bac58f7 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'build/org.eclipse.cdt.meson.ui')
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/MesonBuildTab.java9
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java7
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java25
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java2
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java5
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java7
6 files changed, 24 insertions, 31 deletions
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/MesonBuildTab.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/MesonBuildTab.java
index b1635f56401..cdddf4951af 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/MesonBuildTab.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/MesonBuildTab.java
@@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Text;
public class MesonBuildTab extends CommonBuildTab {
+ private static final String NINJA = "Ninja";
private Button unixGenButton;
private Button ninjaGenButton;
private Text mesonArgsText;
@@ -131,7 +132,7 @@ public class MesonBuildTab extends CommonBuildTab {
}
private void updateGeneratorButtons(String generator) {
- if (generator == null || generator.equals("Ninja")) { //$NON-NLS-1$
+ if (generator == null || generator.equals(NINJA)) { //$NON-NLS-1$
ninjaGenButton.setSelection(true);
} else {
unixGenButton.setSelection(true);
@@ -145,7 +146,7 @@ public class MesonBuildTab extends CommonBuildTab {
ICBuildConfiguration buildConfig = getBuildConfiguration();
buildConfig.setProperty(IMesonConstants.MESON_GENERATOR,
- ninjaGenButton.getSelection() ? "Ninja" : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$
+ ninjaGenButton.getSelection() ? NINJA : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$
String mesonArgs = mesonArgsText.getText().trim();
if (!mesonArgs.isEmpty()) {
@@ -173,7 +174,7 @@ public class MesonBuildTab extends CommonBuildTab {
protected void saveProperties(Map<String, String> properties) {
super.saveProperties(properties);
properties.put(IMesonConstants.MESON_GENERATOR,
- ninjaGenButton.getSelection() ? "Ninja" : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$
+ ninjaGenButton.getSelection() ? NINJA : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put(IMesonConstants.MESON_ARGUMENTS, mesonArgsText.getText().trim());
properties.put(IMesonConstants.BUILD_COMMAND, buildCommandText.getText().trim());
@@ -187,7 +188,7 @@ public class MesonBuildTab extends CommonBuildTab {
String gen = properties.get(IMesonConstants.MESON_GENERATOR);
if (gen != null) {
switch (gen) {
- case "Ninja": //$NON-NLS-1$
+ case NINJA: //$NON-NLS-1$
ninjaGenButton.setSelection(true);
unixGenButton.setSelection(false);
break;
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java
index 72a7f02911b..9158be1bd4e 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java
@@ -48,8 +48,8 @@ public class SWTImagesFactory {
private static ImageDescriptor createManaged(ImageRegistry registry,
String prefix, String name) {
- ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(
- prefix, name.substring(NAME_PREFIX_LENGTH)));
+ ImageDescriptor result = ImageDescriptor
+ .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
registry.put(name, result);
return result;
}
@@ -85,8 +85,9 @@ public class SWTImagesFactory {
*/
public static void setImageDescriptors(IAction action, String type,
String relPath) {
- if (relPath.startsWith(NAME_PREFIX))
+ if (relPath.startsWith(NAME_PREFIX)) {
relPath = relPath.substring(NAME_PREFIX_LENGTH);
+ }
action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$
action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java
index ea3b887e28f..0775c352ec7 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java
@@ -55,8 +55,9 @@ public abstract class AbstractMesonCommandHandler extends AbstractHandler {
if (obj instanceof Collection) {
Collection<Object> c = (Collection<Object>)obj;
Object[] objArray = c.toArray();
- if (objArray.length > 0)
+ if (objArray.length > 0) {
obj = objArray[0];
+ }
}
if (obj instanceof ICElement) {
if ( obj instanceof ICContainer || obj instanceof ICProject) {
@@ -79,8 +80,6 @@ public abstract class AbstractMesonCommandHandler extends AbstractHandler {
return fContainer;
}
- public final String SHELL_COMMAND = "sh"; //$NON-NLS-1$
-
protected void showError(String title, String content) {
MessageDialog.openError(new Shell(), title, content);
}
@@ -174,10 +173,11 @@ public abstract class AbstractMesonCommandHandler extends AbstractHandler {
// Skip white-space
while (Character.isWhitespace(ch)) {
++i;
- if (i < rawArgList.length())
+ if (i < rawArgList.length()) {
ch = rawArgList.charAt(i);
- else // Otherwise we are done
+ } else { // Otherwise we are done
return argList;
+ }
}
// Simplistic parser. We break up into strings delimited
@@ -188,22 +188,21 @@ public abstract class AbstractMesonCommandHandler extends AbstractHandler {
boolean inString = false;
while (i < rawArgList.length()) {
ch = rawArgList.charAt(i);
- if (ch == '\\') // escape character
+ if (ch == '\\') { // escape character
++i; // skip over the next character
- else if (ch == '\"') { // double quotes
+ } else if (ch == '\"') { // double quotes
inString = !inString;
- } else if (Character.isWhitespace(ch)) {
- if (!inString) {
- argList.add(rawArgList.substring(lastArgIndex, i));
- break;
- }
+ } else if (Character.isWhitespace(ch) && !inString) {
+ argList.add(rawArgList.substring(lastArgIndex, i));
+ break;
}
++i;
}
// Look for the case where we ran out of chars for the last
// token.
- if (i >= rawArgList.length())
+ if (i >= rawArgList.length()) {
argList.add(rawArgList.substring(lastArgIndex));
+ }
++i;
}
return argList;
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java
index 51c2d3c9880..17b98a584e7 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java
@@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.meson.ui.wizards;
import org.eclipse.osgi.util.NLS;
-public class WizardMessages extends NLS {
+public final class WizardMessages extends NLS {
public static String RunNinjaPage_name;
public static String RunNinjaPage_description;
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java
index df3b3ab6358..757214687c6 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java
@@ -40,7 +40,7 @@ public interface IMesonPropertyPageControl {
* Get the command line parameter if already configured
* @return String containing command-line for configured build dir
*/
- public default String getConfiguredString() {
+ default String getConfiguredString() {
return "-D" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -48,8 +48,7 @@ public interface IMesonPropertyPageControl {
* Get the command line parameter if never configured
* @return String containing command-line parm for configured build dir
*/
- public default String getUnconfiguredString() {
- // TODO Auto-generated method stub
+ default String getUnconfiguredString() {
return "--" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
index 03a930d4467..601284734c5 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
@@ -339,15 +339,8 @@ public class MesonPropertyPage extends PropertyPage {
Pattern descPattern1 = Pattern.compile("([^\\.]+).*");
Pattern descPattern = Pattern.compile("([^\\(]*)(\\(default\\:\\s+([^\\)]+)\\).*)");
for (String line : lines) {
-// System.out.println(line);
Matcher optionMatcher = optionPattern.matcher(line);
if (optionMatcher.matches() && !optionMatcher.group(2).equals("help")) {
-// System.out.println("group 1 is " + (optionMatcher.group(1) != null ? optionMatcher.group(1).trim() : null));
-// System.out.println("group 2 is " + (optionMatcher.group(2) != null ? optionMatcher.group(2).trim() : null));
-// System.out.println("group 3 is " + (optionMatcher.group(3) != null ? optionMatcher.group(3).trim() : null));
-// System.out.println("group 4 is " + (optionMatcher.group(4) != null ? optionMatcher.group(4).trim() : null));
-// System.out.println("group 5 is " + (optionMatcher.group(5) != null ? optionMatcher.group(5).trim() : null));
-// System.out.println("group 6 is " + (optionMatcher.group(6) != null ? optionMatcher.group(6).trim() : null));
if (optionMatcher.group(3) != null) {
String defaultValue = argMap.get(optionMatcher.group(2));
String description = optionMatcher.group(6);

Back to the top