Caret on a new empty line

I'm creating a new method, and adds a code block with an empty line:

final PsiCodeBlock codeBlock = factory.createCodeBlockFromText("{\n\n}", newMethod);
PsiCodeBlock newMethodCodeBlock = PsiTreeUtil.findChildOfType(newMethod, PsiCodeBlock.class);

After adding it to a class, I would like to navigate to the new line, but it doesn't seems to exist in the syntax tree (I have 2 PsiJavaToken for { and } but nothing else, so I can navigate only to one of those).
Would anybody know of a way to navigate to the empty line?

1 comment
Comment actions Permalink

Figured that it was a complex job... Actually, seems like one way to go is something like adding a ";", navigating to it, selecting it and removing selection.
Also seems like

GenerateMembersUtil.positionCaret(editor, method)

can do the job for you... So I'm writng it here for future reference.


Please sign in to leave a comment.