1
+ using System . Collections . Generic ;
2
+ using System . Linq ;
3
+ using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
4
+
5
+ namespace OmniSharp . Extensions . LanguageServer . Protocol . Server
6
+ {
7
+ public static class LanguageServerConfigurationExtensions
8
+ {
9
+ /// <summary>
10
+ /// Adds a set of configuration items to be tracked by the server
11
+ /// </summary>
12
+ /// <param name="configuration"></param>
13
+ /// <param name="configurationItem"></param>
14
+ /// <param name="configurationItems"></param>
15
+ /// <returns></returns>
16
+ public static ILanguageServerConfiguration AddConfigurationItem ( this ILanguageServerConfiguration configuration , ConfigurationItem configurationItem , params ConfigurationItem [ ] configurationItems )
17
+ {
18
+ return configuration . AddConfigurationItems ( new [ ] { configurationItem } . Concat ( configurationItems ) ) ;
19
+ }
20
+
21
+ /// <summary>
22
+ /// Stops tracking a given set of configuration items
23
+ /// </summary>
24
+ /// <param name="configuration"></param>
25
+ /// <param name="configurationItem"></param>
26
+ /// <param name="configurationItems"></param>
27
+ /// <returns></returns>
28
+ public static ILanguageServerConfiguration RemoveConfigurationItem ( this ILanguageServerConfiguration configuration , ConfigurationItem configurationItem , params ConfigurationItem [ ] configurationItems )
29
+ {
30
+ return configuration . RemoveConfigurationItems ( new [ ] { configurationItem } . Concat ( configurationItems ) ) ;
31
+ }
32
+
33
+ /// <summary>
34
+ /// Adds a set of configuration items to be tracked by the server
35
+ /// </summary>
36
+ /// <param name="configuration"></param>
37
+ /// <param name="section"></param>
38
+ /// <param name="sections"></param>
39
+ /// <returns></returns>
40
+ public static ILanguageServerConfiguration AddSection ( this ILanguageServerConfiguration configuration , string section , params string [ ] sections )
41
+ {
42
+ return configuration . AddConfigurationItems ( new [ ] { section } . Concat ( sections ) . Select ( z => new ConfigurationItem ( ) { Section = z } ) ) ;
43
+ }
44
+
45
+ /// <summary>
46
+ /// Stops tracking a given set of configuration items
47
+ /// </summary>
48
+ /// <param name="configuration"></param>
49
+ /// <param name="section"></param>
50
+ /// <param name="sections"></param>
51
+ /// <returns></returns>
52
+ public static ILanguageServerConfiguration RemoveSection ( this ILanguageServerConfiguration configuration , string section , params string [ ] sections )
53
+ {
54
+ return configuration . RemoveConfigurationItems ( new [ ] { section } . Concat ( sections ) . Select ( z => new ConfigurationItem ( ) { Section = z } ) ) ;
55
+ }
56
+
57
+ /// <summary>
58
+ /// Adds a set of configuration items to be tracked by the server
59
+ /// </summary>
60
+ /// <param name="configuration"></param>
61
+ /// <param name="sections"></param>
62
+ /// <returns></returns>
63
+ public static ILanguageServerConfiguration AddSections ( this ILanguageServerConfiguration configuration , IEnumerable < string > sections )
64
+ {
65
+ return configuration . AddConfigurationItems ( sections . Select ( z => new ConfigurationItem ( ) { Section = z } ) ) ;
66
+ }
67
+
68
+ /// <summary>
69
+ /// Stops tracking a given set of configuration items
70
+ /// </summary>
71
+ /// <param name="configuration"></param>
72
+ /// <param name="sections"></param>
73
+ /// <returns></returns>
74
+ public static ILanguageServerConfiguration RemoveSections ( this ILanguageServerConfiguration configuration , IEnumerable < string > sections )
75
+ {
76
+ return configuration . RemoveConfigurationItems ( sections . Select ( z => new ConfigurationItem ( ) { Section = z } ) ) ;
77
+ }
78
+ }
79
+ }
0 commit comments