1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Use ArrayList instead of Vector.

This commit is contained in:
Sergey Prigogin 2012-01-09 15:45:21 -08:00
parent ecd14f70f8
commit 9b83d66132
8 changed files with 79 additions and 89 deletions

View file

@ -13,9 +13,9 @@ package org.eclipse.cdt.core.parser.tests.rewrite;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Vector;
import org.eclipse.cdt.core.tests.BaseTestFramework; import org.eclipse.cdt.core.tests.BaseTestFramework;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -38,8 +38,8 @@ public abstract class RewriteBaseTest extends BaseTestFramework implements ILogL
protected RewriteBaseTest(String name) { protected RewriteBaseTest(String name) {
super(name); super(name);
} }
public RewriteBaseTest(String name, Vector<TestSourceFile> files) { public RewriteBaseTest(String name, List<TestSourceFile> files) {
super(name); super(name);
for (TestSourceFile file : files) { for (TestSourceFile file : files) {
fileMap.put(file.getName(), file); fileMap.put(file.getName(), file);

View file

@ -18,7 +18,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -59,7 +59,7 @@ public class RewriteTester extends TestSuite {
private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception { private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception {
String line; String line;
Vector<TestSourceFile> files = new Vector<TestSourceFile>(); List<TestSourceFile> files = new ArrayList<TestSourceFile>();
TestSourceFile actFile = null; TestSourceFile actFile = null;
MatcherState matcherState = MatcherState.skip; MatcherState matcherState = MatcherState.skip;
ArrayList<RewriteBaseTest> testCases = new ArrayList<RewriteBaseTest>(); ArrayList<RewriteBaseTest> testCases = new ArrayList<RewriteBaseTest>();
@ -72,7 +72,7 @@ public class RewriteTester extends TestSuite {
if (!bevorFirstTest) { if (!bevorFirstTest) {
RewriteBaseTest test = createTestClass(className, testName, files); RewriteBaseTest test = createTestClass(className, testName, files);
testCases.add(test); testCases.add(test);
files = new Vector<TestSourceFile>(); files = new ArrayList<TestSourceFile>();
className = null; className = null;
testName = null; testName = null;
} }
@ -114,17 +114,11 @@ public class RewriteTester extends TestSuite {
} }
private static RewriteBaseTest createTestClass(String className, String testName, private static RewriteBaseTest createTestClass(String className, String testName,
Vector<TestSourceFile> files) throws Exception { List<TestSourceFile> files) throws Exception {
try { try {
Class<?> refClass = Class.forName(className); Class<?> refClass = Class.forName(className);
Class<?> paratypes[] = new Class[2]; Constructor<?> ct = refClass.getConstructor(new Class[] { String.class, List.class });
paratypes[0] = testName.getClass(); RewriteBaseTest test = (RewriteBaseTest) ct.newInstance(new Object[] { testName, files });
paratypes[1] = files.getClass();
Constructor<?> ct = refClass.getConstructor(paratypes);
Object arglist[] = new Object[2];
arglist[0] = testName;
arglist[1] = files;
RewriteBaseTest test = (RewriteBaseTest) ct.newInstance(arglist);
for (TestSourceFile file : files) { for (TestSourceFile file : files) {
TextSelection sel = file.getSelection(); TextSelection sel = file.getSelection();
if (sel != null) { if (sel != null) {

View file

@ -15,7 +15,6 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Vector;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -85,7 +84,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
private static final String TRAILING_COMMENT_TITLE = "<<<=== Trailing Comment Test Section ===>>>"; //$NON-NLS-1$ private static final String TRAILING_COMMENT_TITLE = "<<<=== Trailing Comment Test Section ===>>>"; //$NON-NLS-1$
private static final String FREESTANDING_COMMENT_TITLE = "<<<=== Freestanding Comment Test Section ===>>>"; //$NON-NLS-1$ private static final String FREESTANDING_COMMENT_TITLE = "<<<=== Freestanding Comment Test Section ===>>>"; //$NON-NLS-1$
public CommentHandlingTest(String name, Vector<TestSourceFile> files) { public CommentHandlingTest(String name, List<TestSourceFile> files) {
super(name, files); super(name, files);
} }

View file

@ -22,8 +22,8 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector;
/** /**
* Startup class for Eclipse. Creates a class loader using * Startup class for Eclipse. Creates a class loader using
* supplied URL of platform installation, loads and calls * supplied URL of platform installation, loads and calls
@ -181,14 +181,14 @@ protected Object basicRun(String[] args) throws Exception {
private String[] getArrayFromList(String prop) { private String[] getArrayFromList(String prop) {
if (prop == null || prop.trim().equals("")) if (prop == null || prop.trim().equals(""))
return new String[0]; return new String[0];
Vector list = new Vector(); List<String> list = new ArrayList<String>();
StringTokenizer tokens = new StringTokenizer(prop, ","); StringTokenizer tokens = new StringTokenizer(prop, ",");
while (tokens.hasMoreTokens()) { while (tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim(); String token = tokens.nextToken().trim();
if (!token.equals("")) if (!token.equals(""))
list.addElement(token); list.add(token);
} }
return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[0]); return list.toArray(new String[list.size()]);
} }
/** /**
* Creates and returns a platform <code>BootLoader</code> which can be used to start * Creates and returns a platform <code>BootLoader</code> which can be used to start
@ -404,10 +404,10 @@ public static void endSplash() {
* @exception Exception thrown if a problem occurs during launching * @exception Exception thrown if a problem occurs during launching
*/ */
public static void main(String argString) throws Exception { public static void main(String argString) throws Exception {
Vector list = new Vector(5); List<String> list = new ArrayList<String>(5);
for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();) for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();)
list.addElement(tokens.nextElement()); list.add((String) tokens.nextElement());
main((String[]) list.toArray(new String[list.size()])); main(list.toArray(new String[list.size()]));
} }
/** /**

View file

@ -14,18 +14,17 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector;
/** /**
* Application is responsible for calling core launch api * Application is responsible for calling core launch api
*/ */
public class NewMain extends Main { public class NewMain extends Main {
private static final String DEFAULT_APPLICATION= "org.eclipse.ui.workbench"; private static final String DEFAULT_APPLICATION= "org.eclipse.ui.workbench";
public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug) throws IOException { public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug) throws IOException {
this.application= application; this.application= application;
this.location= location; this.location= location;
@ -44,17 +43,16 @@ public class NewMain extends Main {
System.exit(0); System.exit(0);
} }
/** /**
* Run this launcher with the arguments specified in the given string. * Run this launcher with the arguments specified in the given string.
* This is a short cut method for people running the launcher from * This is a short cut method for people running the launcher from
* a scrapbook (i.e., swip-and-doit facility). * a scrapbook (i.e., swip-and-doit facility).
*/ */
public static void main(String argString) throws Exception { public static void main(String argString) throws Exception {
Vector list= new Vector(5); List<String> list= new ArrayList<String>(5);
for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();) for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();)
list.addElement(tokens.nextElement()); list.add((String) tokens.nextElement());
main((String[]) list.toArray(new String[list.size()])); main(list.toArray(new String[list.size()]));
} }
public static String getLocationFromProperties(String key) { public static String getLocationFromProperties(String key) {

View file

@ -12,7 +12,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler; package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
import java.util.Vector; import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTComment;
@ -63,13 +64,13 @@ public class NodeCommenter {
protected ASTVisitor visitor; protected ASTVisitor visitor;
protected CommentHandler commHandler; protected CommentHandler commHandler;
protected NodeCommentMap commentMap; protected NodeCommentMap commentMap;
protected Vector<IASTNode> children; protected List<IASTNode> children;
public NodeCommenter(ASTVisitor visitor, CommentHandler commHandler, NodeCommentMap commentMap) { public NodeCommenter(ASTVisitor visitor, CommentHandler commHandler, NodeCommentMap commentMap) {
this.visitor = visitor; this.visitor = visitor;
this.commHandler = commHandler; this.commHandler = commHandler;
this.commentMap = commentMap; this.commentMap = commentMap;
this.children = new Vector<IASTNode>(); this.children = new ArrayList<IASTNode>();
} }
protected void writeNodeList(IASTNode[] nodes) { protected void writeNodeList(IASTNode[] nodes) {

View file

@ -17,7 +17,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
@ -434,7 +433,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
} }
} }
final Vector<IASTNode> initTrail = getTrail(nodesToRewriteWithoutComments); final List<IASTNode> initTrail = getTrail(nodesToRewriteWithoutComments);
final String title; final String title;
if (contextType == MethodContext.ContextType.METHOD) { if (contextType == MethodContext.ContextType.METHOD) {
title = Messages.ExtractFunctionRefactoring_CreateMethodCall; title = Messages.ExtractFunctionRefactoring_CreateMethodCall;
@ -448,8 +447,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
} }
} }
protected Vector<IASTNode> getTrail(List<IASTNode> stmts) { protected List<IASTNode> getTrail(List<IASTNode> stmts) {
final Vector<IASTNode> trail = new Vector<IASTNode>(); final List<IASTNode> trail = new ArrayList<IASTNode>();
nameTrail = new HashMap<String, Integer>(); nameTrail = new HashMap<String, Integer>();
final Container<Integer> trailCounter = new Container<Integer>(NULL_INTEGER); final Container<Integer> trailCounter = new Container<Integer>(NULL_INTEGER);
@ -465,8 +464,9 @@ public class ExtractFunctionRefactoring extends CRefactoring {
trail.add(node); trail.add(node);
return PROCESS_SKIP; return PROCESS_SKIP;
} else if (node instanceof IASTName) { } else if (node instanceof IASTName) {
if (node instanceof ICPPASTConversionName && node instanceof ICPPASTOperatorName if (node instanceof ICPPASTConversionName &&
&& node instanceof ICPPASTTemplateId) { node instanceof ICPPASTOperatorName &&
node instanceof ICPPASTTemplateId) {
trail.add(node); trail.add(node);
return super.visitAll(node); return super.visitAll(node);
} else { } else {
@ -483,8 +483,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
} }
trailName.setNameNumber(actCount); trailName.setNameNumber(actCount);
if (info.getReturnVariable() != null if (info.getReturnVariable() != null &&
&& info.getReturnVariable().getName().getRawSignature().equals( info.getReturnVariable().getName().getRawSignature().equals(
name.getRawSignature())) { name.getRawSignature())) {
returnNumber.setObject(Integer.valueOf(actCount)); returnNumber.setObject(Integer.valueOf(actCount));
} }
@ -498,13 +498,12 @@ public class ExtractFunctionRefactoring extends CRefactoring {
} }
} }
}); });
} }
return trail; return trail;
} }
protected boolean isStatementInTrail(IASTStatement stmt, final Vector<IASTNode> trail, IIndex index) { protected boolean isStatementInTrail(IASTStatement stmt, final List<IASTNode> trail, IIndex index) {
final Container<Boolean> same = new Container<Boolean>(Boolean.TRUE); final Container<Boolean> same = new Container<Boolean>(Boolean.TRUE);
final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index); final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index);
@ -591,8 +590,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
return true; return true;
} }
private void addMethod(IASTName astMethodName, MethodContext context, private void addMethod(IASTName astMethodName, MethodContext context, ASTRewrite rewriter,
ASTRewrite rewriter, IASTNode insertpoint, TextEditGroup group) { IASTNode insertpoint, TextEditGroup group) {
ICPPASTQualifiedName qname = new CPPASTQualifiedName(); ICPPASTQualifiedName qname = new CPPASTQualifiedName();
if (context.getType() == ContextType.METHOD) { if (context.getType() == ContextType.METHOD) {
if (context.getMethodQName() != null) { if (context.getMethodQName() != null) {
@ -609,10 +608,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTDeclSpecifier returnType = getReturnType(); IASTDeclSpecifier returnType = getReturnType();
func.setDeclSpecifier(returnType); func.setDeclSpecifier(returnType);
IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper IASTStandardFunctionDeclarator createdFunctionDeclarator =
.createFunctionDeclarator(qname, info.getDeclarator(), info extractedFunctionConstructionHelper.createFunctionDeclarator(qname,
.getReturnVariable(), container.getNodesToWrite(), info info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
.getAllUsedNames(), ast.getASTNodeFactory()); info.getAllUsedNames(), ast.getASTNodeFactory());
func.setDeclarator(createdFunctionDeclarator); func.setDeclarator(createdFunctionDeclarator);
IASTCompoundStatement compound = new CPPASTCompoundStatement(); IASTCompoundStatement compound = new CPPASTCompoundStatement();
@ -623,8 +622,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
CPPASTTemplateDeclaration templateDeclaration = new CPPASTTemplateDeclaration(); CPPASTTemplateDeclaration templateDeclaration = new CPPASTTemplateDeclaration();
templateDeclaration.setParent(ast); templateDeclaration.setParent(ast);
for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) { for (ICPPASTTemplateParameter param : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) {
templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations)); templateDeclaration.addTemplateParameter(param.copy(CopyStyle.withLocations));
} }
templateDeclaration.setDeclaration(func); templateDeclaration.setDeclaration(func);
@ -664,8 +663,8 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private IASTDeclSpecifier getReturnType() { private IASTDeclSpecifier getReturnType() {
IASTNode firstNodeToWrite = container.getNodesToWrite().get(0); IASTNode firstNodeToWrite = container.getNodesToWrite().get(0);
NameInformation returnVariable = info.getReturnVariable(); NameInformation returnVariable = info.getReturnVariable();
return extractedFunctionConstructionHelper.determineReturnType(firstNodeToWrite,
return extractedFunctionConstructionHelper.determineReturnType(firstNodeToWrite, returnVariable); returnVariable);
} }
protected IASTNode getMethodCall(IASTName astMethodName, protected IASTNode getMethodCall(IASTName astMethodName,
@ -678,30 +677,28 @@ public class ExtractFunctionRefactoring extends CRefactoring {
idExpression.setName(astMethodName); idExpression.setName(astMethodName);
List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>(); List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>();
Vector<IASTName> declarations = new Vector<IASTName>(); List<IASTName> declarations = new ArrayList<IASTName>();
IASTName retName = null; IASTName retName = null;
boolean theRetName = false; boolean theRetName = false;
for (NameInformation nameInfo : myContainer.getNames()) { for (NameInformation nameInfo : myContainer.getNames()) {
Integer trailSeqNumber = trailNameTable.get(nameInfo.getDeclaration().getRawSignature()); Integer trailSeqNumber = trailNameTable.get(nameInfo.getDeclaration().getRawSignature());
String orgName = null; String origName = null;
for (Entry<String, Integer> entry : similarNameTable.entrySet()) { for (Entry<String, Integer> entry : similarNameTable.entrySet()) {
if (entry.getValue().equals(trailSeqNumber)) { if (entry.getValue().equals(trailSeqNumber)) {
orgName = entry.getKey(); origName = entry.getKey();
if (info.getReturnVariable() != null if (info.getReturnVariable() != null &&
&& trailSeqNumber.equals(returnNumber.getObject())) { trailSeqNumber.equals(returnNumber.getObject())) {
theRetName = true; theRetName = true;
} }
} }
} }
if (orgName != null) { if (origName != null) {
boolean found = false; boolean found = false;
for (NameInformation simNameInfo : mySimilarContainer.getNames()) { for (NameInformation simNameInfo : mySimilarContainer.getNames()) {
if (orgName.equals(simNameInfo.getDeclaration() if (origName.equals(simNameInfo.getDeclaration().getRawSignature())) {
.getRawSignature())) { addParameterIfPossible(args, declarations, simNameInfo);
addAParameterIfPossible(args, declarations,
simNameInfo);
found = true; found = true;
if (theRetName) { if (theRetName) {
@ -715,7 +712,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (!found) { if (!found) {
// should be a field, use the old name // should be a field, use the old name
IASTIdExpression expression = new CPPASTIdExpression(); IASTIdExpression expression = new CPPASTIdExpression();
CPPASTName fieldName = new CPPASTName(orgName.toCharArray()); CPPASTName fieldName = new CPPASTName(origName.toCharArray());
expression.setName(fieldName); expression.setName(fieldName);
args.add(expression); args.add(expression);
@ -763,7 +760,6 @@ public class ExtractFunctionRefactoring extends CRefactoring {
decl.setDeclSpecifier(orgDecl.getDeclSpecifier().copy(CopyStyle.withLocations)); decl.setDeclSpecifier(orgDecl.getDeclSpecifier().copy(CopyStyle.withLocations));
IASTDeclarator declarator = new CPPASTDeclarator(); IASTDeclarator declarator = new CPPASTDeclarator();
declarator.setName(retname); declarator.setName(retname);
for (IASTPointerOperator pointer : orgDecl.getDeclarators()[0].getPointerOperators()) { for (IASTPointerOperator pointer : orgDecl.getDeclarators()[0].getPointerOperators()) {
@ -792,31 +788,30 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private IASTNode getReturnAssignment(IASTExpressionStatement stmt, private IASTNode getReturnAssignment(IASTExpressionStatement stmt,
IASTExpression callExpression) { IASTExpression callExpression) {
IASTNode node = container.getNodesToWrite().get(0); IASTNode node = container.getNodesToWrite().get(0);
return extractedFunctionConstructionHelper.createReturnAssignment(node, return extractedFunctionConstructionHelper.createReturnAssignment(node, stmt, callExpression);
stmt, callExpression);
} }
private IASTSimpleDeclaration getDeclaration(IASTName name) { private IASTSimpleDeclaration getDeclaration(IASTName name) {
IASTSimpleDeclaration simpleDecl = new CPPASTSimpleDeclaration(); IASTSimpleDeclaration simpleDecl = new CPPASTSimpleDeclaration();
IASTStandardFunctionDeclarator declarator = IASTStandardFunctionDeclarator declarator =
extractedFunctionConstructionHelper.createFunctionDeclarator(name, extractedFunctionConstructionHelper.createFunctionDeclarator(name,
info.getDeclarator(), info.getReturnVariable(), info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
container.getNodesToWrite(), info.getAllUsedNames(), ast.getASTNodeFactory()); info.getAllUsedNames(), ast.getASTNodeFactory());
simpleDecl.addDeclarator(declarator); simpleDecl.addDeclarator(declarator);
return simpleDecl; return simpleDecl;
} }
private IASTSimpleDeclaration getDeclaration(ModificationCollector collector,IASTName name) { private IASTSimpleDeclaration getDeclaration(ModificationCollector collector, IASTName name) {
IASTDeclSpecifier declSpec = getReturnType(); IASTDeclSpecifier declSpec = getReturnType();
IASTSimpleDeclaration simpleDecl = factory.newSimpleDeclaration(declSpec); IASTSimpleDeclaration simpleDecl = factory.newSimpleDeclaration(declSpec);
if (info.isVirtual() && declSpec instanceof ICPPASTDeclSpecifier) { if (info.isVirtual() && declSpec instanceof ICPPASTDeclSpecifier) {
((ICPPASTDeclSpecifier)declSpec).setVirtual(true); ((ICPPASTDeclSpecifier) declSpec).setVirtual(true);
} }
simpleDecl.setParent(ast); simpleDecl.setParent(ast);
IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper IASTStandardFunctionDeclarator declarator =
.createFunctionDeclarator(name, info.getDeclarator(), info extractedFunctionConstructionHelper.createFunctionDeclarator(name,
.getReturnVariable(), container.getNodesToWrite(), info info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
.getAllUsedNames(), ast.getASTNodeFactory()); info.getAllUsedNames(), ast.getASTNodeFactory());
simpleDecl.addDeclarator(declarator); simpleDecl.addDeclarator(declarator);
return simpleDecl; return simpleDecl;
} }
@ -852,17 +847,17 @@ public class ExtractFunctionRefactoring extends CRefactoring {
public List<IASTInitializerClause> getCallParameters() { public List<IASTInitializerClause> getCallParameters() {
List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>(); List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>();
Vector<IASTName> declarations = new Vector<IASTName>(); List<IASTName> declarations = new ArrayList<IASTName>();
for (NameInformation nameInf : container.getNames()) { for (NameInformation nameInfo : container.getNames()) {
addAParameterIfPossible(args, declarations, nameInf); addParameterIfPossible(args, declarations, nameInfo);
} }
return args; return args;
} }
private void addAParameterIfPossible(List<IASTInitializerClause> args, private void addParameterIfPossible(List<IASTInitializerClause> args,
Vector<IASTName> declarations, NameInformation nameInf) { List<IASTName> declarations, NameInformation nameInfо) {
if (!nameInf.isDeclarationInScope()) { if (!nameInfо.isDeclarationInScope()) {
IASTName declaration = nameInf.getDeclaration(); IASTName declaration = nameInfо.getDeclaration();
if (!declarations.contains(declaration)) { if (!declarations.contains(declaration)) {
declarations.add(declaration); declarations.add(declaration);
IASTIdExpression expression = new CPPASTIdExpression(); IASTIdExpression expression = new CPPASTIdExpression();
@ -875,7 +870,9 @@ public class ExtractFunctionRefactoring extends CRefactoring {
@Override @Override
protected RefactoringDescriptor getRefactoringDescriptor() { protected RefactoringDescriptor getRefactoringDescriptor() {
Map<String, String> arguments = getArgumentMap(); Map<String, String> arguments = getArgumentMap();
RefactoringDescriptor desc = new ExtractFunctionRefactoringDescription(project.getProject().getName(), "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$ RefactoringDescriptor desc =
new ExtractFunctionRefactoringDescription(project.getProject().getName(),
"Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$
return desc; return desc;
} }
@ -884,8 +881,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString());
arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName()); arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName());
arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString()); arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY,
arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES, Boolean.toString(info.isReplaceDuplicates())); info.getVisibility().toString());
arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES,
Boolean.toString(info.isReplaceDuplicates()));
return arguments; return arguments;
} }
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.text.edits.TextEditGroup; import org.eclipse.text.edits.TextEditGroup;
@ -32,7 +31,7 @@ import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
final class SimilarFinderVisitor extends ASTVisitor { final class SimilarFinderVisitor extends ASTVisitor {
private final ExtractFunctionRefactoring refactoring; private final ExtractFunctionRefactoring refactoring;
private final Vector<IASTNode> trail; private final List<IASTNode> trail;
private final IASTName name; private final IASTName name;
private final List<IASTNode> statements; private final List<IASTNode> statements;
private int statementCount; private int statementCount;
@ -42,7 +41,7 @@ final class SimilarFinderVisitor extends ASTVisitor {
private final ModificationCollector collector; private final ModificationCollector collector;
SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, ModificationCollector collector, SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, ModificationCollector collector,
Vector<IASTNode> trail, IFile file, IASTName name, List<IASTNode> statements, List<IASTNode> trail, IFile file, IASTName name, List<IASTNode> statements,
String title) { String title) {
this.refactoring = refactoring; this.refactoring = refactoring;
this.trail = trail; this.trail = trail;