Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code formatting is not working with quarkus-java11 plugin #17560

Closed
sunix opened this issue Aug 4, 2020 · 14 comments
Closed

Code formatting is not working with quarkus-java11 plugin #17560

sunix opened this issue Aug 4, 2020 · 14 comments
Assignees
Labels
area/plugins kind/bug Outline of a bug - must adhere to the bug report template. severity/P2 Has a minor but important impact to the usage or development of the system.
Milestone

Comments

@sunix
Copy link
Contributor

sunix commented Aug 4, 2020

Describe the bug

Tried to format Java code with

  • 7.16.2 (che.openshift.io)
  • quarkus-java11 plugin
      - id: redhat/quarkus-java11/latest
        type: chePlugin

Code completion works fine.

@sunix sunix added the kind/bug Outline of a bug - must adhere to the bug report template. label Aug 4, 2020
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Aug 4, 2020
@mshaposhnik mshaposhnik added area/plugins severity/P2 Has a minor but important impact to the usage or development of the system. and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Aug 4, 2020
@ericwill ericwill mentioned this issue Aug 4, 2020
29 tasks
@ericwill ericwill added this to the 7.18 milestone Aug 5, 2020
@vitaliy-guliy
Copy link
Contributor

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 eclipse-theia/theia#8354

@vitaliy-guliy vitaliy-guliy self-assigned this Aug 13, 2020
@sunix
Copy link
Contributor Author

sunix commented Aug 13, 2020

but shouldn't it just pick the last one?

@ericwill
Copy link
Contributor

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.

@benoitf
Copy link
Contributor

benoitf commented Aug 17, 2020

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

@ericwill
Copy link
Contributor

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?

@vitaliy-guliy
Copy link
Contributor

vitaliy-guliy commented Aug 18, 2020

There is a PR eclipse-che/che-plugin-registry#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'

@benoitf
Copy link
Contributor

benoitf commented Aug 18, 2020

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

java.project.importOnFirstTimeStartup = automatic

@vitaliy-guliy
Copy link
Contributor

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

@benoitf
Copy link
Contributor

benoitf commented Aug 18, 2020

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

@vitaliy-guliy
Copy link
Contributor

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

@benoitf
Copy link
Contributor

benoitf commented Aug 18, 2020

@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.

@ericwill ericwill mentioned this issue Aug 20, 2020
32 tasks
@ericwill
Copy link
Contributor

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.

@sunix
Copy link
Contributor Author

sunix commented Aug 20, 2020

@ericwill
Copy link
Contributor

so fixed with eclipse/che-plugin-registry#575 and redhat-developer/quarkus-ls#332

Correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins kind/bug Outline of a bug - must adhere to the bug report template. severity/P2 Has a minor but important impact to the usage or development of the system.
Projects
None yet
Development

No branches or pull requests

6 participants