Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] JDT Template variable for save Method name

Hi,

I would like to develop a template variable that modifies given input
to a save Java method name (eg stripping/replacing special characters)
My Template should help providing JUnit5 tests in the form of

  @Test
  @DisplayName("some value = 123")
  public void some_value___123() {
  }

... where the content of DisplayString would be a variable and the
method name would be autogenerated from it. My template then looks like
this:

  @Test
  @DisplayName("${displayName}")
  public void ${displayName:toSaveMethodName}() throws Exception {
	${cursor}
  }

So I added my own VariableResolver 'toSaveMethodName' and registered it
with JDT. However it seems my resolver only gets called once in the
beginning when the template is applied. How do I get it called

a) either on any user input to my $displayString variable (preferred)
b) or at least after $displayString looses focus after the user input

to update the method name accordingly?

thanks
Christian





Back to the top