Skip to content

Code formatter does not support additive operator preferences #931

Open

Description

@rdcoe

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

Activity

  1. self-assigned this
    on May 21, 2019
  2. fbricon commented on Jun 20, 2019

    @fbricon
    Collaborator

    @snjeza Is this another case of the formatter changes being seemingly ignored? (see #957)

  3. snjeza commented on Jul 2, 2019

    @snjeza
    Collaborator
  4. rdcoe commented on Jul 4, 2019

    @rdcoe
    Author
  5. snjeza commented on Jul 4, 2019

    @snjeza
    Collaborator

    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.

  6. rdcoe commented on Jul 5, 2019

    @rdcoe
    Author
  7. rdcoe commented on Jul 5, 2019

    @rdcoe
    Author
  8. rdcoe commented on Jul 5, 2019

    @rdcoe
    Author
  9. dongw00 commented on Feb 24, 2020

    @dongw00

    @snjeza Thanks. :)

  10. robstryker commented on Nov 2, 2026

    @robstryker
    Contributor

    @shin19991207 It'd be good when you have spare time to check if this is still able to be replicated or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions