eclipse-jdtls / eclipse.jdt.ls

Java language server
1.74k stars 388 forks source link

[regression] Code actions unrelated to diagnostics are ignored #908

Open fbricon opened 5 years ago

fbricon commented 5 years ago

"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

datho7561 commented 1 year ago

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.

datho7561 commented 1 year ago

However, the code action generates a public static field ...

This happens in Eclipse as well