Each file is represented as a **DocumentState**, which stores the raw text, an AST, a table of top-level symbols, and any parsing errors. When a file is opened or edited, the LSP server host will:
- Parse the code using the lexer and parser.
- Build a symbol table of all top-level declarations (functions, structs, variables, exports).
- Tracks line offsets for converting between editor positions and parser positions.
- Generates diagnostics for syntax or parsing errors.
For editor features:
- Hover shows the signature of a function, struct, or variable under the cursor.
- Go-to-definition finds where a symbol was declared.