DotJoshJohnson/vscode-dotnet

Code Lens Feature

Opened this issue · 0 comments

Code Lens

The code lens request is sent from the client to the server to compute code lenses for a given text document.

Changed: in 2.0 the request uses CodeLensParams instead of a single uri.

Request

  • method: 'textDocument/codeLens'
  • param: CodeLensParams defined as follows:
export interface CodeLensParams {
    /**
     * The document to request code lens for.
     */
    textDocument: TextDocumentIdentifier;
}

Response

  • result: CodeLens[] defined as follows:
/**
 * A code lens represents a command that should be shown along with
 * source text, like the number of references, a way to run tests, etc.
 *
 * A code lens is _unresolved_ when no command is associated to it. For performance
 * reasons the creation of a code lens and resolving should be done to two stages.
 */
export interface CodeLens {
    /**
     * The range in which this code lens is valid. Should only span a single line.
     */
    range: Range;

    /**
     * The command this code lens represents.
     */
    command?: Command;

    /**
     * An data entry field that is preserved on a code lens item between
     * a code lens and a code lens resolve request.
     */
    data?: any
}
  • error: code and message set in case an exception happens during the code lens request.

Code Lens Resolve

The code lens resolve request is sent from the client to the server to resolve the command for a given code lens item.

Request

  • method: 'codeLens/resolve'
  • param: CodeLens

Response

  • result: CodeLens
  • error: code and message set in case an exception happens during the code lens resolve request.