Skip to content

4.2 | Programmatic language features

zalan-racz-gaijin edited this page Jun 17, 2024 · 3 revisions

Core

document-info.ts handles all information about a file and it starts the analyzation. snapshot.ts contains the state of a file at a given time. file-cache-manager.ts handles file IO operations, so that we don't have to load files from disk every time we need them. configuration-manager.ts gives you access to the settings and capability-manager.ts contains the IDE's LSP capabilities.

Helper

The helper folder contains helper functionality, and it contains information about the DSHL and HLSL language constructs.

Interface

The interface folder contains interfaces to store information about the analyzed documents. They don't contain any logic, just data structures and some to string functions. When you see a Position or Range, where the name contains the world original, (eg. originalRange, nameOriginalRange, etc.), it means that it's valid in the document that the user can see, before preprocessing.

Processor

The processor folder contains files which change or analyze a document. The dshl-visitor.ts, expression-visitor.ts, and condition-visitor.ts, are used to walk on the parse tree generated by ANTLR. preprocessor.ts, dshl-preprocessor.ts, hlsl-preprocessor.ts, include-processor.ts, and include-resolver.ts perform preprocessing. block-processor.ts, and argument-processor.ts can find for example the arguments of a function call.

Provider

The provider folder contains all the Language Server Protocol providers. Basically one file per feature. The only exception is link-provider-base.ts, which is not a feature itself, but a generalization of go to definition, go to declaration, go to implementation and go to type declaration. They all have a function with parameters and return type defined in the Language Server Protocol. The first step of the implementation is usually to get the Snapshot corresponding to the file. The function getSnapshot takes care of the analyzation if necessary in the background. The only remaining thing is to get the required data from the Snapshot, and return it. Returning a null, undefined , [], or throwing an exception is handled by VS Code, but not always in the same way.

Clone this wiki locally