1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Sonar fixes in Meson plugins.

Change-Id: I27a75d6dac41ae820d6af0b7c30922eb5bac58f7
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2018-03-09 10:40:53 +02:00
parent c158b0bdd2
commit 84d6fdefaa
9 changed files with 38 additions and 43 deletions

View file

@ -214,7 +214,7 @@ public class MesonToolChainManager implements IMesonToolChainManager {
for (IMesonToolChainListener listener : listeners) {
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
public void run() {
listener.handleMesonToolChainEvent(event);
}

View file

@ -136,13 +136,15 @@ public class Activator implements BundleActivator {
}
public static void log(Throwable e) {
if (e instanceof InvocationTargetException)
if (e instanceof InvocationTargetException) {
e = ((InvocationTargetException) e).getTargetException();
}
IStatus status = null;
if (e instanceof CoreException)
if (e instanceof CoreException) {
status = ((CoreException) e).getStatus();
else
} else {
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
}
log(status);
}
@ -153,12 +155,12 @@ public class Activator implements BundleActivator {
}
@Override
public void start(BundleContext bundleContext) throws Exception {
public void start(BundleContext bundleContext) {
Activator.context = bundleContext;
}
@Override
public void stop(BundleContext bundleContext) throws Exception {
public void stop(BundleContext bundleContext) {
Activator.context = null;
plugin = null;
}

View file

@ -12,12 +12,12 @@ package org.eclipse.cdt.meson.core;
public interface IMesonConstants {
public static final String MESON_ARGUMENTS = "meson.arguments"; //$NON-NLS-1$
public static final String MESON_ENV = "meson.environment"; //$NON-NLS-1$
public static final String MESON_PROJECT_OPTIONS = "meson.project.options"; //$NON-NLS-1$
public static final String NINJA_ENV = "meson.ninja.environment"; //$NON-NLS-1$
public static final String NINJA_ARGUMENTS = "meson.ninja.arguments"; //$NON-NLS-1$
public static final String MESON_ENV_SEPARATOR = "|"; //$NON-NLS-1$
String MESON_ARGUMENTS = "meson.arguments"; //$NON-NLS-1$
String MESON_ENV = "meson.environment"; //$NON-NLS-1$
String MESON_PROJECT_OPTIONS = "meson.project.options"; //$NON-NLS-1$
String NINJA_ENV = "meson.ninja.environment"; //$NON-NLS-1$
String NINJA_ARGUMENTS = "meson.ninja.arguments"; //$NON-NLS-1$
String MESON_ENV_SEPARATOR = "|"; //$NON-NLS-1$
String MESON_GENERATOR = "meson.generator"; //$NON-NLS-1$
String BUILD_COMMAND = "meson.command.build"; //$NON-NLS-1$
String CLEAN_COMMAND = "meson.command.clean"; //$NON-NLS-1$

View file

@ -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;

View file

@ -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$

View file

@ -55,9 +55,10 @@ 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) {
fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource();
@ -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,11 +173,12 @@ 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
// by blanks. If quotes are used, we ignore blanks within.
@ -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) {
} 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;

View file

@ -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;

View file

@ -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$
}

View file

@ -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);