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.
Please sign in to leave a comment.
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!"
What if the two classes already exist?
I want to modify an existing class to derive from another existing class.
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!"
Aaron Ash wrote:
psiClass.getExtendsList().add(reference)
or psiClass.getExtendsList().replace(list)
,where list comes from extendsList of a class created from text.
Thanks, that fixed it. :)
How to automatically generate the abstract method implementations and interface methods of super class?????