ionide / ionide/FsAutoComplete

Provide an AST model of a file or selection

Open
#525 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
F#
Stars
486
Forks
169
Avg merge
2d 8h
Merged PRs (30d)
5

Description

It would be helpful for tool developers (or those developing an analyzer!) to have an easy way to view the AST of the current file/the current selection in some way. I was thinking endpoints like:

```
type AstMode = | Text // later on add a 'json' or 'graph' mode or something for better views
type GetDocumentAstParams =
{ Document: TextDocumentIdentifier
AstMode: AstMode }

let getAstForTextDocument: GetDocumentAstParams -> LspResult

type GetSelectionAstParams =
{ Document: TextDocumentIdentifier
Range:
AstMode: AstMode }

let getAstForSelection: GetSelectionAstParams -> LspResult
```

And then clients could specify the format they wanted and render accordingly. First pass could just be the `sprintf "%A"` representation of the AST, but later iterations could embed more of the functionality found in https://jindraivanek.gitlab.io/ast-viewer/ into dedicated views if there was demand.

This is a bit of a selfish feature, because having this would make writing analyzers easier for me specifically :)

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by reviewing the repository's existing LSP request surface and the AST-viewer reference linked in the issue. Done should be defined as an agreed request design for whole-document and selection AST output, including the initial text format.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.