0

I was exploring through eclipse templates to create public constants. it's had a post fix context. I can understand simple templates, but below public constant template is out of my understanding level. Can anyone please explain below template.

${n:newField(i, true, true, true, true)}${i:inner_expression(novalue)}${cursor}

enter image description here

Ajay Kumar
  • 45
  • 8
  • When in the preferences _Java > Editor > Content Assist > Advanced_ the _Java Postfix Template Proposals_ are enabled (which they are not by default), then you could type for example `"foo".constpup` to apply the refactoring _Extract Constant_ to `"foo"`. Is that what you were asking for? – howlger Nov 28 '22 at 08:25
  • Thank you for response @howlger. I tried `"foo".constpup` . It worked like a charm :). I want to understand what newField, inner_expression or novalue means. Can you please refer any documentation where these are defined. – Ajay Kumar Nov 28 '22 at 09:06
  • Since the UI lacks information/documentation on this topic, you have to look into the code: `newField` creates a new field for `i` with [this boolean options](https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/9d4e8ecc47ba06fa06eaa9c2f6c535503ac4d6df/org.eclipse.jdt.ui/core%20extension/org/eclipse/jdt/internal/corext/template/java/NewFieldResolver.java#L106-L109) where `i` is taken from the [`inner_expression`](https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/master/org.eclipse.jdt.ui/core%20extension/org/eclipse/jdt/internal/corext/template/java/InnerExpressionResolver.java). – howlger Nov 28 '22 at 09:36
  • It would be great if you could contribute a pull request with the missing information. Let me know if you need help with this. – howlger Nov 28 '22 at 09:39

0 Answers0