Plugin Development for CLion: How to add a method call to an existing method
Hi,
I am currently learning about how to write plugins for IntelliJ IDEs. I am especially interested in writing plugins for CLion.
I am trying to find a way how to add a method call to the top of the body of an existing method.
I already found a way to get the Function Definitions in a File.
psiFile.accept(new PsiRecursiveElementWalkingVisitor(){
@Override
public void visitElement(PsiElement element) {
super.visitElement(element);
//OCFunctionDefinition test = new OCFunctionDefinition();
if(element instanceof OCFunctionDefinition){
infoBuilder.append(element.getText()).append("\n");
element.add(elementAtCarret);
}
}
});
I read in the documentation that I can create new PsiFiles via PsiFileFactory.
For Java I could get a Factory with:
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
Is there also a Factry for c++? Something like:
PsiElementFactory factory = OcPsiFacade.getInstance(project).getElementFactory();
Also is this approach in general the right one, for adding a method call to an existing method body?
Please sign in to leave a comment.