Community
Participate
Working Groups
3.4 RC1. SWT templates that e.g. set a text (Button.setText()) are not filling in a string variable but leave the input empty. E.g. having: String text= "aklsdjaks"; Button<code assist> should insert setText(text).
Would probably be easy to fix. If so, we should consider doing this for RC2.
I would close this as wontfix. I'm using the ${word_selection} variable. This allows to select something like: "Press Me" and then invoke the Button template, resulting in: Button button = new Button(parent, SWT.PUSH); button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); button.setText("Press Me"); IMHO this is the 80% case. Using a variable for the string is not the common code pattern. The common case is using a string literal and then maybe later extract to local or more likely externalize string. Of course I have no prove for this statement, but it sounds reasonable. What we could do is improve the word_selection variable to something like ${word_selection(java.lang.String}) where a variable of type String is resolved in the context only if word_selection is empty. But that's not an easy fix and not for 3.4 and does not make the template variable stuff easier to use.
>IMHO this is the 80% case. I disagree. The 80% case is: type some prefix + code assist.
Since we don't agree on a common solution, I agree to not investigate further at this point. But disagree to 'wontfix'.
(In reply to comment #3) > >IMHO this is the 80% case. > I disagree. The 80% case is: type some prefix + code assist. Ok, agreed. But in 80% of this cases you don't want a string variable to be filled into setText() but type in a string literal.
>But in 80% of this cases you don't want a string variable to be >filled into setText() but type in a string literal. Recently when I used the SWT templates I used them in existing code where the strings were already there as vars. But agree that this is less common than start from scratch. Your proposal from comment 2 sounds interesting.
A similar solution, but not the same is handled by Bug 486903, which will allow to define defaults in the template.