redhat-developer / vscode-java

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

Auto completion for method override returns null #1526

Open testforstephen opened 4 years ago

testforstephen commented 4 years ago

Sample project - MapReduceDemo.zip

VSC

thanks!

Originally posted by @xuerui911 in https://github.com/microsoft/vscode-java-pack/issues/452#issuecomment-658722953

testforstephen commented 4 years ago

Can reproduce with the sample code. Looks like the Java extension is not sufficiently good fault tolerance.

The original sample code contains two compilation errors: Missing package declaration and the import Display.Text not visible to current class. Typing map, the triggered completion list contains an overridden method map(), but clicking it failed to apply the text edit.

Fix these compilation errors and auto completion for map works. But there are still room for improvement.

rgrunber commented 11 months ago

This has improved slightly on latest version. Here's what I see as the generated method declaration with the given visibility error on Text :

Note that this is the formatted declaration, as the actual content is all on one line.

protected void map(LongWritable key, Text value,
            org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, IntWritable>.Context context)
            throws IOException, InterruptedException {
};

Still missing the super invocation & @Override

I agree that we should investigate a way to not suggest imports that are not visible, and ensure "Organize Imports" can correct this.