Fully qualified type name inserted in private final field declaration instead of import + simple name (disregarding workspace preference)
Variation of #866.
Consider this class:
package test50
class Test50 {
String foo
private final TreeNode|
}
Invoke code assist at "|" and choose javax.swing.tree.TreeNode.
Once again, the fully qualified name is inserted instead of the import declaration.
Different path through the parser. I'll see what I can do...
The trouble is, Groovy considers this a complete field declaration:
@groovy.transform.ToString(includeFields=true)
class C {
protected field
}
def cee = new C(field: 'value')
println cee
http://docs.groovy-lang.org/latest/html/documentation/#fields
But isn't "final" some kind of reserved word?
The type is optional. So the parser interprets "private final TreeNode" as a field named "TreeNode" of type Object.
I keep on hitting this problem. The presence of private (even without final) is sufficient to trigger it. I understand the cause (the parser interprets "private TreeNode" as a field named "TreeNode"), but once content assist is triggered and confirmed, why should it ignore the option to insert the import statement instead of the FQN? After all, if the insertion is performed, in some way the tools is recognizing TreeNode as a type at that time...