Community
Participate
Working Groups
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
In 4.3 the statements are put into a main method. Can you provide a concrete example?
Created attachment 235438 [details] copy paste in _pasted_code_ - end up in Snippet
Created attachment 235439 [details] copy paste in _pasted_code_ - end up in Snippet 2
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
> 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.
(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