Test & fix for Bug 330169 -  [refactoring] Extract method throws NPE if declared lifting arg is involved
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTestSetup.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTestSetup.java
index 0c6e9e3..4a7d411 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTestSetup.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTestSetup.java
@@ -57,7 +57,8 @@
 	private IPackageFragment _rolefilePackage;

 	private IPackageFragment _rolefileParentPackage;

 	private IPackageFragment _focusTypePackage;

-	private IPackageFragment _overloadingPackage;

+	private IPackageFragment _overloadingPackage;
+	private IPackageFragment _syntaxPackage;

 	

     public ExtractMethodTestSetup(Test test)

     {

@@ -96,8 +97,9 @@
 		_rolefileParentPackage = getRoot().createPackageFragment("roleFile_in", true, null);

 		_nestedTeamPackage = getRoot().createPackageFragment("nestedTeam_in", true, null);

 		_focusTypePackage = getRoot().createPackageFragment("focusType_in", true, null);

-		_overloadingPackage = getRoot().createPackageFragment("overloading_in", true, null);

-		

+		_overloadingPackage = getRoot().createPackageFragment("overloading_in", true, null);
+		_syntaxPackage = getRoot().createPackageFragment("syntax_in", true, null);
+

 //		_selectionPackage = getRoot().createPackageFragment("selection", true, null);

     }

 

@@ -145,5 +147,9 @@
 	public IPackageFragment getOverloadingPackage()

 	{

 	    return _overloadingPackage;

+	}
+
+	public IPackageFragment getSyntaxPackage() {
+		return _syntaxPackage;
 	}

 }

diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTests.java
index c0eb561..1f20ff4 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/src/org/eclipse/objectteams/otdt/ui/tests/refactoring/extractmethod/ExtractMethodTests.java
@@ -477,4 +477,18 @@
 		        COMPARE_WITH_OUTPUT,
 		        "overloading_out");
 	}
+
+	//	=====================================================================================
+	// 	Testing special syntactic nodes
+	//	=====================================================================================	
+
+	// call target is a declared-lifting argument
+	public void testDeclaredLifting1() throws Exception
+	{
+		performTest(
+		        _testSetup.getSyntaxPackage(),
+		        new String[] {"T", "B"},
+		        COMPARE_WITH_OUTPUT,
+		        "syntax_out");
+	}
 }
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/B_testDeclaredLifting1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/B_testDeclaredLifting1.java
new file mode 100644
index 0000000..dd71707
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/B_testDeclaredLifting1.java
@@ -0,0 +1,4 @@
+package syntax_in;
+public class B_testDeclaredLifting1 {
+	
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/T_testDeclaredLifting1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/T_testDeclaredLifting1.java
new file mode 100644
index 0000000..fd9316e
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_in/T_testDeclaredLifting1.java
@@ -0,0 +1,14 @@
+package syntax_in;

+

+public team class T_testDeclaredLifting1

+{

+	public class R playedBy B_testDeclaredLifting1

+	{

+		public void bar(){}

+	}

+	

+	public void foo(final B_testDeclaredLifting1 as R o)

+	{

+		/*[*/o.bar();/*]*/

+	}

+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/B_testDeclaredLifting1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/B_testDeclaredLifting1.java
new file mode 100644
index 0000000..23c5ba1
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/B_testDeclaredLifting1.java
@@ -0,0 +1,4 @@
+package syntax_out;
+public class B_testDeclaredLifting1 {
+	
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/T_testDeclaredLifting1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/T_testDeclaredLifting1.java
new file mode 100644
index 0000000..7783b5d
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.refactoring/testdata/ExtractMethod/syntax_out/T_testDeclaredLifting1.java
@@ -0,0 +1,19 @@
+package syntax_out;

+

+public team class T_testDeclaredLifting1

+{

+	public class R playedBy B_testDeclaredLifting1

+	{

+		public void bar(){}

+	}

+	

+	public void foo(final B_testDeclaredLifting1 as R o)

+	{

+		extracted(o);

+	}

+

+	protected void extracted(final R o)

+	{

+		/*[*/o.bar();/*]*/

+	}

+}
\ No newline at end of file