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

Fixed unnecessary passing parameters by reference.

This commit is contained in:
Sergey Prigogin 2012-01-16 22:18:59 -08:00
parent 91866c57a2
commit 9b5c46e407
11 changed files with 161 additions and 143 deletions

View file

@ -73,20 +73,20 @@ public class ExtractFunctionRefactoringTest extends RefactoringTest {
private void setValues(ExtractFunctionInformation info) {
info.setMethodName(methodName);
info.setReplaceDuplicates(replaceDuplicates);
if (info.getInScopeDeclaredVariable() == null) {
if (info.getMandatoryReturnVariable() == null) {
if (returnValue) {
info.setReturnVariable(info.getAllAfterUsedNames().get(returnParameterIndex));
info.getAllAfterUsedNames().get(returnParameterIndex).setUserSetIsReference(false);
info.setReturnVariable(info.getNamesUsedAfter().get(returnParameterIndex));
info.getNamesUsedAfter().get(returnParameterIndex).setUserSetIsReference(false);
}
} else {
info.setReturnVariable(info.getInScopeDeclaredVariable());
info.setReturnVariable(info.getMandatoryReturnVariable());
}
info.setVisibility(visibility);
info.setVirtual(virtual);
for (NameInformation name : info.getAllAfterUsedNames()) {
for (NameInformation name : info.getNamesUsedAfter()) {
if (!name.isUserSetIsReturnValue()) {
name.setUserSetIsReference(name.isReference());
name.setUserSetIsReference(name.isOutput());
}
}
}

View file

@ -12,7 +12,9 @@
package org.eclipse.cdt.internal.ui.refactoring;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
@ -51,7 +53,7 @@ public class NodeContainer {
public final NameInformation NULL_NAME_INFORMATION = new NameInformation(new CPPASTName());
private final List<IASTNode> nodes;
private final List<NameInformation> names;
private List<NameInformation> names;
public class NameInformation {
private IASTName name;
@ -59,7 +61,7 @@ public class NodeContainer {
private final List<IASTName> references;
private List<IASTName> referencesAfterCached;
private int lastCachedReferencesHash;
private boolean isReference;
private boolean isOutput;
private boolean isReturnValue;
private boolean isConst;
private boolean isWriteAccess;
@ -117,8 +119,8 @@ public class NodeContainer {
return referencesAfterCached;
}
public boolean isUsedAfterReferences() {
return getReferencesAfterSelection().size() > 0;
public boolean isReferencedAfterSelection() {
return !getReferencesAfterSelection().isEmpty();
}
public IASTParameterDeclaration getParameterDeclaration(boolean isReference,
@ -195,7 +197,7 @@ public class NodeContainer {
return writer.write(declSpec);
}
public boolean isDeclarationExtracted() {
public boolean isDeclaredInSelection() {
if (declaration != null && declaration.toCharArray().length > 0) {
int declOffset = declaration.getFileLocation().getNodeOffset();
return declOffset >= getStartOffset() && declOffset <= getEndOffset();
@ -205,15 +207,15 @@ public class NodeContainer {
@Override
public String toString() {
return name.toString() + ": " + (isDeclarationExtracted() ? "with declaration" : "without declaration"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
return name.toString() + (isDeclaredInSelection() ? " (declared inside)" : ""); //$NON-NLS-1$//$NON-NLS-2$
}
public boolean isReference() {
return isReference;
public boolean isOutput() {
return isOutput;
}
public void setReference(boolean isReference) {
this.isReference = isReference;
public void setOutput(boolean output) {
this.isOutput = output;
}
public boolean isReturnValue() {
@ -268,7 +270,6 @@ public class NodeContainer {
public NodeContainer() {
super();
nodes = new ArrayList<IASTNode>();
names = new ArrayList<NameInformation>();
}
public final int size() {
@ -283,7 +284,11 @@ public class NodeContainer {
nodes.add(node);
}
public void findAllNames() {
private void findAllNames() {
if (names != null) {
return;
}
names = new ArrayList<NameInformation>();
for (IASTNode node : nodes) {
node.accept(new ASTVisitor() {
{
@ -294,8 +299,7 @@ public class NodeContainer {
public int visit(IASTName name) {
IBinding bind = name.resolveBinding();
if (bind instanceof ICPPBinding
&& !(bind instanceof ICPPTemplateTypeParameter)) {
if (bind instanceof ICPPBinding && !(bind instanceof ICPPTemplateTypeParameter)) {
ICPPBinding cppBind = (ICPPBinding) bind;
try {
if (!cppBind.isGloballyQualified()) {
@ -326,35 +330,33 @@ public class NodeContainer {
});
}
for (NameInformation nameInf : names) {
IASTName name = nameInf.getName();
for (NameInformation nameInfo : names) {
IASTName name = nameInfo.getName();
IASTTranslationUnit unit = name.getTranslationUnit();
IASTName[] decls = unit.getDeclarationsInAST(name.resolveBinding());
for (IASTName declaration : decls) {
nameInf.setDeclaration(declaration);
nameInfo.setDeclaration(declaration);
}
if (nameInfo.isReferencedAfterSelection()) {
nameInfo.setOutput(true);
}
}
}
/*
* Returns all local names in the selection which will be used after the
* selection expected the ones which are pointers
* Returns all local names in the selection which are referenced after the selection.
*/
public List<NameInformation> getAllAfterUsedNames() {
ArrayList<IASTName> declarations = new ArrayList<IASTName>();
ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
public List<NameInformation> getNamesUsedAfter() {
findAllNames();
if (names.size() <= 0) {
findAllNames();
}
Set<IASTName> declarations = new HashSet<IASTName>();
List<NameInformation> usedAfter = new ArrayList<NameInformation>();
for (NameInformation nameInf : names) {
if (!declarations.contains(nameInf.getDeclaration())) {
declarations.add(nameInf.getDeclaration());
if (nameInf.isUsedAfterReferences()) {
usedAfter.add(nameInf);
nameInf.setReference(true);
for (NameInformation nameInfo : names) {
if (declarations.add(nameInfo.getDeclaration())) {
if (nameInfo.isReferencedAfterSelection()) {
usedAfter.add(nameInfo);
}
}
}
@ -362,15 +364,16 @@ public class NodeContainer {
return usedAfter;
}
public List<NameInformation> getAllAfterUsedNamesChoosenByUser() {
ArrayList<IASTName> declarations = new ArrayList<IASTName>();
ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
public List<NameInformation> getNamesUsedAfterChoosenByUser() {
findAllNames();
for (NameInformation nameInf : names) {
if (!declarations.contains(nameInf.getDeclaration())) {
declarations.add(nameInf.getDeclaration());
if (nameInf.isUserSetIsReference() || nameInf.isUserSetIsReturnValue()) {
usedAfter.add(nameInf);
Set<IASTName> declarations = new HashSet<IASTName>();
List<NameInformation> usedAfter = new ArrayList<NameInformation>();
for (NameInformation nameInfo : names) {
if (declarations.add(nameInfo.getDeclaration())) {
if (nameInfo.isUserSetIsReference() || nameInfo.isUserSetIsReturnValue()) {
usedAfter.add(nameInfo);
}
}
}
@ -379,21 +382,18 @@ public class NodeContainer {
}
public List<NameInformation> getUsedNamesUnique() {
ArrayList<IASTName> declarations = new ArrayList<IASTName>();
ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
findAllNames();
if (names.size() <= 0) {
findAllNames();
}
Set<IASTName> declarations = new HashSet<IASTName>();
List<NameInformation> usedAfter = new ArrayList<NameInformation>();
for (NameInformation nameInf : names) {
if (!declarations.contains(nameInf.getDeclaration())) {
declarations.add(nameInf.getDeclaration());
usedAfter.add(nameInf);
for (NameInformation nameInfo : names) {
if (declarations.add(nameInfo.getDeclaration())) {
usedAfter.add(nameInfo);
} else {
for (NameInformation nameInformation : usedAfter) {
if (nameInf.isWriteAccess()
&& nameInf.getDeclaration() == nameInformation.getDeclaration()) {
if (nameInfo.isWriteAccess() &&
nameInfo.getDeclaration() == nameInformation.getDeclaration()) {
nameInformation.setWriteAccess(true);
}
}
@ -403,24 +403,21 @@ public class NodeContainer {
return usedAfter;
}
/*
* Returns all local names in the selection which will be used after the
* selection expected the ones which are pointers
* XXX Was soll dieser Kommentar aussagen? --Mirko
/**
* Returns all variables declared in the selection, which will are referenced after
* the selection.
*/
public List<NameInformation> getAllDeclaredInScope() {
ArrayList<IASTName> declarations = new ArrayList<IASTName>();
ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
public List<NameInformation> getReturnValueCandidates() {
Set<IASTName> declarations = new HashSet<IASTName>();
List<NameInformation> usedAfter = new ArrayList<NameInformation>();
for (NameInformation nameInfo : names) {
if (nameInfo.isDeclarationExtracted() &&
!declarations.contains(nameInfo.getDeclaration()) &&
nameInfo.isUsedAfterReferences()) {
declarations.add(nameInfo.getDeclaration());
if (nameInfo.isDeclaredInSelection() && nameInfo.isReferencedAfterSelection() &&
declarations.add(nameInfo.getDeclaration())) {
usedAfter.add(nameInfo);
// Is return value candidate, set return value to true and reference to false
// It's a return value candidate, set return value to true and reference to false
nameInfo.setReturnValue(true);
nameInfo.setReference(false);
nameInfo.setOutput(false);
}
}
@ -516,6 +513,7 @@ public class NodeContainer {
}
public List<NameInformation> getNames() {
findAllNames();
return names;
}
}

View file

@ -51,7 +51,7 @@ public class ChooserComposite extends Composite {
setLayout(layout);
boolean hasNoPredefinedReturnValue = true;
if (info.getInScopeDeclaredVariable() != null) {
if (info.getMandatoryReturnVariable() != null) {
hasNoPredefinedReturnValue = false;
}
@ -75,14 +75,14 @@ public class ChooserComposite extends Composite {
}
addColumnToTable(table, ""); //$NON-NLS-1$
for (int i = 0; i < info.getAllUsedNames().size(); i++) {
if (!info.getAllUsedNames().get(i).isDeclarationExtracted()) {
for (int i = 0; i < info.getParameterCandidates().size(); i++) {
if (!info.getParameterCandidates().get(i).isDeclaredInSelection()) {
TableItem item = new TableItem(table, SWT.NONE);
TableEditor editor = new TableEditor(table);
int columnIndex = 0;
final NameInformation name = info.getAllUsedNames().get(i);
final NameInformation name = info.getParameterCandidates().get(i);
// Text
item.setText(columnIndex++, name.getType());
@ -95,14 +95,14 @@ public class ChooserComposite extends Composite {
referenceButton.setSelection(true);
referenceButton.setEnabled(false);
} else {
referenceButton.setSelection(name.isReference());
referenceButton.setSelection(name.isOutput());
}
referenceButton.setBackground(table.getBackground());
referenceButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
name.setUserSetIsReference(referenceButton.getSelection());
onVisibilityOrReturnChange(info.getAllUsedNames());
onVisibilityOrReturnChange(info.getParameterCandidates());
}
@Override
@ -128,7 +128,7 @@ public class ChooserComposite extends Composite {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
name.setConst(constButton.getSelection());
onVisibilityOrReturnChange(info.getAllUsedNames());
onVisibilityOrReturnChange(info.getParameterCandidates());
}
@Override
@ -149,7 +149,7 @@ public class ChooserComposite extends Composite {
editor = new TableEditor(table);
final Button returnButton = new Button(table, SWT.RADIO);
returnButton.setSelection(name.isReturnValue());
name.setUserSetIsReference(name.isReference());
name.setUserSetIsReference(name.isOutput());
returnButton.setEnabled(hasNoPredefinedReturnValue);
returnButton.setBackground(table.getBackground());
returnButton.addSelectionListener(new SelectionListener() {
@ -159,11 +159,11 @@ public class ChooserComposite extends Composite {
if (returnButton.getSelection()) {
referenceButton.setSelection(false);
referenceButton.notifyListeners(SWT.Selection, new Event());
} else if (name.isReference()) {
} else if (name.isOutput()) {
referenceButton.setSelection(true);
referenceButton.notifyListeners(SWT.Selection, new Event());
}
onVisibilityOrReturnChange(info.getAllUsedNames());
onVisibilityOrReturnChange(info.getParameterCandidates());
}
@Override
@ -216,7 +216,7 @@ public class ChooserComposite extends Composite {
void onVisibilityOrReturnChange(List<NameInformation> name) {
String variableUsedAfterBlock = null;
for (NameInformation information : name) {
if (information.isUsedAfterReferences() &&
if (information.isReferencedAfterSelection() &&
!(information.isUserSetIsReference() || information.isUserSetIsReturnValue())) {
variableUsedAfterBlock = information.getName().toString();
}

View file

@ -32,7 +32,7 @@ public class ExtractFunctionComposite extends Composite {
private final ExtractFunctionInformation info;
public ExtractFunctionComposite(Composite parent, ExtractFunctionInformation info,
ExtractFunctionInputPage ip) {
ExtractFunctionInputPage page) {
super(parent, SWT.NONE);
this.info = info;
setLayout(new GridLayout());
@ -40,7 +40,7 @@ public class ExtractFunctionComposite extends Composite {
createNewMethodNameComposite(this);
Group returnGroup = createReturnGroup(nameVisiComp);
createReturnValueChooser(returnGroup, info, ip);
createReturnValueChooser(returnGroup, info, page);
createReplaceCheckBox(nameVisiComp);
@ -65,11 +65,11 @@ public class ExtractFunctionComposite extends Composite {
}
private void createReturnValueChooser(Composite parent, ExtractFunctionInformation info,
ExtractFunctionInputPage ip) {
ExtractFunctionInputPage page) {
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
comp = new ChooserComposite(parent, info, ip);
comp = new ChooserComposite(parent, info, page);
comp.setLayoutData(gridData);
comp.redraw();
}

View file

@ -24,9 +24,9 @@ public class ExtractFunctionInformation {
private VisibilityEnum visibility = VisibilityEnum.v_private;
private String methodName;
private boolean replaceDuplicates;
private List<NameInformation> allAfterUsedNames;
private List<NameInformation> allUsedNames;
private NameInformation inScopeDeclaredVariable;
private List<NameInformation> namesUsedAfter;
private List<NameInformation> parameterCandidates;
private NameInformation mandatoryReturnVariable;
private NameInformation returnVariable;
private ICPPASTFunctionDeclarator declarator;
private MethodContext context;
@ -62,21 +62,21 @@ public class ExtractFunctionInformation {
this.replaceDuplicates = replaceDuplicates;
}
public List<NameInformation> getAllAfterUsedNames() {
if (allAfterUsedNames == null) {
allAfterUsedNames = new ArrayList<NameInformation>();
for (NameInformation name : getAllUsedNames()) {
if (name.isReference()||name.isReturnValue()) {
allAfterUsedNames.add(name);
public List<NameInformation> getNamesUsedAfter() {
if (namesUsedAfter == null) {
namesUsedAfter = new ArrayList<NameInformation>();
for (NameInformation name : getParameterCandidates()) {
if (name.isOutput() || name.isReturnValue()) {
namesUsedAfter.add(name);
}
}
}
return allAfterUsedNames;
return namesUsedAfter;
}
public void setAllAfterUsedNames(ArrayList<NameInformation> allAfterUsedNames) {
this.allAfterUsedNames = allAfterUsedNames;
public void setNamesUsedAfter(List<NameInformation> names) {
this.namesUsedAfter = names;
}
public NameInformation getReturnVariable() {
@ -90,20 +90,20 @@ public class ExtractFunctionInformation {
this.returnVariable = returnVariable;
}
public NameInformation getInScopeDeclaredVariable() {
return inScopeDeclaredVariable;
public NameInformation getMandatoryReturnVariable() {
return mandatoryReturnVariable;
}
public void setInScopeDeclaredVariable(NameInformation inScopeDeclaredVariable) {
this.inScopeDeclaredVariable = inScopeDeclaredVariable;
public void setMandatoryReturnVariable(NameInformation variable) {
this.mandatoryReturnVariable = variable;
}
public List<NameInformation> getAllUsedNames() {
return allUsedNames;
public List<NameInformation> getParameterCandidates() {
return parameterCandidates;
}
public void setAllUsedNames(List<NameInformation> allUsedNames) {
this.allUsedNames = allUsedNames;
public void setParameterCandidates(List<NameInformation> names) {
this.parameterCandidates = names;
}
public VisibilityEnum getVisibility() {

View file

@ -53,7 +53,6 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
for (Control buttons : comp.getVisibiltyGroup().getChildren()) {
buttons.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
String text = ((Button)e.getSource()).getText();

View file

@ -165,15 +165,14 @@ public class ExtractFunctionRefactoring extends CRefactoring {
if (isProgressMonitorCanceld(sm, initStatus))
return initStatus;
container.findAllNames();
markWriteAccess();
sm.worked(1);
if (isProgressMonitorCanceld(sm, initStatus))
return initStatus;
container.getAllAfterUsedNames();
info.setAllUsedNames(container.getUsedNamesUnique());
container.getNamesUsedAfter();
info.setParameterCandidates(container.getUsedNamesUnique());
if (container.size() < 1) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_NoStmtSelected);
@ -181,10 +180,11 @@ public class ExtractFunctionRefactoring extends CRefactoring {
return initStatus;
}
if (container.getAllDeclaredInScope().size() > 1) {
List<NameInformation> returnValueCandidates = container.getReturnValueCandidates();
if (returnValueCandidates.size() > 1) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_TooManySelected);
} else if (container.getAllDeclaredInScope().size() == 1) {
info.setInScopeDeclaredVariable(container.getAllDeclaredInScope().get(0));
} else if (returnValueCandidates.size() == 1) {
info.setMandatoryReturnVariable(returnValueCandidates.get(0));
}
extractedFunctionConstructionHelper =
@ -197,14 +197,14 @@ public class ExtractFunctionRefactoring extends CRefactoring {
MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
info.setMethodContext(context);
if (info.getInScopeDeclaredVariable() != null) {
info.getInScopeDeclaredVariable().setUserSetIsReturnValue(true);
if (info.getMandatoryReturnVariable() != null) {
info.getMandatoryReturnVariable().setUserSetIsReturnValue(true);
}
for (int i = 0; i < info.getAllUsedNames().size(); i++) {
if (!info.getAllUsedNames().get(i).isDeclarationExtracted()) {
NameInformation name = info.getAllUsedNames().get(i);
for (int i = 0; i < info.getParameterCandidates().size(); i++) {
if (!info.getParameterCandidates().get(i).isDeclaredInSelection()) {
NameInformation name = info.getParameterCandidates().get(i);
if (!name.isReturnValue()) {
name.setUserSetIsReference(name.isReference());
name.setUserSetIsReference(name.isOutput());
}
}
}
@ -219,9 +219,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
private void markWriteAccess() throws CoreException {
List<NameInformation> paras = container.getNames();
for (NameInformation name : paras) {
for (NameInformation name : container.getNames()) {
int flag = CPPVariableReadWriteFlags.getReadWriteFlags(name.getName());
if ((flag & PDOMName.WRITE_ACCESS) != 0) {
name.setWriteAccess(true);
@ -230,22 +228,22 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
private void checkForNonExtractableStatements(NodeContainer cont, RefactoringStatus status) {
NonExtractableStmtFinder vis = new NonExtractableStmtFinder();
NonExtractableStmtFinder finder = new NonExtractableStmtFinder();
for (IASTNode node : cont.getNodesToWrite()) {
node.accept(vis);
if (vis.containsContinue()) {
node.accept(finder);
if (finder.containsContinue()) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Continue);
break;
} else if (vis.containsBreak()) {
} else if (finder.containsBreak()) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Break);
break;
}
}
ReturnStatementFinder rFinder = new ReturnStatementFinder();
ReturnStatementFinder returnFinder = new ReturnStatementFinder();
for (IASTNode node : cont.getNodesToWrite()) {
node.accept(rFinder);
if (rFinder.containsReturn()) {
node.accept(returnFinder);
if (returnFinder.containsReturn()) {
initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Return);
break;
}
@ -287,7 +285,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
return finalConditions;
}
}
for (NameInformation name : info.getAllUsedNames()) {
for (NameInformation name : info.getParameterCandidates()) {
if (name.isUserSetIsReturnValue()) {
info.setReturnVariable(name);
}
@ -611,7 +609,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTStandardFunctionDeclarator createdFunctionDeclarator =
extractedFunctionConstructionHelper.createFunctionDeclarator(qname,
info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
info.getAllUsedNames(), ast.getASTNodeFactory());
info.getParameterCandidates(), ast.getASTNodeFactory());
func.setDeclarator(createdFunctionDeclarator);
IASTCompoundStatement compound = new CPPASTCompoundStatement();
@ -752,7 +750,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private IASTNode getReturnAssignment(IASTExpressionStatement stmt,
IASTFunctionCallExpression callExpression, IASTName retname) {
if (info.getReturnVariable().equals(info.getInScopeDeclaredVariable())) {
if (info.getReturnVariable().equals(info.getMandatoryReturnVariable())) {
IASTSimpleDeclaration orgDecl = NodeHelper.findSimpleDeclarationInParents(info
.getReturnVariable().getDeclaration());
IASTSimpleDeclaration decl = new CPPASTSimpleDeclaration();
@ -796,7 +794,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTStandardFunctionDeclarator declarator =
extractedFunctionConstructionHelper.createFunctionDeclarator(name,
info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
info.getAllUsedNames(), ast.getASTNodeFactory());
info.getParameterCandidates(), ast.getASTNodeFactory());
simpleDecl.addDeclarator(declarator);
return simpleDecl;
}
@ -811,7 +809,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
IASTStandardFunctionDeclarator declarator =
extractedFunctionConstructionHelper.createFunctionDeclarator(name,
info.getDeclarator(), info.getReturnVariable(), container.getNodesToWrite(),
info.getAllUsedNames(), ast.getASTNodeFactory());
info.getParameterCandidates(), ast.getASTNodeFactory());
simpleDecl.addDeclarator(declarator);
return simpleDecl;
}
@ -855,9 +853,9 @@ public class ExtractFunctionRefactoring extends CRefactoring {
}
private void addParameterIfPossible(List<IASTInitializerClause> args,
List<IASTName> declarations, NameInformation nameInfo) {
if (!nameInfo.isDeclarationExtracted()) {
IASTName declaration = nameInfo.getDeclaration();
List<IASTName> declarations, NameInformation nameInfо) {
if (!nameInfо.isDeclaredInSelection()) {
IASTName declaration = nameInfо.getDeclaration();
if (!declarations.contains(declaration)) {
declarations.add(declaration);
IASTIdExpression expression = new CPPASTIdExpression();

View file

@ -95,7 +95,7 @@ public abstract class ExtractedFunctionConstructionHelper {
Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
List<IASTParameterDeclaration> result = new ArrayList<IASTParameterDeclaration>();
for (NameInformation name : allUsedNames) {
if (!name.isDeclarationExtracted()) {
if (!name.isDeclaredInSelection()) {
result.add(name.getParameterDeclaration(name.isUserSetIsReference(), nodeFactory));
}
}

View file

@ -63,7 +63,7 @@ final class SimilarFinderVisitor extends ASTVisitor {
if (statementCount == statements.size()) {
// Found similar code
boolean similarOnReturnWays = true;
for (NameInformation nameInfo : similarContainer.getAllAfterUsedNames()) {
for (NameInformation nameInfo : similarContainer.getNamesUsedAfter()) {
if (refactoring.names.containsKey(nameInfo.getDeclaration().getRawSignature())) {
Integer nameOrderNumber = refactoring.names.get(nameInfo.getDeclaration().getRawSignature());
if (refactoring.nameTrail.containsValue(nameOrderNumber)) {
@ -75,7 +75,7 @@ final class SimilarFinderVisitor extends ASTVisitor {
}
}
if (orgName != null) {
for (NameInformation orgNameInfo : refactoring.container.getAllAfterUsedNamesChoosenByUser()) {
for (NameInformation orgNameInfo : refactoring.container.getNamesUsedAfterChoosenByUser()) {
if (orgName.equals(orgNameInfo.getDeclaration().getRawSignature())) {
found = true;
}

View file

@ -133,10 +133,9 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
if (isProgressMonitorCanceld(sm, initStatus))
return initStatus;
container.findAllNames();
sm.worked(1);
container.getAllAfterUsedNames();
container.getNamesUsedAfter();
info.addNamesToUsedNames(findAllDeclaredNames());
sm.worked(1);

View file

@ -1884,10 +1884,10 @@ public class PreferenceConstants {
* @since 5.3
*/
public static final int NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE = 4;
/**
* A named preference that controls order of private/protected/public class members in generated
* code.
* A named preference that controls the order of private/protected/public class members in
* generated code.
* <p>
* Value is of type <code>Boolean</code>. The <code>true</code> value means that private members
* are before public ones. The default is to put public members before private ones.
@ -1896,6 +1896,28 @@ public class PreferenceConstants {
*/
public static final String CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER = "class_member_ascending_visibility_order"; //$NON-NLS-1$
/**
* A named preference that controls the order of parameters of generated functions.
* <p>
* Value is of type <code>Boolean</code>. The <code>true</code> value means that output
* parameters are before the input ones. The default is to put outputparameters after the input
* ones.
*
* @since 5.4
*/
public static final String FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT = "function_output_parameters_before_input"; //$NON-NLS-1$
/**
* A named preference that controls whether output parameters of generated functions are passed
* by pointer or by reference.
* <p>
* Value is of type <code>Boolean</code>. The <code>true</code> value means that output
* parameters are passed by pointer. The default is to pass output parameters by reference.
*
* @since 5.4
*/
public static final String FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER = "function_pass_output_parameters_by_pointer"; //$NON-NLS-1$
/**
* Returns the CDT-UI preference store.
@ -2103,6 +2125,8 @@ public class PreferenceConstants {
// Code style
store.setDefault(CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, false);
store.setDefault(FUNCTION_OUTPUT_PARAMETERS_BEFORE_INPUT, false);
store.setDefault(FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER, false);
// Colors that are set by the current theme
CUIPreferenceInitializer.setThemeBasedPreferences(store, false);