psiStatement.addAfter().getText() behaviour.. is this normal?

After adding a statement after another one, the first one's text seems
to contain both.

question 1 :
Is this normal?


PsiStatement currentStatement = ..
PsiStatement newStatement = ..
currentStatement.addAfter( newStatement, null );
String statementText = currentStatement.getText();

=>
statementText = "String xxx = \"deux\";\n\t assertEquals( \"un\",
\"deux\", \"trois\" );"


question 2:
what's the role of the 2nd parameter in addAfter(..,..)?

Alain

0
5 comments
Avatar
Permanently deleted user

This would be right scenario:

PsiStatement currentStatement = ..
PsiStatement newStatement = ...
PsiElement block = currentStatement.getParent();
block.addAfter(newStatement, currentStatement);


cause 2nd parameter is anchor and addAfter should be invoked on parent to
add child to.
--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Alain Ravet" <alain.ravet.list@wanadoo.be> wrote in message
news:bf6pe3$92k$1@is.intellij.net...

After adding a statement after another one, the first one's text seems
to contain both.

>

question 1 :
Is this normal?

>
>

PsiStatement currentStatement = ..
PsiStatement newStatement = ..
currentStatement.addAfter( newStatement, null );
String statementText = currentStatement.getText();

>

=>
statementText = "String xxx = \"deux\";\n\t assertEquals( \"un\",
\"deux\", \"trois\" );"

>
>

question 2:
what's the role of the 2nd parameter in addAfter(..,..)?

>

Alain

>


0
Avatar
Permanently deleted user

Thanks

0
Avatar
Permanently deleted user

You would not get these questions if we had the name of the parameters.
You talked about delivering the javadoc or the source of the interfaces. Can we expect this soon? If not can we file a request for that?

Jacques

0
Avatar
Permanently deleted user

Yes, I've asked for this too. This would be very valuable.

0
Avatar
Permanently deleted user

+1 for the javadocs!

I wasted half a day on a misunderstanding of one the parameters.

0

Please sign in to leave a comment.