April 01, 2005 16:49
Java
Dear Lazyweb,

I wish to define my own template parameters in Eclipse, in the manner of ${date}, ${year} and ${enclosing_method}. Please provide me with an Eclipse plugin which makes use of the org.eclipse.ui.editors.templates package.

Specifically, I want to be able to insert variables with the parameters passed in on a method, so that given a method:

public void foo(String pBar, String pBaz) {


}

I can produce the following automatically:

if (isLoggingDebug()) {
    String msg = "foo: pBar = {0}, pBaz = {1}";
    Object[] params = { pBar, pBaz };
    msg = java.text.MessageFormat.format(msg, params);
    logDebug(msg);
}

I can get tantalizingly close with ${enclosing_method_arguments}, but I don't have the " = ${parameter_index} " that I would need.

Really, to get this to work, I would have to be able to chain templates together. Have a variable which resolves out to several smaller variables, and be able to define subsections according to the AST.

If someone could write this for me, I'd be much obliged.

Thanks,
Will.

EDIT: okay, it looks like Log4E will do this. To use this for ATG Dynamo, you have to copy the log4j template and change the copy to use the ApplicationLogging interface, disable the declaration and imports, and then use "this" as the logger. From there, it will give you a wizard that shows you all of the parameters and local variables and let you construct a logging statement incorporating any or all of them. Here's an example from picking out a couple:

if (this.isLoggingDebug()) {
    this.logDebug("deletePurchaseItem(String pPurchaseId = "
     + pPurchaseId + ") - Hello world! : staticItem = "
     + staticItem);
}

« Keyboard driven Eclipse | Home | Escape oparam scope »

name
url