🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gmane.emacs.devel
2 messages
2 total messages Started by JD Smith Wed, 23 Aug 2023 09:58
tree-sitter: proper use of parser-set-included-ranges
#307106
Author: JD Smith
Date: Wed, 23 Aug 2023 09:58
52 lines
2599 bytes
--Apple-Mail=_AAE5D15A-701C-4C42-9017-347609BFE223
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

`treesit-parser-set-included-ranges’ appears quite useful for directing tree-sitter’s attention to part of a buffer, for example input at a comint mode’s prompt.  But I have noticed that once the included range is set, it remains fixed within the buffer, and does not expand as text is added or removed from that region.  

Since tree-sitter incrementally updates the syntax tree as edits occur, I wonder what the “right time” to update the included region with `set-included-ranges’ is?  Constantly, say in an after-change-function, or “just-in-time”, as you are about to query the syntax tree for some purpose? 

Put another way, does the syntax tree in tree-sitter survive changes to an included range (treating it as an “incremental update”)?  Or does explicitly changing the range effectively dump the tree and rebuild it?


--Apple-Mail=_AAE5D15A-701C-4C42-9017-347609BFE223
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">`treesit-parser-set-included-ranges’ appears quite useful for directing tree-sitter’s attention to part of a buffer, for example input at a comint mode’s prompt.  But I have noticed that once the included range is set, it remains fixed within the buffer, and does not expand as text is added or removed from that region.  <div><br></div><div>Since tree-sitter incrementally updates the syntax tree as edits occur, I wonder what the “right time” to update the included region with `<font color="#000000">set-included-ranges’ is?  Constantly, say in an after-change-function, or “just-in-time”, as you are about to query the syntax tree for some purpose? </font></div><div><font color="#000000"><br></font></div><div><font color="#000000">Put another way, does the syntax tree in tree-sitter survive changes to an included range (treating it as an “incremental update”)?  Or does explicitly changing the range effectively dump the tree and rebuild it?</font></div><div><br></div></body></html>
--Apple-Mail=_AAE5D15A-701C-4C42-9017-347609BFE223--

Re: tree-sitter: proper use of parser-set-included-ranges
#307171
Author: Yuan Fu
Date: Fri, 25 Aug 2023 00:28
31 lines
1365 bytes

> On Aug 23, 2023, at 6:58 AM, JD Smith <jdtsmith@gmail.com> wrote:
> 
> `treesit-parser-set-included-ranges’ appears quite useful for directing tree-sitter’s attention to part of a buffer, for example input at a comint mode’s prompt.  But I have noticed that once the included range is set, it remains fixed within the buffer, and does not expand as text is added or removed from that region.  
> 
> Since tree-sitter incrementally updates the syntax tree as edits occur, I wonder what the “right time” to update the included region with `set-included-ranges’ is?  Constantly, say in an after-change-function, or “just-in-time”, as you are about to query the syntax tree for some purpose? 

Usually you’d want to do it less often, since usually you need to query the “base” language for the range before setting the range for the embedded language. Other than that I don’t think it makes a big difference either way.

> 
> Put another way, does the syntax tree in tree-sitter survive changes to an included range (treating it as an “incremental update”)?  Or does explicitly changing the range effectively dump the tree and rebuild it?

IIUC the parse tree is preserved. That makes the most sense to me.

Yuan
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads