redhat-developer / redhat-developer/vscode-java

Code formatter does not support additive operator preferences

Open
#931 8 comments 0 reactions 1 assignee View on GitHub

@snjeza is already working on this.

Since May 21, 2019.

bug formatter
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.