mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Bug 491945 - Remove new String() from expressions
Replace all occurrences of `new String(expr)` with `expr` provided that the `expr` is not a byte array or a char array. Change-Id: Iecae801b83084908b60b9e146eba87550eac640d Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
This commit is contained in:
parent
ca4e5b10ee
commit
470de4e66b
15 changed files with 49 additions and 55 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2015 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2016 IBM Corporation 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
|
||||
|
@ -132,11 +132,7 @@ public class StringMatcher {
|
|||
|
||||
/* convert case */
|
||||
if (fIgnoreCase) {
|
||||
char[] chars= aPattern.toCharArray();
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
chars[i]= Character.toUpperCase(chars[i]);
|
||||
}
|
||||
fPattern= new String(chars);
|
||||
fPattern= aPattern.toUpperCase();
|
||||
} else {
|
||||
fPattern= aPattern;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ManagedBuildCommandLineGenerator implements
|
|||
String commandLinePattern) {
|
||||
ManagedBuildCommandLineInfo info = new ManagedBuildCommandLineInfo();
|
||||
// Concatenate the tool name and the passed in command name
|
||||
info.commandName = new String(tool.getName() + commandName);
|
||||
info.commandName = tool.getName() + commandName;
|
||||
// Put out the flags backwards
|
||||
String myflags = ""; // $NON-NLS-1$
|
||||
for (int i = flags.length - 1; i >= 0; i--) {
|
||||
|
@ -62,9 +62,9 @@ public class ManagedBuildCommandLineGenerator implements
|
|||
}
|
||||
info.commandInputs = myinputs;
|
||||
// Don't change the command line pattern
|
||||
info.commandLinePattern = new String(commandLinePattern);
|
||||
info.commandLinePattern = commandLinePattern;
|
||||
// Config artifact name
|
||||
info.commandOutput = new String(((IToolChain)tool.getParent()).getParent().getArtifactName());
|
||||
info.commandOutput = ((IToolChain)tool.getParent()).getParent().getArtifactName();
|
||||
// -Oh
|
||||
info.commandOutputFlag = "-0h";
|
||||
// ""
|
||||
|
|
|
@ -58,11 +58,11 @@ public class Test30_2_CommandLineGenerator implements
|
|||
String commandLinePattern) {
|
||||
ManagedBuildCommandLineInfo info = new ManagedBuildCommandLineInfo();
|
||||
// We are only going to change the "flags" to remove the "test30_2.tar-list.filename" option
|
||||
info.commandName = new String(commandName);
|
||||
info.commandOutputFlag = new String(outputFlag);
|
||||
info.commandOutputPrefix = new String(outputPrefix);
|
||||
info.commandOutput = new String(outputName);
|
||||
info.commandLinePattern = new String(commandLinePattern);
|
||||
info.commandName = commandName;
|
||||
info.commandOutputFlag = outputFlag;
|
||||
info.commandOutputPrefix = outputPrefix;
|
||||
info.commandOutput = outputName;
|
||||
info.commandLinePattern = commandLinePattern;
|
||||
info.commandInputs = ""; // $NON-NLS-1$
|
||||
for (int i = 0; i < inputResources.length; i++) {
|
||||
if (i > 0) info.commandInputs += " ";
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.osgi.framework.Version;
|
|||
|
||||
public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
||||
|
||||
private static final String EMPTY_STRING = ""; // $NON-NLS-1$
|
||||
|
||||
//property name for holding the rebuild state
|
||||
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
|
||||
|
||||
|
@ -139,7 +137,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
setManagedBuildRevision(folderInfo.getParent().getManagedBuildRevision());
|
||||
|
||||
setDirty(false);
|
||||
toolsToInvoke = EMPTY_STRING;
|
||||
toolsToInvoke = ""; // $NON-NLS-1$
|
||||
rcbsApplicability = KIND_DISABLE_RCBS_TOOL;
|
||||
|
||||
|
||||
|
@ -187,7 +185,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
|
||||
// Copy the remaining attributes
|
||||
if (cloneConfig.toolsToInvoke != null) {
|
||||
toolsToInvoke = new String(cloneConfig.toolsToInvoke);
|
||||
toolsToInvoke = cloneConfig.toolsToInvoke;
|
||||
}
|
||||
if (cloneConfig.rcbsApplicability != null) {
|
||||
rcbsApplicability = cloneConfig.rcbsApplicability;
|
||||
|
@ -554,10 +552,10 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
* An empty string implies treat as if no resource configuration, i.e., use project level tool.
|
||||
* This getter routine returns an ITool[] to consumers (i.e., the makefile generator).
|
||||
*/
|
||||
String t_ToolsToInvoke = EMPTY_STRING;
|
||||
String t_ToolsToInvoke = ""; // $NON-NLS-1$
|
||||
ITool[] resConfigTools;
|
||||
ITool[] tools;
|
||||
String rcbsToolId = EMPTY_STRING;
|
||||
String rcbsToolId = ""; // $NON-NLS-1$
|
||||
int len;
|
||||
int j;
|
||||
int rcbsToolIdx=-1;
|
||||
|
@ -573,7 +571,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
* If no tools are currently defined, return a zero lengh array of ITool.
|
||||
*/
|
||||
if (resConfigTools.length == 0) {
|
||||
toolsToInvoke = EMPTY_STRING;
|
||||
toolsToInvoke = ""; // $NON-NLS-1$
|
||||
tools = new ITool[0];
|
||||
return tools;
|
||||
}
|
||||
|
@ -588,7 +586,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!rcbsToolId.equals(EMPTY_STRING)){
|
||||
if (!rcbsToolId.equals("")){ // $NON-NLS-1$
|
||||
/*
|
||||
* Here if an rcbs tool is defined.
|
||||
* Apply the tools according to the current rcbsApplicability setting.
|
||||
|
@ -634,7 +632,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
|||
*/
|
||||
if(resConfigTools.length == 1){
|
||||
tools = new ITool[0];
|
||||
toolsToInvoke = EMPTY_STRING;
|
||||
toolsToInvoke = ""; // $NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
j = 0;
|
||||
|
|
|
@ -138,7 +138,7 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
|
|||
superClass = targetPlatform.isExtensionTargetPlatform ? targetPlatform : targetPlatform.superClass;
|
||||
if (superClass != null) {
|
||||
// if (targetPlatform.superClassId != null) {
|
||||
superClassId = superClass.getId();// new String(targetPlatform.superClassId);
|
||||
superClassId = superClass.getId();// targetPlatform.superClassId;
|
||||
// }
|
||||
}
|
||||
setId(Id);
|
||||
|
@ -150,10 +150,10 @@ public class TargetPlatform extends BuildObject implements ITargetPlatform {
|
|||
|
||||
// Copy the remaining attributes
|
||||
if (targetPlatform.unusedChildren != null) {
|
||||
unusedChildren = new String(targetPlatform.unusedChildren);
|
||||
unusedChildren = targetPlatform.unusedChildren;
|
||||
}
|
||||
if (targetPlatform.errorParserIds != null) {
|
||||
errorParserIds = new String(targetPlatform.errorParserIds);
|
||||
errorParserIds = targetPlatform.errorParserIds;
|
||||
}
|
||||
if (targetPlatform.isAbstract != null) {
|
||||
isAbstract = targetPlatform.isAbstract;
|
||||
|
|
|
@ -793,7 +793,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
|
|||
*/
|
||||
@Override
|
||||
public String getMakefileName() {
|
||||
return new String(MAKEFILE_NAME);
|
||||
return MAKEFILE_NAME;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -75,10 +75,10 @@ public class BuildStepsTab extends AbstractCBuildPropertyTab {
|
|||
private Set<String> set4 = new TreeSet<String>();
|
||||
|
||||
private static final String[] rcbsApplicabilityRules = {
|
||||
new String(Messages.ResourceCustomBuildStepBlock_label_applicability_rule_override),
|
||||
// new String(ManagedBuilderMessages_getResourceString("ResourceCustomBuildStepBlock_label_applicability_rule_before")),
|
||||
// new String(ManagedBuilderMessages_getResourceString("ResourceCustomBuildStepBlock_label_applicability_rule_after")),
|
||||
new String(Messages.ResourceCustomBuildStepBlock_label_applicability_rule_disable),
|
||||
Messages.ResourceCustomBuildStepBlock_label_applicability_rule_override,
|
||||
// ManagedBuilderMessages_getResourceString("ResourceCustomBuildStepBlock_label_applicability_rule_before"),
|
||||
// ManagedBuilderMessages_getResourceString("ResourceCustomBuildStepBlock_label_applicability_rule_after"),
|
||||
Messages.ResourceCustomBuildStepBlock_label_applicability_rule_disable,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ExpectedStrings {
|
|||
int x;
|
||||
expStrings=new String[values.length];
|
||||
for (x=0;x<values.length;x++) {
|
||||
expStrings[x]=new String(values[x]);
|
||||
expStrings[x]=values[x];
|
||||
}
|
||||
foundStrings=new boolean[values.length];
|
||||
for (x=0;x<values.length;x++) {
|
||||
|
@ -62,7 +62,7 @@ public class ExpectedStrings {
|
|||
* and extra string
|
||||
*/
|
||||
|
||||
extraStrings.push(new String(current));
|
||||
extraStrings.push(current);
|
||||
extra=true;
|
||||
return(1);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2015 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2016 Wind River Systems, Inc. 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
|
||||
|
@ -248,7 +248,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
public final String getFilePath() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
return new String(fLocationResolver.getTranslationUnitPath());
|
||||
return fLocationResolver.getTranslationUnitPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2016 Wind River Systems, Inc. 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
|
||||
|
@ -32,7 +32,7 @@ class LocationCtxFile extends LocationCtxContainer {
|
|||
int parentOffset, int parentEndOffset, int sequenceNumber,
|
||||
ASTInclusionStatement inclusionStatement, boolean isSource) {
|
||||
super(parent, source, parentOffset, parentEndOffset, sequenceNumber);
|
||||
fFilename= new String(filename);
|
||||
fFilename= filename;
|
||||
fASTInclude= inclusionStatement;
|
||||
fIsSource= isSource;
|
||||
}
|
||||
|
@ -156,4 +156,4 @@ class LocationCtxFile extends LocationCtxContainer {
|
|||
public void setOffsetOfIncludeExport(int fOffsetOfIncludeExport) {
|
||||
this.fOffsetOfIncludeExport = fOffsetOfIncludeExport;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2016 Wind River Systems, Inc. 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
|
||||
|
@ -481,7 +481,7 @@ public class LocationMap implements ILocationResolver {
|
|||
@Override
|
||||
public String getContainingFilePath(int sequenceNumber) {
|
||||
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
||||
return new String(ctx.getFilePath());
|
||||
return ctx.getFilePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2014 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2016 IBM Corporation 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
|
||||
|
@ -603,7 +603,7 @@ outer:
|
|||
* @return the previous line, save in the working buffer.
|
||||
*/
|
||||
public String getPreviousLine() {
|
||||
return new String((previousLine) == null ? "" : previousLine); //$NON-NLS-1$
|
||||
return previousLine == null ? "" : previousLine; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ExpectedStrings {
|
|||
int x;
|
||||
expStrings=new String[values.length];
|
||||
for (x=0;x<values.length;x++) {
|
||||
expStrings[x]=new String(values[x]);
|
||||
expStrings[x]=values[x];
|
||||
}
|
||||
foundStrings=new boolean[values.length];
|
||||
for (x=0;x<values.length;x++) {
|
||||
|
@ -62,7 +62,7 @@ public class ExpectedStrings {
|
|||
* and extra string
|
||||
*/
|
||||
|
||||
extraStrings.push(new String(current));
|
||||
extraStrings.push(current);
|
||||
extra=true;
|
||||
return(1);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2015 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2016 IBM Corporation 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
|
||||
|
@ -605,7 +605,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
|||
if (i < tabWidth)
|
||||
indentPrefixes[i+1]= spaces + '\t';
|
||||
else
|
||||
indentPrefixes[i+1]= new String(spaces);
|
||||
indentPrefixes[i+1]= spaces;
|
||||
}
|
||||
|
||||
indentPrefixes[tabWidth + 1]= ""; //$NON-NLS-1$
|
||||
|
|
|
@ -128,18 +128,18 @@ public class MIBreakpoint {
|
|||
|
||||
public MIBreakpoint(MIBreakpoint other) {
|
||||
number = other.number;
|
||||
type = new String(other.type);
|
||||
disp = new String(other.disp);
|
||||
type = other.type;
|
||||
disp = other.disp;
|
||||
enabled = other.enabled;
|
||||
address = new String(other.address);
|
||||
func = new String(other.func);
|
||||
fullName = new String(other.fullName);
|
||||
file = new String(other.file);
|
||||
address = other.address;
|
||||
func = other.func;
|
||||
fullName = other.fullName;
|
||||
file = other.file;
|
||||
line = other.line;
|
||||
cond = new String(other.cond);
|
||||
cond = other.cond;
|
||||
times = other.times;
|
||||
exp = new String(other.exp);
|
||||
threadId = new String(other.threadId);
|
||||
exp = other.exp;
|
||||
threadId = other.threadId;
|
||||
ignore = other.ignore;
|
||||
commands = other.commands;
|
||||
passcount= other.passcount;
|
||||
|
|
Loading…
Add table
Reference in a new issue