Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Template Variable Resolver
Template Variable Resolver [message #168432] Tue, 13 July 2004 05:54 Go to next message
Eclipse UserFriend
Originally posted by: gbforum.laposte.net

How to add variable Resolver to the JavaContext ?

I have the following plugin description :

<extension point="org.eclipse.ui.editors.templates">
<template id="com.biomerieux.tools.beautify.template.bmxLogger"
contextTypeId="java" name="bmxLogger" description="Java class logger">
<pattern>private static final java.util.logging.Logger ${logger_field_name}
= java.util.logging.Logger.getLogger(${enclosing_type}.class.g etName());
</pattern>
</template>
<resolver
name="Logger field name"
type="logger_field_name"
contextTypeId="java"
description="Name of the field used as logger (defined in beautify
preference)"
class="org.toto.fieldAdder.logger.LoggerVariableResolver"
/>
</extension>

but nothing happend.
if I execute in debug mode the following code :

org.eclipse.jface.text.templates.TemplateContextType l_tct =
org.eclipse.jdt.internal.ui.JavaPlugin.getDefault().getTempl ateContextRegistry().getContextType( "java");
l_tct.addResolver(new
org.toto.fieldAdder.logger.logger.LoggerVariableResolver());

then it works .
Do I have to put that code some place ? in that case why is it necessary
to declare it in the plug in ?

thanks
Guillaume
Re: Template Variable Resolver [message #168440 is a reply to message #168432] Tue, 13 July 2004 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gbforum.laposte.net

the code I execute is :

> org.eclipse.jface.text.templates.TemplateContextType l_tct =
>
org.eclipse.jdt.internal.ui.JavaPlugin.getDefault().getTempl ateContextRegistry().getContextType( "java");
> l_tct.addResolver(new
> org.toto.fieldAdder.logger.LoggerVariableResolver());

(I made an error when tyoing this message. it's not an issue of class not
found).
Re: Template Variable Resolver [message #168448 is a reply to message #168432] Tue, 13 July 2004 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gbforum.laposte.net

the code I execute is :

> org.eclipse.jface.text.templates.TemplateContextType l_tct =
>
org.eclipse.jdt.internal.ui.JavaPlugin.getDefault().getTempl ateContextRegistry().getContextType( "java");
> l_tct.addResolver(new
> org.toto.fieldAdder.logger.LoggerVariableResolver());

(I made an error when tyoing this message. it's not an issue of class not
found).
Re: Template Variable Resolver [message #168464 is a reply to message #168432] Tue, 13 July 2004 06:28 Go to previous messageGo to next message
Eclipse UserFriend
The Java editor does not currently allow variables to be contributed but
only recognizes its built in ones.

-tom
Re: Template Variable Resolver [message #168478 is a reply to message #168464] Tue, 13 July 2004 06:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gbforum.laposte.net

Tom Eicher wrote:

> The Java editor does not currently allow variables to be contributed but
> only recognizes its built in ones.

that means that I have to put some initialisation somewhere ?
any idea of where I shall put that so that when my plugin is initialised
those Resolver are added ?

Guillaume
Re: Template Variable Resolver [message #168518 is a reply to message #168478] Tue, 13 July 2004 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gbforum.laposte.net

> any idea of where I shall put that so that when my plugin is initialised
> those Resolver are added ?

I used the extension point org.eclipse.ui.startup to put this
initialisation ... that's not as clean as I wish but that seams to work.

Guillaume
Re: Template Variable Resolver [message #168541 is a reply to message #168518] Tue, 13 July 2004 09:41 Go to previous message
Eclipse UserFriend
Guillaume wrote:
>>any idea of where I shall put that so that when my plugin is initialised
>>those Resolver are added ?

As I said, the Java editor chooses not to respect resolvers contributed
to its two context types ('java' and 'javadoc'), but only recognizes the
built-in resolvers.

> I used the extension point org.eclipse.ui.startup to put this
> initialisation ... that's not as clean as I wish but that seams to work.

If you implement your own editor, you can simply set up a
ContributionTemplateStore in your plug-in class, and call
createContextType(String). This will try to instantiate the specified
context type and any contributed variable resolvers. You can do that
lazily the first time that someone requests the context type registry.

-tom
Previous Topic:search
Next Topic:[ANN] JDT update for J2SE 1.5: Cheetah06 available
Goto Forum:
  


Current Time: Sat May 10 03:48:25 EDT 2025

Powered by FUDForum. Page generated in 0.03719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top