Che: Code formatting is not working with quarkus-java11 plugin

Created on 4 Aug 2020  路  14Comments  路  Source: eclipse/che

Describe the bug

Tried to format Java code with

  • 7.16.2 (che.openshift.io)
  • quarkus-java11 plugin
    yaml <ul> <li>id: redhat/quarkus-java11/latest<br /> type: chePlugin<br />

Code completion works fine.

areplugins kinbug severitP2

All 14 comments

Che-Theia does not want to format file when several formatters are registered for the language.

Quarkus11 plugin adds folowing extensions to Che-Theia

- https://download.jboss.org/jbosstools/vscode/3rdparty/vscode-java-debug/vscode-java-debug-0.26.0.vsix
- https://download.jboss.org/jbosstools/static/jdt.ls/stable/java-0.63.0-2222.vsix
- https://download.jboss.org/jbosstools/vscode/stable/vscode-quarkus/vscode-quarkus-1.5.0-324.vsix

Java and vscode-quarkus extensions register formatters for Java language. Command to format the document is displayed and enabled in the context menu for java file, but it does nothing.

Screenshot from 2020-08-13 17-28-55

I recorded a small video how VS Code behaves when I tried to run it with those three extensios https://www.youtube.com/watch?v=ekpMNaLvCWo

Corresponding issue in Theia upstream https://github.com/eclipse-theia/theia/issues/8354

but shouldn't it just pick the last one?

but shouldn't it just pick the last one?

When possible, we should give the choice to the user. Also this functionality is bound to come up again, so having it in Theia makes sense and is worth the effort.

it seems Quarkus extension shouldn't do formatting anymore redhat-developer/vscode-quarkus#166 redhat-developer/quarkus-ls#332

@vitaliy-guliy can you check the latest vscode-quarkus plugin (I believe it's 1.6.0) and see if it removes the formatter issue?

There is a PR https://github.com/eclipse/che-plugin-registry/pull/575 with quarkus 1.6.0
After running the workspace and opening a java file, a message 'The workspace contains Java projects' is appeared and user is proposed to import them.
This is a bit strange, but is not a big problem. After clicking 'Yes', the language server is being running and it's become possible to format the document.

Screenshot from 2020-08-18 14-43-50

Devfile to test


---
apiVersion: 1.0.0
metadata:
  name: java-quarkus-1.6.0
projects:
  -
    name: java-web-spring
    source:
      type: git
      location: "https://github.com/spring-projects/spring-petclinic.git"
      commitId: 4953f87917b449a404a7f1f4e2457836b9eafbbc

components:
  -
    type: chePlugin
    reference: >-
      https://raw.githubusercontent.com/vitaliy-guliy/che-plugin-registry/quarkus-1.6.0/v3/plugins/redhat/quarkus-java11/1.6.0/meta.yaml
    preferences:
      java.project.importOnFirstTimeStartup: 'automatic'

we should have as default setting for new vscode java versions:

java.project.importOnFirstTimeStartup = automatic

@benoitf thanks. The devfile in my previous comment is updated.

@vitaliy-guliy java.project.importOnFirstTimeStartup: 'true' , true looks like different than automatic ?

@benoitf You won't believe it, but I set it to 'true' automatically. And as it turned out, it also works.

@vitaliy-guliy yes it works due to implementation details
https://github.com/redhat-developer/vscode-java/blob/e541b1a8dc2cf2127ef9bbe34c1474d24d8fd65f/src/extension.ts#L309

but it's not really what is expected

java.project.importOnFirstTimeStartup: Specifies whether to import the Java projects, when opening the folder in Hybrid mode for the first time. Supported values are disabled (never imports), interactive (asks to import or not), automatic (always imports). Default to interactive.

I think we can close this, as we have vscode-quarkus 1.6.0 which does not contribute any formatters anymore. The theia issue is separate and can be handled as such.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesDrummond picture JamesDrummond  路  3Comments

SkorikSergey picture SkorikSergey  路  3Comments

johnmcollier picture johnmcollier  路  3Comments

sudheerherle picture sudheerherle  路  3Comments

sleshchenko picture sleshchenko  路  3Comments