Bug 387800 - [templates] template to define a variable
Summary: [templates] template to define a variable
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
Depends on:
Blocks:
 
Reported: 2012-08-22 11:13 EDT by Lars Vogel CLA
Modified: 2015-04-21 11:36 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2012-08-22 11:13:05 EDT
I'm at the moment learning the JDT template approach. Cool stuff you have.

Why not add a template for defining a local variable:

${variabletype} ${myvar:newName(var)}= new ${variabletype}(${cursor});

As in Bug 387272, I'm happy to supply a patch.
Comment 1 Dani Megert CLA 2012-08-23 07:07:01 EDT
This could also be used to declare fields ==>
name: "variable"
description: "variable declaration"
Comment 2 Lars Vogel CLA 2012-08-23 08:59:39 EDT
@Dani: How can I create a template which allows to create either a local variable or a field?
Comment 3 Dani Megert CLA 2012-08-27 07:01:06 EDT
(In reply to comment #2)
> @Dani: How can I create a template which allows to create either a local
> variable or a field?

Take a look at the 'static_final' template.
Comment 4 Robert Roth CLA 2015-03-27 18:19:00 EDT
I would like to tackle this in context of the #greatfix initiative, please assign me and add the greatfix keyword.

As a similar template exists already (the "new" template) I will update that to set the cursor to the constructor arguments instead of just hardcoding "arguments" string there, which will be uncompilable unless you have a variable with that name.
Comment 5 Eclipse Genie CLA 2015-03-27 18:29:15 EDT
New Gerrit change created: https://git.eclipse.org/r/44786
Comment 6 Dani Megert CLA 2015-04-09 09:36:54 EDT
(In reply to Eclipse Genie from comment #5)
> New Gerrit change created: https://git.eclipse.org/r/44786

See my comment there. I've simply removed the "arguments" name, so that one can either tab into the constructor or go to the end with Enter.

Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=0663778d660e5863ed8d9acdc6e3f54aae647c3d


Lars, I'm not convinced anymore that we need a more complicated template than "new" already gives us.
Comment 7 Lars Vogel CLA 2015-04-21 11:36:35 EDT
(In reply to Dani Megert from comment #6)
> 
> Lars, I'm not convinced anymore that we need a more complicated template
> than "new" already gives us.

I agree.