Community
Participate
Working Groups
If I use a variable for word_selection in a template this template "vanishes" if I select a text in the editor. For example: ${button}.setText(${w:word_selection}); Or in a full template (modified Button template): --------- ${buttonType:newType(org.eclipse.swt.widgets.Button)} ${button:newName(org.eclipse.swt.widgets.Button)}= new ${buttonType}(${parent:var(org.eclipse.swt.widgets.Composite)}, ${style:link(SWT.PUSH, SWT.TOGGLE, SWT.RADIO, SWT.CHECK, SWT.FLAT)}); ${button}.setLayoutData(new ${type:newType(org.eclipse.swt.layout.GridData)}(SWT.${horizontal:link(BEGINNING, CENTER, END, FILL)}, SWT.${vertical:link(CENTER, TOP, BOTTOM, FILL)}, ${hex:link(false, true)}, ${vex:link(false, true)})); ${button}.setText(${w:word_selection}); ${button}.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ${listener:link('')} } }); ${imp:import(org.eclipse.swt.SWT, org.eclipse.swt.events.SelectionAdapter, org.eclipse.swt.events.SelectionEvent)}${cursor} ----------
Noopur, maybe you can advice here, where the error could be? You worked recently on the code completion code for subwords.
This template gets filtered here: TemplateEngine#complete, line 144. I'll take a look. FYI: To debug such cases, you can add a breakpoint in org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(int offset) and check where a proposal is added or filtered.
(In reply to Noopur Gupta from comment #2) > This template gets filtered here: TemplateEngine#complete, line 144. > > I'll take a look. Noopur is on vacation now. Same issue for ${line_selection}.
(In reply to Noopur Gupta from comment #2) > This template gets filtered here: TemplateEngine#complete, line 144. Thanks Noopur, the template gets filtered indeed in line 144 via this statement: (!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1))) We should switch to evaluate a pattern. I prepare a patch.
New Gerrit change created: https://git.eclipse.org/r/66014
Gerrit change https://git.eclipse.org/r/66014 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=57d8b334ec559a45f07dcb2e1727f60bb93600dc