-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
What problem are you trying to solve?
Currently, the AddMissingMethodImplementation checks primarily for existing method declarations on the visited class declaration. It does not check whether the visited class has a superclass which already provides an implementation of the relevant method.
What precondition(s) should be checked before applying this recipe?
Existing recipe, no suggested precondition changes
Describe the situation before applying the recipe
// surrounding code
interface MyInterface {
void foo();
void bar();
}
class MyBaseClass implements MyInterface {
public void bar() {}
}
// code for the recipe to actually visit
class MyClass extends MyBaseClass {
}Describe the situation after applying the recipe
If we run a recipe like this:
- org.openrewrite.java.migrate.AddMissingMethodImplementation:
fullyQualifiedClassName: MyInterface
methodPattern: "*..* foo()"
methodTemplateString: "public void foo() { /* added */ }"...then we would get this:
class MyClass extends MyBaseClass {
public void foo() { /* added */ }
}But if we run this
- org.openrewrite.java.migrate.AddMissingMethodImplementation:
fullyQualifiedClassName: MyInterface
methodPattern: "*..* bar()"
methodTemplateString: "public void bar() { /* added */ }"...then we would get no change, because MyClass already has an implementation of bar() from MyBaseClass.
Have you considered any alternatives or workarounds?
This behavior could also be disabled with a new option (default enabled)
Any additional context
Are you interested in contributing this recipe to OpenRewrite?
Maybe eventually; could also be a good first issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Type
Projects
Status
Done