Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[javac] fix quickfix to implement inherited abstract methods #376

Conversation

datho7561
Copy link

  • add mapping for error id for missing abstract method implementations
  • fixed an NPE that would prevent the error from being shown on anonymous classes
  • fix binding logic for anonymous classes

example to try out: use the quickfix to add a stub implementation of method() to the anonymous class:

public class Parent {

  static interface IMethodable {
    void method();
  }

  public static void myMethod() {
    IMethodable methodable = new IMethodable() {
    };
    methodable.method();
  }

}

Future work: fix the diagnostic range on anonymous classes. We might need access to the AST, since we ideally want to highlight IMethodable from the constructor invocation.

@datho7561 datho7561 force-pushed the dom-with-javac-anonymousclass-errors branch from 8442e39 to b861602 Compare May 10, 2024 20:47
@datho7561
Copy link
Author

datho7561 commented May 10, 2024

After the rebase, the return type in the generated method is now generated as invalid instead of void. I'll need to look further into it.

UPDATE: got it, void should be considered a primitive type.

- add mapping for error id for missing abstract method implementations
- fixed an NPE that would prevent the error from being shown on
  anonymous classes
- fix binding logic for anonymous classes

example to try out: use the quickfix to add a stub implementation of
method() to the anonymous class:

```java
public class Parent {

  static interface IMethodable {
    void method();
  }

  public static void myMethod() {
    IMethodable methodable = new IMethodable() {
    };
    methodable.method();
  }

}
```

Future work: fix the diagnostic range on anonymous classes. We might
need access to the AST, since we ideally want to highlight `IMethodable`
from the constructor invocation.

Signed-off-by: David Thompson <[email protected]>
@datho7561 datho7561 force-pushed the dom-with-javac-anonymousclass-errors branch from b861602 to 1d05d8c Compare May 10, 2024 21:06
@mickaelistria mickaelistria merged commit eaf1d25 into eclipse-jdtls:dom-with-javac May 10, 2024
2 of 4 checks passed
@datho7561 datho7561 deleted the dom-with-javac-anonymousclass-errors branch January 2, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants