redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.05k stars 420 forks source link

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

Closed Kidsunbo closed 1 month ago

Kidsunbo commented 1 month ago

[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

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(){

}

}



2. [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](https://github.com/redhat-developer/vscode-java/assets/12459780/71aa4b50-6065-4ede-b541-9d217624fb23)

##### 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](https://github.com/redhat-developer/vscode-java/assets/12459780/c1168052-5de1-4811-ad6b-9152e87d0114)
fbricon commented 1 month ago

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

Kidsunbo commented 1 month ago

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.

Kidsunbo commented 1 month ago

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.