mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-27 19:05:38 +02:00
Code maintenance for refactoring by Emanuel Graf, bug 234348.
This commit is contained in:
parent
796acfa15d
commit
0417976c9e
8 changed files with 19 additions and 23 deletions
|
@ -73,7 +73,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTest {
|
|||
info.setReplaceDuplicates(replaceDuplicates);
|
||||
if(info.getInScopeDeclaredVariable() == null){
|
||||
if(returnValue) {
|
||||
info.setReturnVariable(info.getAllAfterUsedNames().elementAt(returnParameterIndex));
|
||||
info.setReturnVariable(info.getAllAfterUsedNames().get(returnParameterIndex));
|
||||
}
|
||||
} else {
|
||||
info.setReturnVariable( info.getInScopeDeclaredVariable() );
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -326,8 +326,8 @@ public abstract class CRefactoring extends Refactoring {
|
|||
return fIndex;
|
||||
}
|
||||
|
||||
protected Vector<IASTName> findAllMarkedNames() {
|
||||
final Vector<IASTName> namesVector = new Vector<IASTName>();
|
||||
protected ArrayList<IASTName> findAllMarkedNames() {
|
||||
final ArrayList<IASTName> namesVector = new ArrayList<IASTName>();
|
||||
|
||||
unit.accept(new CPPASTVisitor() {
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -73,11 +72,11 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
|
|||
}
|
||||
|
||||
private IASTName getSelectedName() {
|
||||
Vector<IASTName> names = findAllMarkedNames();
|
||||
ArrayList<IASTName> names = findAllMarkedNames();
|
||||
if (names.size() < 1) {
|
||||
return null;
|
||||
}
|
||||
return names.lastElement();
|
||||
return names.get(names.size()-1);
|
||||
}
|
||||
|
||||
protected void findDeclarations() {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -78,15 +78,12 @@ public class HideMethodRefactoring extends CRefactoring {
|
|||
if(isProgressMonitorCanceld(sm, initStatus)) return initStatus;
|
||||
|
||||
IASTName name;
|
||||
Vector<IASTName> names = findAllMarkedNames();
|
||||
if(names.size() > 1) {
|
||||
name = names.lastElement();
|
||||
} else if (names.size() < 1) {
|
||||
ArrayList<IASTName> names = findAllMarkedNames();
|
||||
if (names.size() < 1) {
|
||||
initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected);
|
||||
return initStatus;
|
||||
}else {
|
||||
name = names.get(0);
|
||||
}
|
||||
name = names.get(names.size()-1);
|
||||
sm.worked(1);
|
||||
if(isProgressMonitorCanceld(sm, initStatus)) return initStatus;
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -105,20 +105,20 @@ public class MethodDefinitionInsertLocationFinder {
|
|||
* @return all declarations, sorted in reverse order
|
||||
*/
|
||||
private static Collection<IASTSimpleDeclaration> getAllPreviousIASTSimpleDeclarationsFromClassInReverseOrder(IASTDeclaration[] declarations, IASTFileLocation methodPosition) {
|
||||
Vector<IASTSimpleDeclaration> allIASTSimpleDeclarations = new Vector<IASTSimpleDeclaration>();
|
||||
ArrayList<IASTSimpleDeclaration> allIASTSimpleDeclarations = new ArrayList<IASTSimpleDeclaration>();
|
||||
for (IASTDeclaration decl : declarations) {
|
||||
if (decl.getFileLocation().getStartingLineNumber() >= methodPosition.getStartingLineNumber()) {
|
||||
return allIASTSimpleDeclarations;
|
||||
}
|
||||
if (isMemberFunctionDeclaration(decl)) {
|
||||
allIASTSimpleDeclarations.insertElementAt((IASTSimpleDeclaration) decl, 0);
|
||||
allIASTSimpleDeclarations.add(0, (IASTSimpleDeclaration) decl);
|
||||
}
|
||||
}
|
||||
return allIASTSimpleDeclarations;
|
||||
}
|
||||
|
||||
private static Collection<IASTSimpleDeclaration> getAllFollowingIASTSimpleDeclarationsFromClass(IASTDeclaration[] declarations, IASTFileLocation methodPosition) {
|
||||
Vector<IASTSimpleDeclaration> allIASTSimpleDeclarations = new Vector<IASTSimpleDeclaration>();
|
||||
ArrayList<IASTSimpleDeclaration> allIASTSimpleDeclarations = new ArrayList<IASTSimpleDeclaration>();
|
||||
|
||||
for (IASTDeclaration decl : declarations) {
|
||||
if (isMemberFunctionDeclaration(decl) && decl.getFileLocation().getStartingLineNumber() > methodPosition.getStartingLineNumber() ) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public class NodeHelper {
|
|||
return context;
|
||||
}
|
||||
|
||||
public static IASTCompoundStatement findCompoundStatementInParent(IASTNode node) {
|
||||
public static IASTCompoundStatement findCompoundStatementInAncestors(IASTNode node) {
|
||||
while(node != null){
|
||||
if (node instanceof IASTCompoundStatement) {
|
||||
return (IASTCompoundStatement) node;
|
||||
|
@ -138,7 +138,7 @@ public class NodeHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static IASTCompositeTypeSpecifier findEnclosingClass(IASTNode node) {
|
||||
public static IASTCompositeTypeSpecifier findClassInAncestors(IASTNode node) {
|
||||
while(!(node instanceof IASTCompositeTypeSpecifier)){
|
||||
if(node instanceof IASTTranslationUnit) {
|
||||
return null;
|
||||
|
@ -148,7 +148,7 @@ public class NodeHelper {
|
|||
return (IASTCompositeTypeSpecifier) node;
|
||||
}
|
||||
|
||||
public static IASTFunctionDefinition findFunctionDefinition(IASTNode node) {
|
||||
public static IASTFunctionDefinition findFunctionDefinitionInAncestors(IASTNode node) {
|
||||
while(node != null){
|
||||
if (node instanceof IASTFunctionDefinition) {
|
||||
return (IASTFunctionDefinition) node;
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Helps to generate new unsused names.
|
||||
* Helps to generate new unused names.
|
||||
*
|
||||
* @author Mirko Stocker
|
||||
*
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
|||
import org.eclipse.cdt.internal.ui.refactoring.Container;
|
||||
|
||||
/**
|
||||
* Helper class to suport operations conserning a selection.
|
||||
* Helper class to support operations concerning a selection.
|
||||
*
|
||||
* @author Mirko Stocker, Lukas Felber
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue