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.

Code formatter does not support additive operator preferences

See original GitHub issue

Eclipse code formatting supports a setting that wraps lines after the string concatenation operator (+), along with column formatting that aligns text with one element per line:

public enum SqlQuery {
    createChatSchema( "CREATE SCHEMA IF NOT EXISTS chat;" +
                      "ALTER SCHEMA chat" +
                      "    OWNER TO postgres;" +
                      "CREATE TABLE IF NOT EXISTS chat.messages_as_json" +
                      " (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);" ),
    // leaving out constructor, etc.
}
Environment

Version: 1.34.0 (user setup) Commit: a622c65b2c713c890fcf4fbf07cf34049d5fe758 Date: 2019-05-15T21:59:37.030Z Electron: 3.1.8 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.18898

Java extension version: 0.7.1

Steps To Reproduce
  1. Export eclipse code style with:
  • string concatenation wrap after operator
  • wrap all elements, one per line
  1. export settings from eclipse
  2. set vscode url to point at the exported settings
  3. create a type that defines a String that includes wrapping.
  4. auto format the file
Current Result
public enum SqlQuery {
    createChatSchema("CREATE SCHEMA IF NOT EXISTS chat;" + "ALTER SCHEMA chat" + "    OWNER TO postgres;"
            + "CREATE TABLE IF NOT EXISTS chat.messages_as_json"
            + " (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);"),
Expected Result
public enum SqlQuery {
    createChatSchema( "CREATE SCHEMA IF NOT EXISTS chat;" +
                      "ALTER SCHEMA chat" +
                      "    OWNER TO postgres;" +
                      "CREATE TABLE IF NOT EXISTS chat.messages_as_json" +
                      " (id BIGSERIAL PRIMARY KEY, message JSON NOT NULL);" ),
    // leaving out constructor, etc.
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
snjezacommented, Jul 4, 2019

I can’t reproduce the issue.

Could you set the following:

"java.format.settings.url": "https://raw.githubusercontent.com/snjeza/vscode-test/master/eclipse-formatter.xml"

to your workspace settings.json.

1reaction
snjezacommented, Jul 2, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Prettier not format code in VS Code? - Stack Overflow
Open Files -> Preferences -> Settings (or Ctrl + , in Windows). Search for Editor: Default Formatter; Select your default formatter as Prettier ......
Read more >
User and Workspace Settings - Visual Studio Code
Here is the list of settings not supported in workspace settings: git.path; terminal.external.windowsExec; terminal.external.osxExec; terminal.external.
Read more >
WebStorm 2020.2: Use Prettier as the Default Formatter, Work ...
With Vue-specific code style settings, you can quickly choose which ... The IDE won't support WSL 1 because Git from WSL 1 doesn't...
Read more >
Code style options and code cleanup - Visual Studio (Windows)
You can define code style settings per-project by using an ... the Code Cleanup (Visual Studio 2019, Visual Studio 2022) and Format Document ......
Read more >
Clang-Format Style Options — Clang 16.0.0git documentation
When formatting standard input or a file that doesn't have the extension ... This option is supported only in the clang-format configuration (both...
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