redhat-developer / redhat-developer/vscode-java
Updating class references (generated classes from proto files)
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 546
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 11
説明
Hi. I'm using Protocol Buffers in my Java application. I'm using Gradle, and the protobuf-gradle-plugin to generate Java classes from the .proto files. The generated proto Java files are added to my sourceSet in build.gradle.
build.gradle
plugins {
id 'java'
id 'application'
id "com.google.protobuf" version "0.8.12"
}
repositories {
jcenter()
}
dependencies {
implementation 'com.google.guava:guava:28.2-jre'
testImplementation 'junit:junit:4.12'
}
application {
mainClassName = 'test.gradle.project.proto.App'
}
sourceSets {
main {
java {
srcDirs 'src/main/java'
srcDirs 'build/generated/source/proto/main/java'
}
}
}
compileJava.dependsOn 'generateProto'
Whenever I make a change to the proto files, and re-generate the proto Java classes via ./gradlew generateProto, the language server does not update the references, and I get errors in the editor. AFAIK there's two ways to update the class references:
- Restart vscode, or
- Run "Update project configuration" from the grade build file
Neither options are ideal, and option 2 can sometimes take a long time to complete on large projects. I would think updating class references should be a quick process. No compilation is necessary, the language server just needs to update it's reference cache (or something along those lines).
Would it be possible to
- Provide a new command to update class references?
- Watch the build directory/sourceSets and automatically update references when generated files change?
I'm also developing a gradle vscode extension, and from my extension i would potentially be able to provide a list of generated class files to the vscode-java extension via an API call, so that could also be a potential option.
Looking for any ideas/suggestions/changes to make this process more user friendly and fast.
Environment
- Operating System: MacOS catalina
- JDK version: openjdk 11.0.2
- Visual Studio Code version: 1.45.1
- Java extension version: 0.62.0
Steps To Reproduce
- Clone this repo: https://github.com/badsyntax/test-gradle-project-proto
- Open
test-gradle-project-protoin vscode - Open
src/main/java/test/gradle/project/proto/App.java - Note classes for
Greetingdon't exist - In the vscode terminal, run
./gradlew generateProto - Note references for
Greetingstill don't exist - Either restart vscode, or run "Update project configuration" from
build.gradle - Note references for
Greetingnow exist and there's no errors in the editor
Keep in mind this is a very small project and you won't see the performance issues I mentioned above, but does demonstrate the extension not updating references when files on disk change.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている test-gradle-project-proto リポジトリで、build.gradle と src/main/java/test/gradle/project/proto/App.java を使用して問題を再現します。プロジェクトを開いた後に ./gradlew generateProto を実行し、VS Code を再起動したり Update project configuration を実行したりせずに Greeting の参照が更新されるか確認します。ファイルの変更後に生成されたクラスへの参照が更新され、プロジェクト設定全体の更新を必要としなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, vscode
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100