1 /*
2  *Copyright (C) 2018 Laurent Tréguier
3  *
4  *This file is part of DLS.
5  *
6  *DLS is free software: you can redistribute it and/or modify
7  *it under the terms of the GNU General Public License as published by
8  *the Free Software Foundation, either version 3 of the License, or
9  *(at your option) any later version.
10  *
11  *DLS is distributed in the hope that it will be useful,
12  *but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *GNU General Public License for more details.
15  *
16  *You should have received a copy of the GNU General Public License
17  *along with DLS.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 module dls.protocol.interfaces.client;
22 
23 private abstract class RegistrationBase
24 {
25     string id;
26     string method;
27 
28     @safe this(string id, string method) pure nothrow
29     {
30         this.id = id;
31         this.method = method;
32     }
33 }
34 
35 package interface RegistrationOptions
36 {
37 }
38 
39 final class Registration(R : RegistrationOptions) : RegistrationBase
40 {
41     import std.typecons : Nullable;
42 
43     Nullable!R registerOptions;
44 
45     @safe this(string id = string.init, string method = string.init,
46             Nullable!R registerOptions = Nullable!R.init) pure nothrow
47     {
48         super(id, method);
49         this.registerOptions = registerOptions;
50     }
51 }
52 
53 class TextDocumentRegistrationOptions : RegistrationOptions
54 {
55     import dls.protocol.definitions : DocumentSelector;
56     import std.typecons : Nullable;
57 
58     Nullable!DocumentSelector documentSelector;
59 
60     @safe this(Nullable!DocumentSelector documentSelector = Nullable!DocumentSelector.init) pure nothrow
61     {
62         this.documentSelector = documentSelector;
63     }
64 }
65 
66 final class RegistrationParams(R : RegistrationOptions)
67 {
68     Registration!R[] registrations;
69 
70     @safe this(Registration!R[] registrations = Registration!R[].init) pure nothrow
71     {
72         this.registrations = registrations;
73     }
74 }
75 
76 final class Unregistration : RegistrationBase
77 {
78     @safe this(string id = string.init, string method = string.init) pure nothrow
79     {
80         super(id, method);
81     }
82 }
83 
84 final class UnregistrationParams
85 {
86     Unregistration[] unregistrations;
87 
88     @safe this(Unregistration[] unregistrations = Unregistration[].init) pure nothrow
89     {
90         this.unregistrations = unregistrations;
91     }
92 }