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.

0
6 comments
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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

Thanks, that fixed it. :)

0
Avatar
Permanently deleted user

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

0

Please sign in to leave a comment.