Bug 417029 - pasting a series of statements in _pasted_code_ project should add them in a method/initializer
Summary: pasting a series of statements in _pasted_code_ project should add them in a ...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2013-09-11 13:37 EDT by Palmer Eldritch CLA
Modified: 2013-09-13 08:56 EDT (History)
1 user (show)

See Also:


Attachments
copy paste in _pasted_code_ - end up in Snippet (2.87 KB, text/plain)
2013-09-12 13:13 EDT, Palmer Eldritch CLA
no flags Details
copy paste in _pasted_code_ - end up in Snippet 2 (1.33 KB, text/plain)
2013-09-12 13:13 EDT, Palmer Eldritch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Palmer Eldritch CLA 2013-09-11 13:37:50 EDT
Have recently discovered this feature and been using it a lot (mainly to CP code from stackoverflow and format it). It is a wonderful time saver but one thing is missing

When the code consists of a series of statements they end up in Snippet class and I have to manually add a pair of braces and move the code there :

{
	// CP the CP
}

It would be nice to have this as the default behavior - or maybe adding a method with the copypasted code although this would be more complicated
Comment 1 Dani Megert CLA 2013-09-12 08:34:44 EDT
In 4.3 the statements are put into a main method. Can you provide a concrete example?
Comment 2 Palmer Eldritch CLA 2013-09-12 13:13:09 EDT
Created attachment 235438 [details]
copy paste in _pasted_code_ - end up in Snippet
Comment 3 Palmer Eldritch CLA 2013-09-12 13:13:39 EDT
Created attachment 235439 [details]
copy paste in _pasted_code_ - end up in Snippet 2
Comment 4 Palmer Eldritch CLA 2013-09-12 13:19:00 EDT
Never saw this main() - gladly I could retrieve those 2 thanks to dropbox but I have experienced this consistently - just checked those by trying to copy paste them in the navigation pane with _pasted_code_ selected

Maybe some (syntax error or anything) prevents them from ending up in main() - but when I add the anonymous block (instance initializer) and move them there I can then hit Ctrl+Shift+F and they format alright

Consider adding as an option to have code added to such an initializer

Also if you can reproduce this qualifies as a bug not an enhancement

Eclipse Java EE IDE for Web Developers.

Version: Kepler Release
Build id: 20130614-0229
Comment 5 Dani Megert CLA 2013-09-13 04:17:51 EDT
> Never saw this main() 

Paste e.g. this into the 'Package Explorer':
System.out.println();

In your snippet it detects variables and hence adds it into the type. Also, if I select the same project using 4.4 M1, then the second paste is also added into the first 'Snippet' class.
Comment 6 Palmer Eldritch CLA 2013-09-13 08:56:00 EDT
(In reply to Dani Megert from comment #5)
> > Never saw this main() 
> 
> Paste e.g. this into the 'Package Explorer':
> System.out.println();


I meant the package explorer, sorry. Your example works for me also

> In your snippet it detects variables and hence adds it into the type. 

yes but Ctrl+Shift+F does not work at all - as the syntax with statements and variables is completely wrong in the class body - it naturally belongs to a method - or more easily to an initializer. This would make editing/inspecting the code much easier - as it is it beats the purpose of a quick and dirty _usable_ copy paste

> Also,
> if I select the same project using 4.4 M1, then the second paste is also
> added into the first 'Snippet' class.

This also happens in my case (4.3) - sorry if I were unclear

In all, I think this should stay open - marking it WONTFIX as WORKSFORME was not the point, but I 'd rather you open it again - the title should change to "...series of statements and variable declarations/definitions..." for clarity

Thanks