Re: Eclipse: Template Variable Creation

From: A.Buschmann (a.buschmann_at_vinex.de)
Date: 02/21/04


Date: Sat, 21 Feb 2004 18:23:35 +0100


Hello Paul,

"P.Hill" <goodhill@xmission.com> wrote:
<snip>
>those things that have ${...} that result in dynamic substitution when
>Java code is generated
<snip>
I don't think that this could be possible, because some of the predefined
Variables have some
action behind them, like searching for an array, so I think they are defined
somewhere in the Source Code.

> "You can insert your own template variables, which then evaluate to the
name of
> the variable itself.
<snip>

I think you didn't get that right.
They wrote: "evaluate to the name of the variable itself" and that's exactly
what is meant.
1. Try defining a template in "preferences->java->editor->templates" with
name "TempTest"
2. write somewhere in this Template: ${MyTestVariable}
3. open a Java-Editor
4. Type in: "TempTest" and press Ctrl-Space.
In the Source-Code now ${MyTestVariable} is replaces with "MyTestVariable".
That's neither nice nor smothe, but it's exactly
what the help is saying.

Now you are asking: Why then define an Template Variable?
Because when the same Variable appears more than once and you overwrite the
Variable right after pressing Ctrl-Space,
all occurences are replaced at the same time.

For more infos, look into the Eclipse-Help:
Getting Started->Basic tutorial->Editing Java Elements->Using source code
templates

Alex



Relevant Pages

  • Re: The Decline of C/C++, the rise of X
    ... >> tend to be most useful for encoding Boolean values in data structures ... Template instantiations are done as COMDAT records, ... separate instantiation for each type using reference semantics or do ...
    (comp.programming)
  • Breaking classes down in header files.
    ... uses a template. ... I'm using one cpp file and a Makefile. ... <SNIP> ... template <class sometype> ...
    (comp.lang.cpp)
  • Re: Questions about defaut template type argument
    ... > it as the default template type argument? ... you need to give the function type say bool (*)(int, ... template < typename NonVoid, typename Alt> ...
    (comp.lang.cpp)
  • Re: Ruby, Web Apps and Cross Site Scripting
    ... > vulnerability of web applications to cross site scripting ... > # snip ... ERB template to force escaping (Rails aliases this to #h, ... Or just manually stick an escape there yourself:) ...
    (comp.lang.ruby)
  • Re: GRR-Ripper System
    ... > Just ordered this from Lee Valley (along with a F1 template for the ... good control on cuts on narrow pieces where I would not have made the cut ...
    (rec.woodworking)