-
Notifications
You must be signed in to change notification settings - Fork 47
Implement methods #199
base: master
Are you sure you want to change the base?
Implement methods #199
Conversation
efef6a7
to
bde624a
Compare
bde624a
to
2baf089
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfcoperez looks quite neat, but it needs part on scala-ide part I guess. Let me look at it
Thanks @wpopielarski for taking the time reviewing it! I thought that part would require a new PR, but not to this repo but to https://github.com/scala-ide/scala-ide . If that's the case, I can do it too. My plan is to bring this functionality to https://github.com/ensime/ensime-server too. |
""".stripMargin | ||
} applyRefactoring implementMethods | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, these tests are failing
@Test
def shouldNotModifyComments() = new FileSet() {
"""
|package implementMethods
|
|trait T {
| def t = 42
| def f(x: Int): String
|}
|
|object Obj extends /*(*/T/*)*/ { // don't remove this comment
|}
""".stripMargin becomes
"""
|package implementMethods
|
|trait T {
| def t = 42
| def f(x: Int): String
|}
|
|object Obj extends /*(*/T/*)*/ { // don't remove this comment
| def f(x: Int): String = {
| ???
| }
|}
""".stripMargin
} applyRefactoring implementMethods
@Test
def implementUnimplementedBackticksEvilMethod() = new FileSet() {
"""
|package implementMethods
|
|trait T {
| def `Zła metoda`: Int
|}
|
|object Obj extends /*(*/T/*)*/ {
| val doNotCutMeOut = 42
|}
""".stripMargin becomes
"""
|package implementMethods
|
|trait T {
| def `Zła metoda`: Int
|}
|
|object Obj extends /*(*/T/*)*/ {
| val doNotCutMeOut = 42
|
| def `Zła metoda`: Int = {
| ???
| }
|}
""".stripMargin
} applyRefactoring implementMethods
@Test
def implementUnimplementedSpecialMethod() = new FileSet() {
"""
|package implementMethods
|
|trait T {
| def :++: : Int
|}
|
|object Obj extends /*(*/T/*)*/ {
| val doNotCutMeOut = 42
|}
""".stripMargin becomes
"""
|package implementMethods
|
|trait T {
| def :++: : Int
|}
|
|object Obj extends /*(*/T/*)*/ {
| val doNotCutMeOut = 42
|
| def :++: : Int = {
| ???
| }
|}
""".stripMargin
} applyRefactoring implementMethods
} | ||
|
||
val transformation = topdown { | ||
matchingChildren { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I think that it will be quite hard to modify trees. The way how you determine unimplemented methods/fields from tree is done OK, but it is safer to modify source code directly, not its tree. There is scala.tools.refactoring.util.Movement
util to walk on source. Generally I have to look at this closer.
This PR tries to add
ImplementMethod
transformation aimed to offer a similar functionality to widespread IDEs, e.g:It works through
Selection
mechanism as follows: