redhat-developer / redhat-developer/vscode-java
CodeAction that modifies code in an unopened file doesn't work with two spaces indentation
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 546
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 11
説明
When I apply a CodeAction that modifies code in a file that isn't currently opened in VS Code, such as "create missing field asdf in Foo", and the file being modified is formatted to use two spaces as indentation, then the newly added content is not formatted correctly.
In order for this to happen, I don't specify any indentation settings in settings.json, and I don't add a .settings/org.eclipse.jdt.core.prefs.
Environment
- Operating System: RHEL 8
- JDK version:
- Visual Studio Code version: 1.69.2, 3b889b090b5ad5793f524b5d1d39fda662b96a2a, x64
- Java extension version: v1.10.2022080304
Steps To Reproduce
- Make a class FooA:
public class FooA {
private String prefix;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
- Close
FooA - Make a class FooB:
public class FooB {
private FooA fooA;
public FooB(FooA fooA) {
this.fooA = fooA;
}
public String getParameter() {
return this.fooA.parameter;
}
}
- Activate the "Create field 'parameter' in type 'FooA'" CodeAction
Current Result
FooA becomes:
public class FooA {
private String prefix;
public String parameter;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
Expected Result
FooA becomes:
public class FooA {
private String prefix;
public String parameter;
public FooA(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return this.prefix;
}
}
Additional Informations
- You can reproduce this bug using other CodeActions, like the "Create method" one
- If indentation settings are set in a
settings.jsonor.settings/org.eclipse.jdt.core.prefs, the newly added content respects those settings as expected
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue では実装ファイルもテストも指定されていません。まず、2 つのスペースによるインデントを使用し、明示的なインデント設定を指定していない閉じた Java ファイルで CodeAction を再現してください。新しく挿入されたフィールドまたはメソッドがファイルの 2 つのスペースによるインデントを使用し、期待される結果と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100