jdneo / vscode-checkstyle

Checkstyle extension for VS Code
https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle
GNU Lesser General Public License v3.0
69 stars 16 forks source link

Does not work on VS Code start until setting.json modified #341

Closed jamesdu-ms closed 1 year ago

jamesdu-ms commented 1 year ago

Checkstyle does not work (does not highlight errors) each time VS Code is started.

It can be triggered to work by editing a setting, e.g. java.checkstyle.version to a different value, which I assume triggers checkstyle to restart. The actual version selected doesn't matter, when VS Code is closed and reopened it will not work again until editing the setting.json again.

The output window of Checkstyle shows the following exception, which I assume is the root of the problem: TypeError: Cannot read properties of undefined (reading 'sendRequest') at /home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:698767 at l.h (/.vscode-server/bin/92da9481c0904c6adfe372c12da3b7748d74bdcb/out/vs/workbench/api/node/extensionHostProcess.js:96:108784) at l.g (/.vscode-server/bin/92da9481c0904c6adfe372c12da3b7748d74bdcb/out/vs/workbench/api/node/extensionHostProcess.js:96:107674) at l.executeCommand (/.vscode-server/bin/92da9481c0904c6adfe372c12da3b7748d74bdcb/out/vs/workbench/api/node/extensionHostProcess.js:96:107574) at Object.executeCommand (/.vscode-server/bin/92da9481c0904c6adfe372c12da3b7748d74bdcb/out/vs/workbench/api/node/extensionHostProcess.js:117:30781) at Object.t.executeJavaLanguageServerCommand (/home/vscode/.vscode-extensions/shengchen.vscode-checkstyle-1.4.1/dist/extension.js:9:73370) at Object.syncServer (/home/vscode/.vscode-extensions/shengchen.vscode-checkstyle-1.4.1/dist/extension.js:1:82769) at Object.refresh (/home/vscode/.vscode-extensions/shengchen.vscode-checkstyle-1.4.1/dist/extension.js:1:81481) at async Object.initialize (/home/vscode/.vscode-extensions/shengchen.vscode-checkstyle-1.4.1/dist/extension.js:1:79616) at async m (/home/vscode/.vscode-extensions/shengchen.vscode-checkstyle-1.4.1/dist/extension.js:29:20243)

Errors from Dev Tools Console: [[object Object]]Connection got disposed. $onExtensionRuntimeError @ mainThreadExtensionService.ts:79 mainThreadExtensionService.ts:80 Error: Connection got disposed. at Object.dispose (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1051095) at Object.dispose (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:898091) at b.handleConnectionClosed (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:898279) at b.handleConnectionClosed (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:971911) at t (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:896393) at invoke (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1052721) at s.fire (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1053482) at Q (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1040234) at invoke (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1052721) at s.fire (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1053482) at p.fireClose (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1061373) at Socket. (/home/vscode/.vscode-extensions/redhat.java-1.15.0-linux-x64/dist/extension.js:2:1062958) at Socket.emit (node:events:538:35) at Pipe. (node:net:687:12)

This is on MacOS 12.6.3, Visual Studio Code version 1.76.0

.vscode/settings.json: { "java.checkstyle.configuration": "/google_checks.xml", "java.checkstyle.properties": { "basedir": "${workspaceFolder}" }, "java.checkstyle.version": "9.3", }

Repro steps:

  1. Open Java project in VSCode
  2. Go to a Java file and make a change that triggers a checkstyle warning. e.g. rearrange imports out of order

Expected: Get highlight over line with checkstyle warning showing the issue

Actual:

  1. No highlight over line
  2. Edit settings.json to change java.checkstyle.version to any other version
  3. Now line shows highlight
  4. Restart VS Code
  5. highlight gone again
jdneo commented 1 year ago

Looks like we need to add some logic to wait the language server ready.

simahao commented 1 year ago

Looks like we need to add some logic to wait the language server ready.

Is there any plan to fix it?

jdneo commented 1 year ago

vscode-checkstyle-1.4.2.vsix.zip

I've worked for a fix for this issue. Please check if the problem is solved or not and let me know.

Note: The default Checkstyle version is changed to 9.3. If that does not apply to your Checkstyle configuration, please change the used version accordingly.

simahao commented 1 year ago

1.4.2 looks good, 3ks