mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics
Change-Id: I375dfe970de30bf660d7783c52fb809ecdfd84fe
This commit is contained in:
parent
2df93034f3
commit
6ba479a6f2
1 changed files with 69 additions and 74 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2011 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2015 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,7 +11,6 @@
|
|||
* Ericsson - Modified for additional features in DSF Reference implementation and bug 219920
|
||||
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -30,14 +29,10 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
|
|||
* Represents any MI command.
|
||||
*/
|
||||
public class MICommand<V extends MIInfo> implements ICommand<V> {
|
||||
private static final String[] empty = {};
|
||||
|
||||
/*
|
||||
* Variables.
|
||||
*/
|
||||
final static String[] empty = new String[0];
|
||||
|
||||
List<Adjustable> fOptions = new ArrayList<Adjustable>();
|
||||
List<Adjustable> fParameters = new ArrayList<Adjustable>();
|
||||
List<Adjustable> fOptions = new ArrayList<>();
|
||||
List<Adjustable> fParameters = new ArrayList<>();
|
||||
String fOperation = new String();
|
||||
IDMContext fCtx;
|
||||
|
||||
|
@ -62,7 +57,7 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
}
|
||||
|
||||
private final List<Adjustable> optionsToAdjustables(String[] options) {
|
||||
List<Adjustable> result = new ArrayList<Adjustable>();
|
||||
List<Adjustable> result = new ArrayList<>();
|
||||
if (options != null) {
|
||||
for (String option : options) {
|
||||
result.add(new MIStandardOptionAdjustable(option));
|
||||
|
@ -72,7 +67,7 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
}
|
||||
|
||||
private final List<Adjustable> parametersToAdjustables(String[] parameters) {
|
||||
List<Adjustable> result = new ArrayList<Adjustable>();
|
||||
List<Adjustable> result = new ArrayList<>();
|
||||
if (parameters != null) {
|
||||
for (String parameter : parameters) {
|
||||
result.add(new MIStandardParameterAdjustable(parameter));
|
||||
|
@ -86,19 +81,19 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
return controlDmc.getCommandControlFilter();
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the operation of this command.
|
||||
*/
|
||||
public String getOperation() {
|
||||
return fOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns an array of command's options. An empty collection is
|
||||
* returned if there are no options.
|
||||
*/
|
||||
public String[] getOptions() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Adjustable option : fOptions) {
|
||||
result.add(option.getValue());
|
||||
}
|
||||
|
@ -109,12 +104,12 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
fOptions = optionsToAdjustables(options);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns an array of command's parameters. An empty collection is
|
||||
* returned if there are no parameters.
|
||||
*/
|
||||
public String[] getParameters() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Adjustable parameter : fParameters) {
|
||||
result.add(parameter.getValue());
|
||||
}
|
||||
|
@ -129,16 +124,16 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
fParameters = Arrays.asList(params);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the constructed command without using the --thread/--frame options.
|
||||
*/
|
||||
public String constructCommand() {
|
||||
return constructCommand(null, -1);
|
||||
}
|
||||
/*
|
||||
* Returns the constructed command potentially using the --thread/--frame options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the constructed command potentially using the --thread/--frame options.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public String constructCommand(String threadId, int frameId) {
|
||||
|
@ -147,20 +142,21 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
|
||||
/**
|
||||
* With GDB 7.1 the --thread-group option is used to support multiple processes.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public String constructCommand(String groupId, String threadId, int frameId) {
|
||||
StringBuffer command = new StringBuffer(getOperation());
|
||||
StringBuilder command = new StringBuilder(getOperation());
|
||||
|
||||
// Add the --thread option
|
||||
if (supportsThreadAndFrameOptions() && threadId != null && threadId.trim().length() > 0) {
|
||||
if (supportsThreadAndFrameOptions() && threadId != null && !threadId.trim().isEmpty()) {
|
||||
command.append(" --thread " + threadId); //$NON-NLS-1$
|
||||
|
||||
// Add the --frame option, but only if we are using the --thread option
|
||||
if (frameId >= 0) {
|
||||
command.append(" --frame " + frameId); //$NON-NLS-1$
|
||||
}
|
||||
} else if (supportsThreadGroupOption() && groupId != null && groupId.trim().length() > 0) {
|
||||
} else if (supportsThreadGroupOption() && groupId != null && !groupId.trim().isEmpty()) {
|
||||
// The --thread-group option is only allowed if we are not using the --thread option
|
||||
command.append(" --thread-group " + groupId); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -185,11 +181,6 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
// return false;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Takes the supplied command and coalesces it with this one.
|
||||
* The result is a new third command which represent the two
|
||||
* original command.
|
||||
*/
|
||||
@Override
|
||||
public ICommand<? extends ICommandResult> coalesceWith(ICommand<? extends ICommandResult> command) {
|
||||
return null;
|
||||
|
@ -200,6 +191,7 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
public IDMContext getContext() {
|
||||
return fCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the corresponding ICommandResult result for this
|
||||
* command.
|
||||
|
@ -207,11 +199,11 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
* @return result for this command
|
||||
*/
|
||||
public MIInfo getResult(MIOutput MIresult) {
|
||||
return ( new MIInfo(MIresult) );
|
||||
return new MIInfo(MIresult);
|
||||
}
|
||||
|
||||
protected String optionsToString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (fOptions != null && !fOptions.isEmpty()) {
|
||||
for (Adjustable option : fOptions) {
|
||||
sb.append(option.getAdjustedValue());
|
||||
|
@ -222,7 +214,7 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
|
||||
protected String parametersToString() {
|
||||
String[] options = getOptions();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
if (fParameters != null && !fParameters.isEmpty()) {
|
||||
// According to GDB/MI spec
|
||||
// Add a "--" separator if any parameters start with "-"
|
||||
|
@ -254,15 +246,19 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
/**
|
||||
* @since 1.1
|
||||
*/
|
||||
public boolean supportsThreadAndFrameOptions() { return true; }
|
||||
public boolean supportsThreadAndFrameOptions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public boolean supportsThreadGroupOption() { return true; }
|
||||
public boolean supportsThreadGroupOption() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare commands based on the MI command string that they generate,
|
||||
* Compares commands based on the MI command string that they generate,
|
||||
* without the token.
|
||||
*/
|
||||
@Override
|
||||
|
@ -344,7 +340,7 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
}
|
||||
|
||||
// Although this change makes sense, it could have impacts on many
|
||||
// different commands we send to GDB. The risk outways the benefits,
|
||||
// different commands we send to GDB. The risk outweighs the benefits,
|
||||
// so we comment it out. See bugs 412471 and 414959 for details.
|
||||
//
|
||||
// // an empty parameter can be passed with two single quotes
|
||||
|
@ -357,7 +353,6 @@ public class MICommand<V extends MIInfo> implements ICommand<V> {
|
|||
}
|
||||
|
||||
public static abstract class MICommandAdjustable implements Adjustable {
|
||||
|
||||
protected final String value;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue