Metals implements a Language Server Protocol extension called the "Tree View Protocol" to render tree views in the editor client.
One "tree view" represents the root of a tree along with all of its descendent tree nodes. Multiple tree views can be displayed at the same time in an editor client.
A tree view is uniquely identified by a
viewId: string field in other data
A tree view can contain multiple tree view nodes. A tree view node can have the following metadata.
The children of a tree view node can be obtained through the
The Tree View Protocol (TVP) consists of several JSON-RPC requests and notification endpoints.
The Tree View Protocol is only enabled when both the client and server declare
support for the protocol by adding an
treeViewProvider: true field to the
experimental section of the server and client capabilities in the
The tree view children request is sent from the client to the server to get the
children nodes of a tree view node. The client is safe to cache the response of
the children until server sends a
metals/treeViewDidChange notification for
the parent node or one of its ancestor nodes.
TreeViewChildrenParamsdefined as follows.
TreeViewChildrenResultdefined as follows.
The tree view parent request is sent from the client to the server to obtain the
parent node of a child node. The
metals/treeViewParent endpoint is required to
TreeViewParentParamsdefined as follows.
TreeViewParentResultdefined as follows.
The tree view did change notification is sent from the server to the client to notify that the the metadata about a given tree view node has changed.
TreeViewDidChangeParamsdefined as follows:
The visibility did change notification is sent from the client to the server to notify that the visibility of a tree view has changed.
TreeViewVisibilityDidChangeParamsdefined as follows:
The collapse did change notification is sent from the client to the server to notify that a tree node has either been collapsed or expanded.
TreeViewNodeCollapseDidChangeParamsdefined as follows:
The reveal request is sent from the client to the server to convert a text document position into it's corresponding tree view node.
TextDocumentPositionParams, as defined in LSP.
TreeViewRevealResultdefined as follows.
Example implementation of the reveal request.