Integrated code formatter

Rumbu rumbu at
Tue Jan 18 08:03:01 UTC 2022

On Tuesday, 18 January 2022 at 02:06:01 UTC, deadalnix wrote:
> This approach is fundamentally flawed, as keeping all the info 
> you need through an AST is pretty much impossible.

It is not impossible. Roslyn has a SyntaxTree build dynamically 
(on expand) which includes every character in the source code (as 
slices). This tree allows operations on source code as formatting 
or code refactoring.

In parallel, it has a SemanticModel tree which is built 
separately stripped of any irellevant information for the 
semantic analysis. This tree is used to emit CIL code or enabling 
features like edit and continue.

Both trees use as backstore a minimal AST (green nodes) which is 
dynamically regenerated and its nodes reused on any text change.

More information about the Digitalmars-d mailing list