1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// This file contains the corresponding structures to the
6// "Text Synchronization" part of the LSP specification.
7
8package protocol
9
10type DidOpenTextDocumentParams struct {
11	/**
12	 * The document that was opened.
13	 */
14	TextDocument TextDocumentItem `json:"textDocument"`
15}
16
17type DidChangeTextDocumentParams struct {
18	/**
19	 * The document that did change. The version number points
20	 * to the version after all provided content changes have
21	 * been applied.
22	 */
23	TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
24
25	/**
26	 * The actual content changes. The content changes describe single state changes
27	 * to the document. So if there are two content changes c1 and c2 for a document
28	 * in state S10 then c1 move the document to S11 and c2 to S12.
29	 */
30	ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
31}
32
33/**
34 * An event describing a change to a text document. If range and rangeLength are omitted
35 * the new text is considered to be the full content of the document.
36 */
37type TextDocumentContentChangeEvent struct {
38	/**
39	 * The range of the document that changed.
40	 */
41	Range *Range `json:"range,omitempty"`
42
43	/**
44	 * The length of the range that got replaced.
45	 */
46	RangeLength float64 `json:"rangeLength,omitempty"`
47
48	/**
49	 * The new text of the range/document.
50	 */
51	Text string `json:"text"`
52}
53
54/**
55 * Describe options to be used when registering for text document change events.
56 */
57type TextDocumentChangeRegistrationOptions struct {
58	TextDocumentRegistrationOptions
59	/**
60	 * How documents are synced to the server. See TextDocumentSyncKind.Full
61	 * and TextDocumentSyncKind.Incremental.
62	 */
63	SyncKind float64 `json:"syncKind"`
64}
65
66/**
67 * The parameters send in a will save text document notification.
68 */
69type WillSaveTextDocumentParams struct {
70	/**
71	 * The document that will be saved.
72	 */
73	TextDocument TextDocumentIdentifier `json:"textDocument"`
74
75	/**
76	 * The 'TextDocumentSaveReason'.
77	 */
78	Reason TextDocumentSaveReason `json:"reason"`
79}
80
81/**
82 * Represents reasons why a text document is saved.
83 */
84type TextDocumentSaveReason float64
85
86const (
87	/**
88	 * Manually triggered, e.g. by the user pressing save, by starting debugging,
89	 * or by an API call.
90	 */
91	Manual TextDocumentSaveReason = 1
92
93	/**
94	 * Automatic after a delay.
95	 */
96	AfterDelay TextDocumentSaveReason = 2
97
98	/**
99	 * When the editor lost focus.
100	 */
101	FocusOut TextDocumentSaveReason = 3
102)
103
104type DidSaveTextDocumentParams struct {
105	/**
106	 * The document that was saved.
107	 */
108	TextDocument TextDocumentIdentifier `json:"textDocument"`
109
110	/**
111	 * Optional the content when saved. Depends on the includeText value
112	 * when the save notification was requested.
113	 */
114	Text string `json:"text,omitempty"`
115}
116
117type TextDocumentSaveRegistrationOptions struct {
118	TextDocumentRegistrationOptions
119	/**
120	 * The client is supposed to include the content on save.
121	 */
122	IncludeText bool `json:"includeText,omitempty"`
123}
124
125type DidCloseTextDocumentParams struct {
126	/**
127	 * The document that was closed.
128	 */
129	TextDocument TextDocumentIdentifier `json:"textDocument"`
130}
131