Extract method in custom languages

I just hit Ctrl-M and IDEA either complains that the selection is
not an expression, or (if the selection referes to an valid PsiMember)
an exception is thrown (see below).
It's an nice idea to implicitly allow this but the refactorings are
not prepared for this :(

com.intellij.psi.impl.file.PsiDirectoryImpl
java.lang.ClassCastException: com.intellij.psi.impl.file.PsiDirectoryImpl
at
com.intellij.refactoring.extractMethod.ExtractMethodProcessor.f(ExtractMethodProcessor.java:463)
at
com.intellij.refactoring.extractMethod.ExtractMethodProcessor.prepare(ExtractMethodProcessor.java:359)
at
com.intellij.refactoring.extractMethod.ExtractMethodHandler.a(ExtractMethodHandler.java:2)
at
com.intellij.refactoring.extractMethod.ExtractMethodHandler.invoke(ExtractMethodHandler.java:44)
at
com.intellij.refactoring.actions.BaseRefactoringAction.actionPerformed(BaseRefactoringAction.java:21)
at
com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:55)
at
com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:140)
at
com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:171)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:116)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:37)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

2 comments

Hi Sven,

Can you be more specific? What are you trying to extract? Could you give the entire method you are trying to extract from, and what the selection is in that method?

-e

0

I have selected an textrange which is resolved to an PsiMethod.
Being used to extracting methods from complex expressions I hit Ctrl-M
and the given exception occured.
So either Ctrl-M should be disabled for custom languages or the
underlying functionality should be robust enough to deal with it.


Emerson schrieb:

Hi Sven,

Can you be more specific? What are you trying to extract? Could you give the entire method you are trying to extract from, and what the selection is in that method?

-e

0

Please sign in to leave a comment.