question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

regression: java.format.settings.url no longer loads project .xml file

See original GitHub issue

Some of our teammates just upgraded to the latest version of this extension and noticed that the formatter’s behavior has changed.

Before upgrading extension:

  • open a file, run Format document – no diff

After upgrading extension:

  • open a file, run Format document – large diff

Our formatter configuration is and has been set from an .xml config file. Our .vscode/settings.json looks like this:

  "java.format.settings.url": "path/to/code-style.xml",

I opened the project in Eclipse and imported the same code-style.xml file, and verified that the Eclipse formatter running with that config produces no diff.

I’ve concluded the formatter on the most recent version of this extension has regressed.

Environment
  • Operating System: MacOS 11.2.1
  • JDK version: openjdk version "15.0.1" 2020-10-20
  • Visual Studio Code version: 1.54.1
  • Java extension version: v0.76.0
Steps To Reproduce
  1. Create custom code style .xml file
  2. Configure via .vscode/settings.json
  3. Run Format document
Current Result

Formatter generating unwanted diffs on newest extension version.

Expected Result

No formatting diffs on files that were formatted with prior extension version.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
rothfelscommented, Mar 9, 2021

Edit: I discovered it works with a (relative) file URL (absolute doesn’t work because ${workspaceFolder} is not interpolated).

  "java.format.settings.url": "file:path/to/code-style.xml",

Fwiw, the documentation for this setting says it can be a path. Maybe you want to fix? https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings

4reactions
lpedrosacommented, Mar 7, 2021

I guess I should’ve read @rothfels answer more carefully 😅, since it is mentioned that the URI could be relative to the ${workspaceFolder}.

A workaround for the scenario I’ve described above is to set the java.format.settings.url property like:

# assuming your formatter xml file in on ${workspaceFolder}
# and is called 'eclipse-formatter.xml'
"java.format.settings.url": "file:./eclipse-formatter.xml"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Java formatting and linting - Visual Studio Code
The property can be set to a URL or a local file path. If the formatter XML file contains more than one profile,...
Read more >
Import google-java-format from Eclipse to VSCode
Another way to use it is to trigger command Java: Open Java formatter settings , and it will help you generate a default...
Read more >
emacs-lsp/lsp-mode - Gitter
I'm hitting the “file watches” limitation because of the size of the project I'm working on, so I've gone ahead and added (setq...
Read more >
Upgrade Notes | TeamCity On-Premises Documentation
This fix restores the intended behavior, but we recommend that you review your clean-up settings to ensure no builds will be cleaned up ......
Read more >
xmlsave — Export or import dataset in XML format - Stata
include Stata DTD in XML file legible format XML to be more legible replace overwrite existing filename xmluse options. Description doctype(dta) load XML ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found