🔍 Looking up ranges in structured data
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- ocaml
- Domain
- compilers
Research direction
The issue names Range.located, Range.view, and an LSP patch as starting points; read those APIs and the linked patch first. No repository file or test is identified. Done would be an agreed, tested way to use source ranges to look up syntax-tree nodes, including the relevant position-boundary cases.
Written by the indexing model from the issue text.
Description
When Asai reports an error, the diagnostics are attached to the string source like this:
→ error[(Reporter.Message.Tree_not_found foo-0006)]
ꭍ ○ when expanding tree at address `foo-0004`
■ ./trees/foo-0004.tree
1 | \import{foo-0006}
^ Could not find tree named `foo-0006'
I find myself in the position where it would be really useful if I could use the range to look up nodes in the syntax tree.
Nick Hu once sent a patch implementing an LSP server for Forester that contained the following function:
let inside = fun (located : 'a Range.located) ->
match located.loc with
| Some loc -> begin
match Range.view loc with
| `Range (start, end_) ->
let within (a, b) x = a <= x && x <= b in
within (start.line_num, end_.line_num ) (pos.line + 1)
&& within ((start.offset - start.start_of_line), (end_.offset - end_.start_of_line - 1)) pos.character
| _ -> false
end
| None -> false
I did not think through the arithmetic, but conceptually, this is the right way to do this, right? Or is there a more elegant way using more library functions?
- Dominant language
- OCaml
- Stars
- 55
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RedPRL/asai
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
-
Configurable unicode Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
Similar issues
-
mlir
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
llvm/llvm-project#224908 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
secondlife/sl-vscode-plugin#147 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
objectionary/phie#149 ·