Updating my Plugin, getPsiFileInEditor() is gone
I am finally getting around to update my plugin to work with IntelliJ 11 (yes I am a procrastinator), I have code that has worked up until IntelliJ 11 for getting the Class that is in the current editor. The method I was using getPsiFileInEditor(Editor, Project) is no longer in the plugin SDK. Does anyone know the equivalent method call now?
private PsiClass getClassInCurrentEditor() { PsiClass currentClass = null; final Editor editor = FileEditorManager.getInstance(this.project).getSelectedTextEditor(); if (editor != null) { final PsiJavaFile javaFile = (PsiJavaFile) PsiUtil.getPsiFileInEditor(editor, this.project); //This method is no longer available if (javaFile != null) { final PsiElement element = javaFile.findElementAt(editor.getCaretModel().getOffset()); //final PsiElement element = javaFile.findElementAt(0); currentClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); } } return currentClass; }
Please sign in to leave a comment.
How about PsiUtilBase.getPsiFileInEditor(Editor, Project) ?
Thanks! Calling the method from PsiUtilBase instead of PsiUtil did the trick.