intellij idea - Adding custom code generator -
when work types of files, such as: java file, html file or jasmine test file can generate useful code snippets using code > generate
option, example:
- if working java file
code > generate
allows me insert getter, setter, constructor etc - if working html file
code > generate
allows me insert xml tag - if working jasmine text file
code > generate
allows me insert scaffolding of test suit or singe test case
i wondering if (and how) can add own 'generator'. know can use live templates, fact code > generate
gives me quick list of available generators.
yes, can writing intellij plugin , extending class:
com.intellij.openapi.actionsystem.action
if create intellij plugin project (just google intellij plugin development
for information on how started), hit alt-enter somewhere in project source tree , select action
, dialog allows configure action should appear.
you want place in relation action exists, example right below it. in case - have @ menu group named generategroup (generate)
.
once action defined in manner in plugin.xml, build , run plugin in sandbox.
now, when action triggered, anactionevent
fired contains references necessary information need (current project, file, position of cursor within file, psi tree, etc).
try working far , come specific questions.
good luck!
Comments
Post a Comment