Vscode-java: Question: How do you verify local path in "java.format.settings.url" is pointing to the right file?

Created on 10 Dec 2019  路  12Comments  路  Source: redhat-developer/vscode-java

Currently, I have a file, eclipse-formatter.xml, located at ${workspaceRoot}/.vscode directory.

I understand environment variables are not supported in VSCode-Java.

So, if I were to start from:

"java.format.settings.url": "",

How do I know where the current working directory for "java.format.settings.url" defaults to? Or this is actually based on where the ".code-workspace" file is located? Or this is based off of where "settings.json" is located?

Environment
  • Operating System: Windows 10 Pro & Ubuntu
  • JDK version: 12.0.1
  • Visual Studio Code version: 1.40.2
  • Java extension version: 0.54.2
duplicate formatter question

Most helpful comment

Yep, latest VSCode broke referencing local files without a file: protocol... @saumilsdk and @kulynyak tipps fixed the issue for me! Thanks so much!

All 12 comments

@tommai78101 you can try the following:

 "java.format.settings.url": ".vscode/eclipse-formatter.xml",

Thanks for the solution. I have my formatter set up now.

I would like to know if there's a way to detect the current working directory? If so, where does it begin by default, when the "java.format.settings.url" is not specified yet?

Currently, the wiki page on Github didn't specify in detail where the current working directory is pointing to.

See https://code.visualstudio.com/docs/editor/variables-reference

${cwd} - the task runner's current working directory on startup

Thanks.

I'll figure something out for printing the ${cwd} within Visual Studio Code.

This seems not working in latest VC code version 1.54.3

@saumilsdk Open a new issue and reference this ticket.

@tommai78101 Hey this seems to work with _file:_ prefix.

"java.format.settings.url": "file:/eclipse-formatter.xml"

"java.format.settings.url": "file:.vscode/eclipse-formatter.xml", should work

Yep, latest VSCode broke referencing local files without a file: protocol... @saumilsdk and @kulynyak tipps fixed the issue for me! Thanks so much!

@saumilsdk @kulynyak Thanks to both. Didn't know there's a new protocol to specify the file.

It's a bug that'll be fixed in the next release (end of March)

Duplicate of #1827

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sfariaNG picture sfariaNG  路  3Comments

ViniciusAtaide picture ViniciusAtaide  路  4Comments

bilymed picture bilymed  路  3Comments

danielcalvogonzalez picture danielcalvogonzalez  路  3Comments

xriu picture xriu  路  4Comments