[regression] Code actions unrelated to diagnostics are ignored
- given a basically empty class Bar.java
public class Bar {
}
- and a class Foo.java:
public class Foo {
public static void main(String[] args) {
new Bar().thatField;
}
}
"thatField" should have a code action to generate the field in Bar, but no code action is returned. Server log:
[Trace - 5:58:54 PM] Sending request 'textDocument/codeAction - (629)'.
Params: {
"textDocument": {
"uri": "file:///Users/fbricon/Downloads/test/src/main/java/Foo.java"
},
"range": {
"start": {
"line": 7,
"character": 21
},
"end": {
"line": 7,
"character": 21
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 7,
"character": 18
},
"end": {
"line": 7,
"character": 23
}
},
"message": "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression",
"severity": 1,
"code": "1610612976",
"source": "Java"
}
]
}
}
[Trace - 5:58:54 PM] Received response 'textDocument/codeAction - (629)' in 2ms.
Result: []
UnresolvedVariablesQuickFixTest.testBug300 (although it's broken), checks a code action for that case is sent, when there's no diagnostics info attached to the query
I think the main part of this bug no longer happens; when I write the code you suggest, the code action appears and can be applied. Also the test you referenced is enabled.
However, the code action generates a public static field instead of just a public field as the code action name and the way the code is structured would suggest. Maybe this is intentional, but this seems like a bug.
However, the code action generates a
public staticfield ...
This happens in Eclipse as well
with new App().thatField = 5;, the generated field is static with jdt.ls, not static in Eclipse. Something's fishy here.