redhat-developer / lsp4ij

LSP Client for IntelliJ
Eclipse Public License 2.0
113 stars 25 forks source link

Error is displayed only after some action #308

Closed KUGDev closed 6 months ago

KUGDev commented 6 months ago

The issue: When I write some code that declares some PL/I specific instruction, IntelliJ does not display it right after I make a mistake image Only after some action (e.g. refocus/change current window) the error appear image

Prereqs: https://github.com/zowe/zowe-pli-language-support/tree/feature/intellij-pli-poc intellij-plugin folder, where the fix could be tested LSP server + TextMate bundle as Node.js application, generated by Langium Node.js v18.16.0 image

angelozerr commented 6 months ago

The validation error is managed with publish diagnostics.

I suggest that you enable LSP traces from LSP console as verbose https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserGuide.md#lsp-console and check you have publish diagnostics.

Could you share please your LSP traces.

KUGDev commented 6 months ago

trace.txt 14:50:08 - opened the file 14:50:11 - did the change 14:50:15 - changed the current window

fbricon commented 6 months ago

your LS publishes diagnostics when it receives a textDocument/didSave event. IJ only saves the file when it goes out of focus, or you manually hit Ctrl+S/Cmd+S

KUGDev commented 6 months ago

Ok, thank you guys We will be investigating the issue on the LSP server part then

angelozerr commented 6 months ago

Indeed, you can see that in your LSP traces. When you open, change your document, your LS send empty publish diagnostics:

[Trace - 14:50:11] Received notification 'textDocument/publishDiagnostics'
Params: {
  "uri": "file:///c%3A/Users/Admin/Desktop/Demo/demo1.pl1",
  "diagnostics": []
}

And when you save the file (with Ctrl+S or when you go to the outside of IJ IDE (IJ auto save the file when it lost focus)), you can see that your language server reports non empty diagnostics:

[Trace - 14:50:15] Sending notification 'textDocument/didSave'
Params: {
  "textDocument": {
    "uri": "file:///C:/Users/Admin/Desktop/Demo/demo1.pl1"
  },
  "text": "person pli\nHello pli1!"
}

[Trace - 14:50:15] Sending notification 'workspace/didChangeWatchedFiles'
Params: {
  "changes": [
    {
      "uri": "file:///C:/Users/Admin/Desktop/Demo/demo1.pl1",
      "type": 2
    }
  ]
}

[Trace - 14:50:15] Received notification 'textDocument/publishDiagnostics'
Params: {
  "uri": "file:///c%3A/Users/Admin/Desktop/Demo/demo1.pl1",
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 1,
          "character": 6
        },
        "end": {
          "line": 1,
          "character": 10
        }
      },
      "severity": 1,
      "source": "pl-one",
      "message": "Could not resolve reference to Person named \u0027pli1\u0027.",
      "data": {
        "code": "linking-error",
        "containerType": "Greeting",
        "property": "person",
        "refText": "pli1"
      }
    }
  ]
}

You will have the same problem with vscode.

Your language server needs to report diagnostics onDidChange.

In other words, I suggest that you use the LSP console to understand the behavior of your language server.

angelozerr commented 6 months ago

@KUGDev if you think LSP4IJ is good for you, could you create a PR to add your project in https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#who-is-using-lsp4ij

Thanks!

KUGDev commented 6 months ago

@angelozerr yes, I though about that We are investigating the client for some other things also, later I'm going to try to use it with the COBOL LSP server by Broadcom (as I mentioned here) If everything is fine, we are going to create a PR to add not only the PL/I's repo to the list, but the COBOL for IntelliJ IDEA also

angelozerr commented 6 months ago

Hope you will be happy with lsp4ij!

angelozerr commented 6 months ago

If everything is fine, we are going to create a PR to add not only the PL/I's repo to the list, but the COBOL for IntelliJ IDEA also

@MituuZ I think you could be interested with the @KUGDev plugin.

KUGDev commented 6 months ago

Hey @angelozerr I recommend adding your project here https://langserver.org/ under LSP client for IntelliJ section