You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When nested classes are referenced within the classfile, a quick fix suggestionto import the nested class is show( to resolve the Nested class symbol). However, the quick fix simply doesnt import the shown fix.
Environment
Operating System: Manjaro Linux
JDK version: OpenJDK 11
Visual Studio Code version:1.61.0
Java extension version: 0.82.0
Steps To Reproduce
Create class file like below.
package com.dstyle.demo.resource;
import java.util.Iterator;
public class Example implements Iterable<Nested>{
public class Nested{}
@Override
public Iterator<com.dstyle.demo.resource.Nested> iterator() {
// TODO Auto-generated method stub
return null;
}
}
I can reproduce the issue in Eclipse IDE. Actually, the quickfix is wrong, you should not have to import the Nested class, as it's already inside the current one. The fix should be to change the code to public class Example implements Iterable<Example.Nested>.
Totally agreed @fbricon . Nested class needs to be accessed using parent class. But I see, that if you are referring the nested class/interface outside the class(lets say using a decorator) and compiler still allows to import nested class, the java extension behaves the same way.(Suggests to import the nested class but clicking on it will not import it).
For ex something like below, since nestedclass HystrixclientFallbackfactory class is referenced outside the class, an import scenario might arise. Personally am against this kind of usage, but I have seen people using it, and the language server simply doesnt import it properly at the moment.
@FeignClient(name = "hello", fallbackFactory = HystrixClientFallbackFactory.class)
protected interface HystrixClient {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
Hello iFailSometimes();
@Component
static class HystrixClientFallbackFactory implements FallbackFactory<HystrixClient> {
@Override
public HystrixClient create(Throwable cause) {
return new HystrixClient() {
@Override
public Hello iFailSometimes() {
return new Hello("fallback; reason was: " + cause.getMessage());
}
};
}
}
}
Nested Clasess are not Imported
When nested classes are referenced within the classfile, a quick fix suggestionto import the nested class is show( to resolve the Nested class symbol). However, the quick fix simply doesnt import the shown fix.
Environment
Steps To Reproduce
[Please attach a sample project reproducing the error]
Please attach logs
Log File:
ls.log
Current Result
A suggestion to Import nested class is shown, however quick fix doesnt import the nested class
Expected Result
The Nested class should be able to imported
Additional Informations
Gif demonstrating the issue:
The text was updated successfully, but these errors were encountered: