1 | import type * as atomIde from "atom-ide-base";
|
2 | import * as ls from "./languageclient";
|
3 | import { Point, FilesystemChange, Range, TextEditor } from "atom";
|
4 | /**
|
5 | * Public: Class that contains a number of helper methods for general conversions between the language server protocol
|
6 | * and Atom/Atom packages.
|
7 | */
|
8 | export default class Convert {
|
9 | /**
|
10 | * Public: Convert a path to a Uri.
|
11 | *
|
12 | * @param filePath A file path to convert to a Uri.
|
13 | * @returns The Uri corresponding to the path. e.g. file:///a/b/c.txt
|
14 | */
|
15 | static pathToUri(filePath: string): string;
|
16 | /**
|
17 | * Public: Convert a Uri to a path.
|
18 | *
|
19 | * @param uri A Uri to convert to a file path.
|
20 | * @returns A file path corresponding to the Uri. e.g. /a/b/c.txt If the Uri does not begin file: then it is returned
|
21 | * as-is to allow Atom to deal with http/https sources in the future.
|
22 | */
|
23 | static uriToPath(uri: string): string;
|
24 | /**
|
25 | * Public: Convert an Atom {Point} to a language server {Position}.
|
26 | *
|
27 | * @param point An Atom {Point} to convert from.
|
28 | * @returns The {Position} representation of the Atom {PointObject}.
|
29 | */
|
30 | static pointToPosition(point: Point): ls.Position;
|
31 | /**
|
32 | * Public: Convert a language server {Position} into an Atom {PointObject}.
|
33 | *
|
34 | * @param position A language server {Position} to convert from.
|
35 | * @returns The Atom {PointObject} representation of the given {Position}.
|
36 | */
|
37 | static positionToPoint(position: ls.Position): Point;
|
38 | /**
|
39 | * Public: Convert a language server {Range} into an Atom {Range}.
|
40 | *
|
41 | * @param range A language server {Range} to convert from.
|
42 | * @returns The Atom {Range} representation of the given language server {Range}.
|
43 | */
|
44 | static lsRangeToAtomRange(range: ls.Range): Range;
|
45 | /**
|
46 | * Public: Convert an Atom {Range} into an language server {Range}.
|
47 | *
|
48 | * @param range An Atom {Range} to convert from.
|
49 | * @returns The language server {Range} representation of the given Atom {Range}.
|
50 | */
|
51 | static atomRangeToLSRange(range: Range): ls.Range;
|
52 | /**
|
53 | * Public: Create a {TextDocumentIdentifier} from an Atom {TextEditor}.
|
54 | *
|
55 | * @param editor A {TextEditor} that will be used to form the uri property.
|
56 | * @returns A {TextDocumentIdentifier} that has a `uri` property with the Uri for the given editor's path.
|
57 | */
|
58 | static editorToTextDocumentIdentifier(editor: TextEditor): ls.TextDocumentIdentifier;
|
59 | /**
|
60 | * Public: Create a {TextDocumentPositionParams} from a {TextEditor} and optional {Point}.
|
61 | *
|
62 | * @param editor A {TextEditor} that will be used to form the uri property.
|
63 | * @param point An optional {Point} that will supply the position property. If not specified the current cursor
|
64 | * position will be used.
|
65 | * @returns A {TextDocumentPositionParams} that has textDocument property with the editors {TextDocumentIdentifier}
|
66 | * and a position property with the supplied point (or current cursor position when not specified).
|
67 | */
|
68 | static editorToTextDocumentPositionParams(editor: TextEditor, point?: Point): ls.TextDocumentPositionParams;
|
69 | /**
|
70 | * Public: Create a string of scopes for the atom text editor using the data-grammar selector from an {Array} of
|
71 | * grammarScope strings.
|
72 | *
|
73 | * @param grammarScopes An {Array} of grammar scope string to convert from.
|
74 | * @returns A single comma-separated list of CSS selectors targetting the grammars of Atom text editors. e.g. `['c',
|
75 | * 'cpp']` => `'atom-text-editor[data-grammar='c'], atom-text-editor[data-grammar='cpp']`
|
76 | */
|
77 | static grammarScopesToTextEditorScopes(grammarScopes: string[]): string;
|
78 | /**
|
79 | * Public: Encode a string so that it can be safely used within a HTML attribute - i.e. replacing all quoted values
|
80 | * with their HTML entity encoded versions. e.g. `Hello"` becomes `Hello"`
|
81 | *
|
82 | * @param s A string to be encoded.
|
83 | * @returns A string that is HTML attribute encoded by replacing &, <, >, " and ' with their HTML entity named equivalents.
|
84 | */
|
85 | static encodeHTMLAttribute(s: string): string;
|
86 | /**
|
87 | * Public: Convert an Atom File Event as received from atom.project.onDidChangeFiles and convert it into an Array of
|
88 | * Language Server Protocol {FileEvent} objects. Normally this will be a 1-to-1 but renames will be represented by a
|
89 | * deletion and a subsequent creation as LSP does not know about renames.
|
90 | *
|
91 | * @param fileEvent An {atom$ProjectFileEvent} to be converted.
|
92 | * @returns An array of LSP {ls.FileEvent} objects that equivalent conversions to the fileEvent parameter.
|
93 | */
|
94 | static atomFileEventToLSFileEvents(fileEvent: FilesystemChange): ls.FileEvent[];
|
95 | /** @deprecated Use Linter V2 service */
|
96 | static atomIdeDiagnosticToLSDiagnostic(diagnostic: atomIde.Diagnostic): ls.Diagnostic;
|
97 | /** @deprecated Use Linter V2 service */
|
98 | static diagnosticTypeToLSSeverity(type: atomIde.DiagnosticType): ls.DiagnosticSeverity;
|
99 | /**
|
100 | * Public: Convert an array of language server protocol {atomIde.TextEdit} objects to an equivalent array of Atom
|
101 | * {atomIde.TextEdit} objects.
|
102 | *
|
103 | * @param textEdits The language server protocol {atomIde.TextEdit} objects to convert.
|
104 | * @returns An {Array} of Atom {atomIde.TextEdit} objects.
|
105 | */
|
106 | static convertLsTextEdits(textEdits?: ls.TextEdit[] | null): atomIde.TextEdit[];
|
107 | /**
|
108 | * Public: Convert a language server protocol {atomIde.TextEdit} object to the Atom equivalent {atomIde.TextEdit}.
|
109 | *
|
110 | * @param textEdits The language server protocol {atomIde.TextEdit} objects to convert.
|
111 | * @returns An Atom {atomIde.TextEdit} object.
|
112 | */
|
113 | static convertLsTextEdit(textEdit: ls.TextEdit): atomIde.TextEdit;
|
114 | }
|