1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

239059: Double & in signature of extracted functions

This commit is contained in:
Emanuel Graf 2008-07-02 12:42:53 +00:00
parent d4573870a7
commit 647d9a147e
3 changed files with 96 additions and 2 deletions

View file

@ -2070,3 +2070,79 @@ int main(){
newElements[0] = "s";
}
//!Bug 239059: Double & in signature of extracted functions
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
//@.config
returnvalue=false
returnparameterindex=0
//@A.h
#ifndef A_H_
#define A_H_
class A
{
public:
A();
virtual ~A();
int foo(int& a);
};
#endif /*A_H_*/
//=
#ifndef A_H_
#define A_H_
class A
{
public:
A();
virtual ~A();
int foo(int& a);
private:
void exp(int & a, int b, int c);
};
#endif /*A_H_*/
//@A.cpp
#include "A.h"
A::A()
{
}
A::~A()
{
}
int A::foo(int& a)
{
int b = 7;
int c = 8;
//$a = b + c;$//
return a;
}
//=
#include "A.h"
A::A()
{
}
A::~A()
{
}
void A::exp(int & a, int b, int c)
{
a = b + c;
}
int A::foo(int& a)
{
int b = 7;
int c = 8;
exp(a, b, c);
return a;
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
@ -154,7 +155,7 @@ public class NodeContainer {
declarator.addPointerOperator(pointerOp);
}
if (isReference) {
if (isReference && !hasReferenceOperartor(declarator)) {
declarator.addPointerOperator(new CPPASTReferenceOperator());
}
@ -165,6 +166,15 @@ public class NodeContainer {
return para;
}
public boolean hasReferenceOperartor(IASTDeclarator declarator) {
for(IASTPointerOperator pOp :declarator.getPointerOperators()) {
if (pOp instanceof ICPPASTReferenceOperator) {
return true;
}
}
return false;
}
public String getType() {
IASTDeclSpecifier declSpec = null;

View file

@ -26,6 +26,8 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
public class ChooserComposite extends Composite {
@ -90,7 +92,13 @@ public class ChooserComposite extends Composite {
// Button
editor = new TableEditor(table);
final Button referenceButton = new Button(table, SWT.CHECK);
referenceButton.setSelection(name.isReference());
if(name.hasReferenceOperartor((IASTDeclarator) name.getDeclaration().getParent()))
{
referenceButton.setSelection(true);
referenceButton.setEnabled(false);
}else {
referenceButton.setSelection(name.isReference());
}
referenceButton.setBackground(table.getBackground());
referenceButton.addSelectionListener(new SelectionListener() {