mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Code cleanup.
Change-Id: I8425c6995bad38758234a2bdb43f5bab8cb244d7
This commit is contained in:
parent
93438cade8
commit
e2f375fc86
1 changed files with 6 additions and 8 deletions
|
@ -8,15 +8,13 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.mi.core.command;
|
package org.eclipse.cdt.debug.mi.core.command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Represents a MI command.
|
* Represents a MI command.
|
||||||
*/
|
*/
|
||||||
public class MICommand extends Command {
|
public class MICommand extends Command {
|
||||||
final static String[] empty = new String[0];
|
final static String[] empty = {};
|
||||||
String[] fOptions = empty;
|
String[] fOptions = empty;
|
||||||
String[] fParameters = empty;
|
String[] fParameters = empty;
|
||||||
String fOperation = new String();
|
String fOperation = new String();
|
||||||
|
@ -112,13 +110,13 @@ public class MICommand extends Command {
|
||||||
|
|
||||||
protected String optionsToString() {
|
protected String optionsToString() {
|
||||||
String[] options = getOptions();
|
String[] options = getOptions();
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (options != null && options.length > 0) {
|
if (options != null && options.length > 0) {
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
String option = options[i];
|
String option = options[i];
|
||||||
// If the option argument contains " or \ it must be escaped
|
// If the option argument contains " or \ it must be escaped
|
||||||
if (option.indexOf('"') != -1 || option.indexOf('\\') != -1) {
|
if (option.indexOf('"') != -1 || option.indexOf('\\') != -1) {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
for (int j = 0; j < option.length(); j++) {
|
for (int j = 0; j < option.length(); j++) {
|
||||||
char c = option.charAt(j);
|
char c = option.charAt(j);
|
||||||
if (c == '"' || c == '\\') {
|
if (c == '"' || c == '\\') {
|
||||||
|
@ -144,7 +142,7 @@ public class MICommand extends Command {
|
||||||
protected String parametersToString() {
|
protected String parametersToString() {
|
||||||
String[] parameters = getParameters();
|
String[] parameters = getParameters();
|
||||||
String[] options = getOptions();
|
String[] options = getOptions();
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
if (parameters != null && parameters.length > 0) {
|
if (parameters != null && parameters.length > 0) {
|
||||||
// According to GDB/MI spec
|
// According to GDB/MI spec
|
||||||
// Add a "--" separator if any parameters start with "-"
|
// Add a "--" separator if any parameters start with "-"
|
||||||
|
@ -157,7 +155,7 @@ public class MICommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < parameters.length; i++) {
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
// We need to escape the double quotes and the backslash.
|
// We need to escape the double quotes and the backslash.
|
||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
|
@ -184,7 +182,7 @@ public class MICommand extends Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer command = new StringBuffer(getToken() + getOperation());
|
StringBuilder command = new StringBuilder(getToken() + getOperation());
|
||||||
String opt = optionsToString();
|
String opt = optionsToString();
|
||||||
if (opt.length() > 0) {
|
if (opt.length() > 0) {
|
||||||
command.append(' ').append(opt);
|
command.append(' ').append(opt);
|
||||||
|
|
Loading…
Add table
Reference in a new issue