Add access to the source bytes of the Tree
まだ誰も着手していません。
評価
調査の方向性
まず Parser#parse と Tree#getText を読んで、ソースバイトがどのように変換され保持されるかを追跡し、次に以前クローズされた pull request #65 のアプローチを確認します。コピーや String への変換を避けつつ、内部データの編集を防ぐ、保存されたバイトへのアクセス経路を定義してください。完了とは、呼び出し側が重複した保存なしにツリーのソースバイトを安全に使用できることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Currently when you parse some source code, you can only provide it as a String. The Parser#parse function then converts it to a byte[] before it is passed to tree-sitter. Also, the Tree class only exposes the underlying source code as a String. It stores the content as a byte[]. But every call to Tree#getText converts it to a String.
Those conversion create computational overhead as Java stores its string in UTF-16 while the input encoding for the source code in the byte array can be UTF-8.
In my use case, I parse some text and then want to edit it. I check for some nodes and remove their contents from the text (e.g. by replacing them with whitespace). To avoid those conversions, I currently need to store the input text two times (once in the Tree instance and once separately for the byte level editing). If one could access the byte[] of the tree this could be avoided. I understand, that we do not want the internal byte[] to be edited. Thus one could also expose it as a read only ByteBuffer using ByteBuffer#asReadOnlyBuffer
I proposed a similar change already in https://github.com/tree-sitter/java-tree-sitter/pull/65 but it was closed. In fact, I've been maintaining a private fork of this repo since then, to have the functionality available. I'd really like to have this possibility in the official bindings as I think it could also benefit others.
- 主要言語
- Java
- スター
- 142
- フォーク
- 34
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tree-sitter/java-tree-sitter のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
tree-sitter/java-tree-sitter#174 · コメント 4 件 ·
-
good first issue help wanted
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
tree-sitter/java-tree-sitter#144 · リアクション 1 件 ·
-
Collect source bytes from ParseCallback対応中かも @ALancki1 が 213 日前に担当しました。 オープンgood first issue help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
tree-sitter/java-tree-sitter#126 · コメント 1 件 ·
tree-sitter/java-tree-sitter の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: WriteFileTool shows "Error reading file" snippet for relative paths when baseDir is set対応中かも @ShryukGrandhi が今日担当しました。 オープン
難易度 2/5 1時間未満 初心者へのやさしさ 86/100
agentscope-ai/agentscope-java#3917 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
intellij-elixir/intellij-elixir#4585 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MetricsHub/metricshub-community#1474 ·
メンテナーはふだん 1 日以内に返信
-
go:build
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
Sanne/incus-spawn#1929 ·
メンテナーはふだん 1 日以内に返信