extract method question

hi jetbrains scala plugin team,

how exactly is "extract method" supposed to work? for me, it basically does the same as "ctrl+w", then stop at a certain level and surround it with def name = {...}
is the feature not done yet?

3 comments
Comment actions Permalink

HoD,

I just made a quick random attempt in some code of mine, and it seemed to work just fine. After selecting the code to be extracted and issuing the command, you first pick the scope at which the new definition is to be placed (I chose "class", though this was in fact an object). Then you're presented with a dialog in which you specify the method's name, its arguments and the argument order. When you confirm the dialog the extracted method is added and a call to it replaces the code you'd selected. It also undoes in one go. All very nice and what you'd expect.

I have never used this before, either in Scala or Java (which I did quite a bit in IDEA before taking up Scala), but this seems to be working correctly, at least for my little test.


Versions:

  • Scala Plug-in 0.3.1673
  • IDEA: Ultimate 9.0.3 EA (IU-95.260)
  • JVM: 1.7.0-ea-b95
  • OS: Linux 2.6.27
  • arch: x86



Randall Schulz

0
Comment actions Permalink

i expected the scope to be the code that should be extracted and took the smalltest one each time ;D

0
Comment actions Permalink

It uses control flow to find which variables used in selected scope and which variables used after scope. Then extract method work using this information.
If you use extract method only for smallest scope, then no parameters needed for extract method, because all variables known in this scope.

0

Please sign in to leave a comment.