You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basic.go
+88-61Lines changed: 88 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -30,31 +30,37 @@ var EOL = []string{"\n", "\r\n", "\r"}
30
30
//
31
31
// The offsets are based on a UTF-16 string representation.
32
32
// So a string of the form "a𐐀b" the character offset of the character "a" is 0,
33
-
// the character offset of "𐐀" is 1 and the character offset of "b" is 3 since 𐐀 is represented using two code units in UTF-16.
33
+
// the character offset of "𐐀" is 1 and the character offset of "b" is 3 since 𐐀 is represented using two code
34
+
// units in UTF-16.
34
35
//
35
-
// To ensure that both client and server split the string into the same line representation the protocol
36
-
// specifies the following end-of-line sequences: "\n", "\r\n' and "\r".
36
+
// Positions are line end character agnostic. So you can not specify a position that
37
+
// denotes "\r|\n" or "\n|" where "|" represents the character offset.
37
38
//
38
39
// A position is between two characters like an "insert" cursor in a editor.
39
40
// Special values like for example "-1" to denote the end of a line are not supported.
40
41
typePositionstruct {
41
42
// Line position in a document (zero-based).
43
+
//
44
+
// If a line number is greater than the number of lines in a document, it defaults back to the number of lines in
45
+
// the document.
46
+
// If a line number is negative, it defaults to 0.
42
47
Lineuint32`json:"line"`
43
48
44
49
// Character offset on a line in a document (zero-based).
45
50
//
46
-
// Assuming that the line is represented as a string, the "character" value represents the gap between the
51
+
// Assuming that the line is represented as a string, the Character value represents the gap between the
47
52
// "character" and "character + 1".
48
53
//
49
-
// If the character value is greater than the line length it defaults back to the
50
-
// line length.
54
+
// If the character value is greater than the line length it defaults back to the line length.
55
+
// If a line number is negative, it defaults to 0.
51
56
Characteruint32`json:"character"`
52
57
}
53
58
54
59
// Range represents a text document expressed as (zero-based) start and end positions.
55
60
//
56
61
// A range is comparable to a selection in an editor. Therefore the end position is exclusive.
57
-
// If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.
62
+
// If you want to specify a range that contains a line including the line ending character(s) then use an end position
63
+
// denoting the start of the next line.
58
64
typeRangestruct {
59
65
// Start is the range's start position.
60
66
StartPosition`json:"start"`
@@ -79,24 +85,21 @@ type LocationLink struct {
79
85
// TargetURI is the target resource identifier of this link.
80
86
TargetURIDocumentURI`json:"targetUri"`
81
87
82
-
// TargetRange is the full target range of this link. If the target for example is a symbol then target range is the
83
-
// range enclosing this symbol not including leading/trailing whitespace but everything else
84
-
// like comments. This information is typically used to highlight the range in the editor.
88
+
// TargetRange is the full target range of this link.
89
+
//
90
+
// If the target for example is a symbol then target range is the range enclosing this symbol not including
91
+
// leading/trailing whitespace but everything else like comments.
92
+
//
93
+
// This information is typically used to highlight the range in the editor.
85
94
TargetRangeRange`json:"targetRange"`
86
95
87
-
// TargetSelectionRange is the range that should be selected and revealed when this link is being followed, e.g the name of a function.
88
-
// Must be contained by the the `targetRange`. See also `DocumentSymbol#range`
96
+
// TargetSelectionRange is the range that should be selected and revealed when this link is being followed,
97
+
// e.g the name of a function.
98
+
//
99
+
// Must be contained by the the TargetRange. See also DocumentSymbol#range
// CodeDescription is the structure to capture a description for an error code.
93
-
//
94
-
// @since 3.16.0.
95
-
typeCodeDescriptionstruct {
96
-
// Href an URI to open with more information about the diagnostic error.
97
-
HrefURI`json:"href"`
98
-
}
99
-
100
103
// Diagnostic represents a diagnostic, such as a compiler error or warning.
101
104
//
102
105
// Diagnostic objects are only valid in the scope of a resource.
@@ -216,11 +219,22 @@ type DiagnosticRelatedInformation struct {
216
219
Messagestring`json:"message"`
217
220
}
218
221
222
+
// CodeDescription is the structure to capture a description for an error code.
223
+
//
224
+
// @since 3.16.0.
225
+
typeCodeDescriptionstruct {
226
+
// Href an URI to open with more information about the diagnostic error.
227
+
HrefURI`json:"href"`
228
+
}
229
+
219
230
// Command represents a reference to a command. Provides a title which will be used to represent a command in the UI.
220
231
//
221
232
// Commands are identified by a string identifier.
222
-
// The recommended way to handle commands is to implement their execution on the server side if the client and server provides the corresponding capabilities.
223
-
// Alternatively the tool extension code could handle the command. The protocol currently doesn't specify a set of well-known commands.
233
+
// The recommended way to handle commands is to implement their execution on the server side if the client and
234
+
// server provides the corresponding capabilities.
235
+
//
236
+
// Alternatively the tool extension code could handle the command. The protocol currently doesn't specify
// TextEdit is a textual edit applicable to a text document.
269
-
typeTextEditstruct {
270
-
// Range is the range of the text document to be manipulated.
271
-
// To insert text into a document create a range where start === end.
272
-
RangeRange`json:"range"`
273
-
274
-
// NewText is the string to be inserted. For delete operations use an
275
-
// empty string.
276
-
NewTextstring`json:"newText"`
277
-
}
278
-
279
294
// TextDocumentEdit describes textual changes on a single text document.
280
295
//
281
-
// The text document is referred to as a VersionedTextDocumentIdentifier to allow clients to check the text document version before an edit is applied.
282
-
// A TextDocumentEdit describes all changes on a version Si and after they are applied move the document to version Si+1.
283
-
// So the creator of a TextDocumentEdit doesn't need to sort the array or do any kind of ordering. However the edits must be non overlapping.
296
+
// The TextDocument is referred to as a OptionalVersionedTextDocumentIdentifier to allow clients to check the
297
+
// text document version before an edit is applied.
298
+
//
299
+
// TextDocumentEdit describes all changes on a version "Si" and after they are applied move the document to
300
+
// version "Si+1".
301
+
// So the creator of a TextDocumentEdit doesn't need to sort the array or do any kind of ordering. However the
@@ -740,12 +762,18 @@ type DocumentFilter struct {
740
762
// Pattern a glob pattern, like `*.{ts,js}`.
741
763
//
742
764
// Glob patterns can have the following syntax:
743
-
// - `*` to match one or more characters in a path segment
744
-
// - `?` to match on one character in a path segment
745
-
// - `**` to match any number of path segments, including none
746
-
// - `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
747
-
// - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
748
-
// - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
765
+
// "*"
766
+
// to match one or more characters in a path segment
767
+
// "?"
768
+
// to match on one character in a path segment
769
+
// "**"
770
+
// to match any number of path segments, including none
771
+
// "{}"
772
+
// to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
773
+
// "[]"
774
+
// to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
775
+
// "[!...]"
776
+
// to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
749
777
Patternstring`json:"pattern,omitempty"`
750
778
}
751
779
@@ -776,18 +804,17 @@ const (
776
804
// See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
777
805
//
778
806
// Here is an example how such a string can be constructed using JavaScript / TypeScript:
779
-
// ```typescript
780
-
// * let markdown: MarkdownContent = {
781
-
// * kind: MarkupKind.Markdown,
782
-
// * value: [
783
-
// * '# Header',
784
-
// * 'Some text',
785
-
// * '```typescript',
786
-
// 'someCode();',
787
-
// '```'
788
-
// * ].join('\n')
789
-
// * };
790
-
// * ```
807
+
//
808
+
// let markdown: MarkdownContent = {
809
+
// kind: MarkupKind.Markdown,
810
+
// value: [
811
+
// '# Header',
812
+
// 'Some text',
813
+
// '```typescript',
814
+
// 'someCode();',
815
+
// '```'
816
+
// ].join('\n')
817
+
// };
791
818
//
792
819
// NOTE: clients might sanitize the return markdown. A client could decide to
793
820
// remove HTML from the markdown to avoid script execution.
0 commit comments