UNPKG

2.94 kBTypeScriptView Raw
1import type * as atomIde from "atom-ide-base";
2import { LanguageClientConnection, Location, LocationLink, ServerCapabilities } from "../languageclient";
3import { Point, TextEditor } from "atom";
4/**
5 * Public: Adapts the language server definition provider to the Atom IDE UI Definitions package for 'Go To Definition'
6 * functionality.
7 */
8export default class DefinitionAdapter {
9 /**
10 * Public: Determine whether this adapter can be used to adapt a language server based on the serverCapabilities
11 * matrix containing a definitionProvider.
12 *
13 * @param serverCapabilities The {ServerCapabilities} of the language server to consider.
14 * @returns A {Boolean} indicating adapter can adapt the server based on the given serverCapabilities.
15 */
16 static canAdapt(serverCapabilities: ServerCapabilities): boolean;
17 /**
18 * Public: Get the definitions for a symbol at a given {Point} within a {TextEditor} including optionally highlighting
19 * all other references within the document if the langauge server also supports highlighting.
20 *
21 * @param connection A {LanguageClientConnection} to the language server that will provide definitions and highlights.
22 * @param serverCapabilities The {ServerCapabilities} of the language server that will be used.
23 * @param languageName The name of the programming language.
24 * @param editor The Atom {TextEditor} containing the symbol and potential highlights.
25 * @param point The Atom {Point} containing the position of the text that represents the symbol for which the
26 * definition and highlights should be provided.
27 * @returns A {Promise} indicating adapter can adapt the server based on the given serverCapabilities.
28 */
29 getDefinition(connection: LanguageClientConnection, serverCapabilities: ServerCapabilities, languageName: string, editor: TextEditor, point: Point): Promise<atomIde.DefinitionQueryResult | null>;
30 /**
31 * Public: Normalize the locations so a single {Location} becomes an {Array} of just one. The language server protocol
32 * return either as the protocol evolved between v1 and v2.
33 *
34 * @param locationResult Either a single {Location} object or an {Array} of {Locations}.
35 * @returns An {Array} of {Location}s or {null} if the locationResult was null.
36 */
37 static normalizeLocations(locationResult: Location | Location[] | LocationLink[] | null): Location[] | LocationLink[] | null;
38 /**
39 * Public: Convert an {Array} of {Location} objects into an Array of {Definition}s.
40 *
41 * @param locations An {Array} of {Location} objects to be converted.
42 * @param languageName The name of the language these objects are written in.
43 * @returns An {Array} of {Definition}s that represented the converted {Location}s.
44 */
45 static convertLocationsToDefinitions(locations: Location[] | LocationLink[], languageName: string): atomIde.Definition[];
46}