| Summary: | Allow text-selection for code assist to span more than one line | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Alex Blewitt <alex.blewitt> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | 2.1 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
I think you mean "more than one line" in the summary don't you? Thanks. Changed sentence in my head whilst in the middle of writing it ... Quick assist (ctrl-1) gives you an approximation of this capability today. If you select some text, you can then type ctrl-1 to surround with your choice of do, for, if, try, while. John, what version is that? I'm using 2.1RC1 and I don't have that in the quick-assist menu; just a bunch of classes/fields/methods (usually the publicly available static ones) I've created the template (shown in #1) in 2.1RC1, and it works provided that the selected text doesn't contain a newline; if it does, the template doesn't seem to show up at all. I guess you work with a workspace you created with an older version than RC1. In this case you have to press the "Restore Defaults" button on the Templates' preference page. We added new templates that make use of the newly introduced content assist variables $word_selection and $line_selection. Those templates that make use of the $line_selection variable are proposed by quick assist in case of a multi-line selection. Yes, this closes the suggestion that I had here. I do have an issue that the line_selection now no longer shows up /unless/ you have multiple lines, which requires that anything using a single line now can't be captured. The solution, though ugly, is to have two templates for the 'if' generation; one showing for a word_selection and the other for a line_selection. I'll close this bug and open a new bug for this new issue. |
The current code-assist allows a single word to be selected and then a psuedo-macro run to insert some behaviour (such as 'print out variable') using the 'selected_word' variable in Preferences -> Java -> Editor -> Templates "Print out expression" System.out.println("${selected_word}"); However, this fails if the selection consists of more than one line. Instead, it would be advantageous to allow multiple-line selects to take place which would allow templates such as "Generate if" if (${test}${cursor}) { ${selected_text} } Whist this works for single-line values, it doesn't work for multi-line values. If the selected_word was replaced with selected_text then it would be possible to provide features otherwise described by bug 32082