mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
FIXED - bug 282004: Refactor->Extract Function in C Project (not C++) won't extract parameters
https://bugs.eclipse.org/bugs/show_bug.cgi?id=282004
This commit is contained in:
parent
a43c0fdb39
commit
e4a67a4897
2 changed files with 37 additions and 0 deletions
|
@ -2752,3 +2752,29 @@ int a = 0;
|
|||
return a;
|
||||
}
|
||||
|
||||
//!Bug#282004 Refactor->Extract Function in C Project (not C++) won't extract parameters
|
||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||
//@.config
|
||||
filename=main.c
|
||||
methodname=exp
|
||||
//@main.c
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
/*$*/b=a*2;/*$$*/
|
||||
return a;
|
||||
}
|
||||
|
||||
//=
|
||||
void exp(int b, int & a)
|
||||
{
|
||||
b = a * 2;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
exp(b, a);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
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;
|
||||
|
@ -326,6 +327,16 @@ public class NodeContainer {
|
|||
.getMessage(), e);
|
||||
logger.log(status);
|
||||
}
|
||||
}else if(bind instanceof IVariable) {
|
||||
NameInformation nameInformation = new NameInformation(
|
||||
name);
|
||||
|
||||
IASTName[] refs = name.getTranslationUnit()
|
||||
.getReferences(bind);
|
||||
for (IASTName ref : refs) {
|
||||
nameInformation.addReference(ref);
|
||||
}
|
||||
names.add(nameInformation);
|
||||
}
|
||||
return super.visit(name);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue