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

Base class methods are missing when generating override methods with source action. #3657

Closed
Kidsunbo opened this issue May 21, 2024 · 3 comments
Labels

Comments

@Kidsunbo
Copy link

[provide a description of the issue]
When instantiating an anonymous class, I would like to use source action to override some methods in the base class. But the methods in base class don't show up in the quick pick list.

Environment
  • Operating System: Ubuntu (24.04)
  • JDK version: 21
  • Visual Studio Code version: 1.89.1
  • Java extension version: 1.30.0

But this issue seems not related to the OS.

Steps To Reproduce
  1. [step 1]
    Creating a Java project with the following code:
public class App {
    public static void main(String[] args) throws Exception {
        System.out.println("Hello, World!");
        Base s = new Base(){

        };
    }
}


class Base{
    public void hello(){

    }

    public void hey(){
        
    }
}

  1. [step 2]

At the position of new Base(), right click and select Source Action and select Override/Implement Methods. There is no hello and hey in the options.
image

Current Result

No hey and hello

Expected Result

The two methods exist.

Additional Informations

I have already tried Eclipse and it work well for such operation.
image

@fbricon
Copy link
Collaborator

fbricon commented May 21, 2024

As a workaround, if you start typing he in the body of new Base(){ };, you should get completion to override those methods

@Kidsunbo
Copy link
Author

Kidsunbo commented May 21, 2024

As a workaround, if you start typing he in the body of new Base(){ };, you should get completion to override those methods

Thanks and I've taken this workaround. Not a big deal, but I think it's worth repairing. BTW, i find that it seems to be an upstream issue as the extension only wrap the result returned by the language server.

@fbricon fbricon added the bug label May 21, 2024
@Kidsunbo
Copy link
Author

As a workaround, if you start typing he in the body of new Base(){ };, you should get completion to override those methods

Sorry for the misleading, I found that it seems not to be a bug. If I right-click at the base class name, the language server searches the overridable methods of the outer class. When right-clicking between the braces of the base class, it works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants