How to make a PsiClass derive from another one?

Hello,

How do you make a PsiClass derive from another PsiClass?
I can't seem to find an element that the elementFactory creates that would be suitable for it (to do psiClass.add( parentClassElement) or something similiar) and i've searched a bit on the forums here and can't seem to find out how to do it.

Is it possible to do this?

thanks,
Aaron.

6 comments

Hello Aaron,

AA> How do you make a PsiClass derive from another PsiClass?
AA>
AA> I can't seem to find an element that the elementFactory creates that
AA> would be suitable for it (to do psiClass.add( parentClassElement) or
AA> something similiar) and i've searched a bit on the forums here and
AA> can't seem to find out how to do it.
AA>
AA> Is it possible to do this?

You can simply call createClassFromText() with text like "class A extends
B { }".

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

What if the two classes already exist?
I want to modify an existing class to derive from another existing class.

0

Hello Aaron,

AA> What if the two classes already exist?
AA> I want to modify an existing class to derive from another existing
AA> class.

psiClass.getExtendsList().add(psiElementFactory.createReferenceElementByType(psiClassType));

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Aaron Ash wrote:

What if the two classes already exist?
I want to modify an existing class to derive from another existing class.


psiClass.getExtendsList().add(reference)

or psiClass.getExtendsList().replace(list)

,where list comes from extendsList of a class created from text.

0

How to automatically generate the abstract method implementations and interface methods of super class?????

0

Please sign in to leave a comment.