Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-03-11 22:47:11 +0000
committerSergey Prigogin2016-03-11 22:47:46 +0000
commit600966533413e5e8cc77faab1fe8af33b50d059c (patch)
tree3277ea6a1945c3725b236db64f721988f475263b /core/org.eclipse.cdt.ui.tests
parent1a0c51205ed3a936b31b6cdc464a46ba28167ae4 (diff)
downloadorg.eclipse.cdt-600966533413e5e8cc77faab1fe8af33b50d059c.tar.gz
org.eclipse.cdt-600966533413e5e8cc77faab1fe8af33b50d059c.tar.xz
org.eclipse.cdt-600966533413e5e8cc77faab1fe8af33b50d059c.zip
Bug 489468 - Extract Function creates illegal declaration in .h when
there is a using statement in the .cpp for an argument type Change-Id: Ie54ce13b434bab21f96b0c6bb7347846d52314e0
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests')
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java81
1 files changed, 77 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
index 15cb4e3c377..6b30e36e1d1 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java
@@ -16,8 +16,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.Test;
-
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestBase;
@@ -27,6 +25,8 @@ import org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionIn
import org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring;
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+import junit.framework.Test;
+
/**
* Tests for Extract Function refactoring.
*/
@@ -35,12 +35,12 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
private String extractedFunctionName = "extracted";
private String returnValue;
// Map from old names to new ones.
- private Map<String, String> parameterRename = new HashMap<>();
+ private final Map<String, String> parameterRename = new HashMap<>();
// New positions of parameters, or null.
private int[] parameterOrder;
private VisibilityEnum visibility = VisibilityEnum.v_private;
private boolean virtual;
- private boolean replaceDuplicates = true;
+ private final boolean replaceDuplicates = true;
private ExtractFunctionRefactoring refactoring;
public ExtractFunctionRefactoringTest() {
@@ -570,6 +570,79 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
assertRefactoringSuccess();
}
+ //A.h
+ //#ifndef A_H_
+ //#define A_H_
+ //
+ //#include "B.h"
+ //
+ //class A {
+ //public:
+ // void foo();
+ //};
+ //
+ //#endif /*A_H_*/
+ //====================
+ //#ifndef A_H_
+ //#define A_H_
+ //
+ //#include "B.h"
+ //
+ //class A {
+ //public:
+ // void foo();
+ //
+ //private:
+ // ns1::ns2::B extracted(ns1::ns2::B b);
+ //};
+ //
+ //#endif /*A_H_*/
+
+ //A.cpp
+ //#include "A.h"
+ //#include "B.h"
+ //
+ //using ns1::ns2::B;
+ //
+ //void A::foo() {
+ // B b;
+ // /*$*/b.m();/*$$*/
+ // b.n();
+ //}
+ //====================
+ //#include "A.h"
+ //#include "B.h"
+ //
+ //using ns1::ns2::B;
+ //
+ //B A::extracted(B b) {
+ // b.m();
+ // return b;
+ //}
+ //
+ //void A::foo() {
+ // B b;
+ // b = extracted(b);
+ // b.n();
+ //}
+
+ //B.h
+ //#ifndef B_H_
+ //#define B_H_
+ //
+ //namespace ns1 { namespace ns2 {
+ //struct B {
+ // void m();
+ // void n() const;
+ //};
+ //}}
+ //
+ //#endif /*B_H_*/
+ public void testUsingDeclaration() throws Exception {
+ getPreferenceStore().setValue(PreferenceConstants.FUNCTION_PASS_OUTPUT_PARAMETERS_BY_POINTER, true);
+ assertRefactoringSuccess();
+ }
+
//A.cpp
//void test() {
// for (int i = 0; i < 2; i++) {

Back to the top