I want to create a plugin which defines a new code template (like this blog post). How can I pass a parameter into the template? like ${name:param}?
I want to create a plugin which defines a new code template ( like
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There aren’t many things that you can pass into a code template. For example
${word_selection}contains the current selection.But what many people are missing is that you can define your own variables:
Neither
${type}nor${name}are in the list which you get when you click the “Insert variable…” button. Eclipse notices and allows you to cycle through them with Tab and it will keep the content of these custom “template fields” in sync (so you the part afternewgets filled in if you type in the first field).See this answer for other useful Eclipse templates.
[EDIT] According to the answers in the blog post which you mention, this is only possible at the moment with editor templates, not code templates. I suggest to file a bug against JDT Text to open the API for this.