Open testforstephen opened 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.
Text
, should filter out org.apache.hadoop.fs.shell.Display.Text
from auto import choices because the class Display
is not public and not visible to the user code.map
again. Although auto completion will generate the method override code, but the generated override method is not good enough.
Current one:
@Override
protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context)
throws IOException, InterruptedException {
// TODO Auto-generated method stub
super.map(key, value, context);
}
A better one should be:
@Override
protected void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
// TODO Auto-generated method stub
super.map(key, value, context);
}
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.
Sample project - MapReduceDemo.zip
thanks!
Originally posted by @xuerui911 in https://github.com/microsoft/vscode-java-pack/issues/452#issuecomment-658722953