forked from PowerShell/PowerShellEditorServices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextDocument.cs
161 lines (136 loc) · 4.73 KB
/
TextDocument.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Diagnostics;
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
{
/// <summary>
/// Defines a base parameter class for identifying a text document.
/// </summary>
[DebuggerDisplay("TextDocumentIdentifier = {Uri}")]
public class TextDocumentIdentifier
{
/// <summary>
/// Gets or sets the URI which identifies the path of the
/// text document.
/// </summary>
public string Uri { get; set; }
}
/// <summary>
/// Defines a position in a text document.
/// </summary>
[DebuggerDisplay("TextDocumentPosition = {Position.Line}:{Position.Character}")]
public class TextDocumentPosition : TextDocumentIdentifier
{
/// <summary>
/// Gets or sets the position in the document.
/// </summary>
public Position Position { get; set; }
}
public class DidOpenTextDocumentNotification : TextDocumentIdentifier
{
public static readonly
EventType<DidOpenTextDocumentNotification> Type =
EventType<DidOpenTextDocumentNotification>.Create("textDocument/didOpen");
/// <summary>
/// Gets or sets the full content of the opened document.
/// </summary>
public string Text { get; set; }
}
public class DidCloseTextDocumentNotification
{
public static readonly
EventType<TextDocumentIdentifier> Type =
EventType<TextDocumentIdentifier>.Create("textDocument/didClose");
}
public class DidSaveTextDocumentNotification
{
public static readonly
EventType<DidSaveTextDocumentParams> Type =
EventType<DidSaveTextDocumentParams>.Create("textDocument/didSave");
}
public class DidSaveTextDocumentParams
{
public TextDocumentIdentifier TextDocument { get; set; }
}
public class DidChangeTextDocumentNotification
{
public static readonly
EventType<DidChangeTextDocumentParams> Type =
EventType<DidChangeTextDocumentParams>.Create("textDocument/didChange");
}
public class DidChangeTextDocumentParams : TextDocumentIdentifier
{
/// <summary>
/// Gets or sets the list of changes to the document content.
/// </summary>
public TextDocumentChangeEvent[] ContentChanges { get; set; }
}
public class TextDocumentChangeEvent
{
/// <summary>
/// Gets or sets the Range where the document was changed. Will
/// be null if the server's TextDocumentSyncKind is Full.
/// </summary>
public Range? Range { get; set; }
/// <summary>
/// Gets or sets the length of the Range being replaced in the
/// document. Will be null if the server's TextDocumentSyncKind is
/// Full.
/// </summary>
public int? RangeLength { get; set; }
/// <summary>
/// Gets or sets the new text of the document.
/// </summary>
public string Text { get; set; }
}
[DebuggerDisplay("Position = {Line}:{Character}")]
public class Position
{
/// <summary>
/// Gets or sets the zero-based line number.
/// </summary>
public int Line { get; set; }
/// <summary>
/// Gets or sets the zero-based column number.
/// </summary>
public int Character { get; set; }
}
[DebuggerDisplay("Start = {Start.Line}:{Start.Character}, End = {End.Line}:{End.Character}")]
public struct Range
{
/// <summary>
/// Gets or sets the starting position of the range.
/// </summary>
public Position Start { get; set; }
/// <summary>
/// Gets or sets the ending position of the range.
/// </summary>
public Position End { get; set; }
}
[DebuggerDisplay("Range = {Range.Start.Line}:{Range.Start.Character} - {Range.End.Line}:{Range.End.Character}, Uri = {Uri}")]
public class Location
{
/// <summary>
/// Gets or sets the URI indicating the file in which the location refers.
/// </summary>
public string Uri { get; set; }
/// <summary>
/// Gets or sets the Range indicating the range in which location refers.
/// </summary>
public Range Range { get; set; }
}
public enum FileChangeType
{
Created = 1,
Changed,
Deleted
}
public class FileEvent
{
public string Uri { get; set; }
public FileChangeType Type { get; set; }
}
}