diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts index eb7509328cc..758e2c66104 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts @@ -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; +} + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java index 72e0053b44b..3e1f1aeebb2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java @@ -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); }