Psi Class loader conversion from Intellij Plugin SDK to Resharper SDK
I have the following code and I am trying to convert this piece of code into Resharper. is there a possibility I can write a code of similar functionality ?
Functionality: This code opens a class selector Dialog and loads all the classes of the current project. on the selection of the class, it returns the PsiClass object which contains information about the selected class.
public PsiClass chooseClass(Project project, PsiClass defaultClass) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
.createProjectScopeChooser("Select a Class", defaultClass);
chooser.showDialog();
return chooser.getSelected();
}
public PsiClass chooseClass(AnActionEvent anActionEvent) {
Project project = getProject(anActionEvent);
PsiClass defaultClass = getPsiClass(anActionEvent);
return chooseClass(project, defaultClass);
}
public PsiClass getPsiClass(AnActionEvent anActionEvent) {
PsiFile psiFile = anActionEvent.getData(LangDataKeys.PSI_FILE);
Editor editor = anActionEvent.getData(PlatformDataKeys.EDITOR);
if (psiFile == null || editor == null) {
return null;
}
int offset = editor.getCaretModel().getOffset();
PsiElement element = psiFile.findElementAt(offset);
return PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
Please sign in to leave a comment.
Hello Zubayr Bhutta, thank you for your question. Please take a look at these articles, I hope they will be useful:
If this doesn't help, please let us know. Thank you!
Hi Maria, Thanks a lot for reaching out to my post.
I already checked the samples and also tried to read the SDK documentation. Unfortunately did not get much support on what I am trying to achieve.
My goal is to have a Class finder dialog in ReSharper. I can activate it in Java using IntelliJ Plugin SDK but in ReSharper, I have tried anything but I am not able to achieve it. Please also consider that I am very new to Resharper.