redhat-developer / redhat-developer/vscode-java

Inconsistency in line break "{}" formatting in Java with in VS Code

オープン
#3,694 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

In my VSC I have the extension called "Language support for java(TM) by red hat". The typical one that all of us who do Java have and this is self-evident. The formatter of said extension does not format correctly. Surely the formatting is taken from LLVM so there is some error or even some incorrect syntax when formatting

When I format in VSC this example code with java or java spring boot:

❌Incorrect - If I format like this, it leaves it like this
This happens on both the opening "{" and the ending "}". It seems that the extra space has no influence since the format accepts both together and extra spacing. When the correct one is the second one with the extra spacing.

Incorrect Preview
image image image
Also say the formatting of the extension also leaves it like this if the code is like this.image

3 incorrect formats accepted by the formatter have been shown. Therefore, if there is any code "in that format", the formatter will leave it that way. Only the correct one is the last one or the one made by Eclipse.
This doesn't make much sense since the code is stuck above or below or even between the curly braces "{}".

This way of formatting is not expected for those of us who work with Java. Eclipse does well in this regard.

✅ correct - This is how Eclipse does it. It doesn't matter how messy the code is. It will leave it like this:

Correct Preview
image

I have tried countless things, none of them worked.

This has worked since 2007 in eclipse. We are in 2024. As an example of a good format:
image

How do you solve this problem and get the correct form, like correct or equal to eclipse?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

レポートの例とスクリーンショットを使って、Java VS Code extension における波括弧と改行のフォーマット動作を再現し、その後、出力を Eclipse と比較します。Extension の Java フォーマットのエントリーポイントから formatter の動作を追跡し、その差異が設定によるものか実装によるものかを判断します。報告されたレイアウトが期待される Eclipse 形式の結果に正規化されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。