Community
Participate
Working Groups
Build: 3.6 M4 1) Select a method in the Outline view 2) Ctrl+X to cut the method 3) Select a new destination file in the Project Explorer view 4) Ctrl+V to paste The entire method bodies are cut from the source file, but only the string from the outline view is pasted into the destination. I.e., in the source file I had this: public void testGetValueForArgument() throws Exception { List args = new ArrayList(); args.add("-foo"); args.add("bar"); assertEquals( "bar", ParserUtils.getValueForArgument("-foo", args)); args.set(1, "-bar"); assertEquals(null, ParserUtils.getValueForArgument("-foo", args)); } And in the destination I got this: testGetValueForArgument() I would expect Cut/Paste to be symmetric and paste the same method body that was cut at the source location.
It works if you paste it into a valid parent. A CU can contain many classes and hence we only paste the full method if you paste it into a class.
(In reply to comment #1) > It works if you paste it into a valid parent. A CU can contain many classes and > hence we only paste the full method if you paste it into a class. Shouldn't you just fail to paste then? The current behaviour is that the paste operation does select a class in that CU (the top-level public class), and selects a reasonable place to paste the new method at the end of the method list for that class. But, instead of pasting the method body it pastes the method declaration only. If it's not safe to select a destination class automatically then the paste of a method shouldn't be permitted with a CU target.
>selects a reasonable place to paste the new method at the end of the method >list for that class. But, instead of pasting the method body it pastes the >method declaration only. That's because of the feature to paste any text snippet into the Package Explorer. I agree we could be smarter and in case of having the body we paste the full source.
I'll disable snippet paste if the clipboard only contains file names. Pasting to the CU will paste into the CU's main type.
Fixed in ReorgPolicyFactory and enabled CopyTest#test_method_yes_cu_with_main_type().
A problem is that the target CU does not get opened in the editor, but that's bug 274019.
*** Bug 297092 has been marked as a duplicate of this bug. ***