Remove PsiElements

I have met some problem with removing field's initial value (class members
also).
Actually I don't know the correct way how to do this, but I have tried to
make replacement "PsiField.getInitializer().replace(EmptyStatment)". Seems
to be correct solution, but I haven't find way to create "EmptyStatment" (
PsiManager.getElementFactory().createExpressionFromText("", null) doesn't
like empty string ).

Thank you for help,
--
Egidijus Vaisnora



6 comments
Comment actions Permalink

Use PsiField.getInitializer().delete() instead.
(Inside Application.runWriteAction() of course)

--
regards,
Alexey Kudravtsev.
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"


"Egidijus Vaisnora" <Egidijus.Vaisnora@nomagic.com> wrote in message news:bgvl4m$qcd$1@is.intellij.net...

I have met some problem with removing field's initial value (class members
also).
Actually I don't know the correct way how to do this, but I have tried to
make replacement "PsiField.getInitializer().replace(EmptyStatment)". Seems
to be correct solution, but I haven't find way to create "EmptyStatment" (
PsiManager.getElementFactory().createExpressionFromText("", null) doesn't
like empty string ).

>

Thank you for help,
--
Egidijus Vaisnora

>
>
>


0
Comment actions Permalink

Hmmm... quite simple... ;)

--
Egidijus Vaisnora



0
Comment actions Permalink

How PsiField can be supplied with initial value, when
"PsiField.getInitializer() == null"?

When initialization is not "null" it can be changed with "replace" method to
the created expression, but with "null" I find only way to create
expression, step through child element searching ";" and insert before ";".
Event than, seems there is no way to create "PsiJavaToken" to represent "="
value.

--
Egidijus Vaisnora



0
Comment actions Permalink

Seems to be no way - missing feature. In fact, we plan to rework
write-methods of PSI to provide more specific methods like "addParameter",
"setInitializer" etc.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Egidijus Vaisnora" <Egidijus.Vaisnora@nomagic.com> wrote in message
news:bh02aa$9i3$1@is.intellij.net...

How PsiField can be supplied with initial value, when
"PsiField.getInitializer() == null"?

>

When initialization is not "null" it can be changed with "replace" method

to

the created expression, but with "null" I find only way to create
expression, step through child element searching ";" and insert before

";".

Event than, seems there is no way to create "PsiJavaToken" to represent

"="

value.

>

--
Egidijus Vaisnora

>
>
>


0
Comment actions Permalink


Would be great!
When are you planning to rework these methods?

--
Egidijus Vaisnora



0
Comment actions Permalink

When are you planning to rework these methods?


Not defined yet. We planned to do this for Aurora but I'm not sure it's
realistic plan.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"


"Egidijus Vaisnora" <Egidijus.Vaisnora@nomagic.com> wrote in message
news:bhcstj$gqd$1@is.intellij.net...
>

Would be great!
When are you planning to rework these methods?

>

--
Egidijus Vaisnora

>
>
>


0

Please sign in to leave a comment.