About PsiField initial value problem!

I want to add or change or delete in the initial value

But sometime the psifield.getInitializer() may be null
so how can i add a new initializer to the psifield?

And

getManager().getElementFactory().createExpressionFromText(String text,Psielement element);

The element parameter is for what?

Thx

6 comments
Comment actions Permalink

PeterGC wrote:

I want to add or change or delete in the initial value

But sometime the psifield.getInitializer() may be null
so how can i add a new initializer to the psifield?

And

getManager().getElementFactory().createExpressionFromText(String
text,Psielement element);

The element parameter is for what?


The is a context to resolve references in 'text'

Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

So How about when the getInitializer() return null,
how can i add a new initializer to the psifield?

0
Comment actions Permalink

On Tue, 27 Jan 2004 12:46:19 +0300, Dmitry Lomov (JetBrains) wrote:

>> getManager().getElementFactory().createExpressionFromText(String
>> text,Psielement element);
>>
>> The element parameter is for what?


The is a context to resolve references in 'text'


Sorry for thread hijacking, but. When ever I addBefore() a PsiDocComment,
I see the comment appear in the code, but then I get hit with a "Text
block not empty" exception, which no hint as to -what- text block its
referring to.

I'm using the following:

commentString = "/**\n * some comment\n */";
element = elementFactory.createCommentFromText(commentString, null);

method.addBefore(element, method.getFirstChild());

PsiDocumentManager pdm = PsiDocumentManager.getInstance(project);
pdm.commitDocument(documentEvent.getDocument());


I have a suspicion that the problem lies in the method.getFirstChild()
maybe.

Mark


0
Comment actions Permalink

Mark Derricutt wrote:

On Tue, 27 Jan 2004 12:46:19 +0300, Dmitry Lomov (JetBrains) wrote:

>>> getManager().getElementFactory().createExpressionFromText(String
>>> text,Psielement element);
>>>
>>> The element parameter is for what?
>>
>> The is a context to resolve references in 'text'


Sorry for thread hijacking, but. When ever I addBefore() a PsiDocComment,
I see the comment appear in the code, but then I get hit with a "Text
block not empty" exception, which no hint as to -what- text block its
referring to.

I'm using the following:

commentString = "/**\n * some comment\n */";
element = elementFactory.createCommentFromText(commentString, null);

method.addBefore(element, method.getFirstChild());

PsiDocumentManager pdm = PsiDocumentManager.getInstance(project);
pdm.commitDocument(documentEvent.getDocument());


I have a suspicion that the problem lies in the method.getFirstChild()
maybe.


Mark,
you should commit document before any modifications to PSI.

Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

On Tue, 27 Jan 2004 13:55:25 +0300, Dmitry Lomov (JetBrains) wrote:

you should commit document before any modifications to PSI.


Excellent, you're the man :) How about changing the assert to saying that ;)

0
Comment actions Permalink

Excellent, you're the man :) How about changing the assert to saying that

;)

Done.

--
Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


"Mark Derricutt" <mark@talios.com> wrote in message
news:pan.2004.01.27.18.51.29.240357@talios.com...

On Tue, 27 Jan 2004 13:55:25 +0300, Dmitry Lomov (JetBrains) wrote:

>

you should commit document before any modifications to PSI.

>

Excellent, you're the man :) How about changing the assert to saying that

;)
>


0

Please sign in to leave a comment.