77
88// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#semanticTokenModifiers
99
10- public enum CaptureModifiers : Int8 , CaseIterable , Sendable {
10+ public enum CaptureModifier : Int8 , CaseIterable , Sendable {
1111 case declaration
1212 case definition
1313 case readonly
@@ -18,9 +18,59 @@ public enum CaptureModifiers: Int8, CaseIterable, Sendable {
1818 case modification
1919 case documentation
2020 case defaultLibrary
21+
22+ var stringValue : String {
23+ switch self {
24+ case . declaration:
25+ return " declaration "
26+ case . definition:
27+ return " definition "
28+ case . readonly:
29+ return " readonly "
30+ case . static:
31+ return " static "
32+ case . deprecated:
33+ return " deprecated "
34+ case . abstract:
35+ return " abstract "
36+ case . async :
37+ return " async "
38+ case . modification:
39+ return " modification "
40+ case . documentation:
41+ return " documentation "
42+ case . defaultLibrary:
43+ return " defaultLibrary "
44+ }
45+ }
46+
47+ static func fromString( _ string: String ) -> CaptureModifier {
48+ switch string {
49+ case " declaration " :
50+ return . declaration
51+ case " definition " :
52+ return . definition
53+ case " readonly " :
54+ return . readonly
55+ case " static` " :
56+ return . static
57+ case " deprecated " :
58+ return . deprecated
59+ case " abstract " :
60+ return . abstract
61+ case " async " :
62+ return . async
63+ case " modification " :
64+ return . modification
65+ case " documentation " :
66+ return . documentation
67+ case " defaultLibrary " :
68+ return . defaultLibrary
69+ }
70+ }
2171}
2272
23- extension CaptureModifiers : CustomDebugStringConvertible {
73+ extension CaptureModifier : CustomDebugStringConvertible {
2474 public var debugDescription : String {
2575 switch self {
2676 case . declaration: return " declaration "
@@ -45,25 +95,25 @@ public struct CaptureModifierSet: OptionSet, Equatable, Hashable, Sendable {
4595 self . rawValue = rawValue
4696 }
4797
48- static let declaration = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . declaration. rawValue)
49- static let definition = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . definition. rawValue)
50- static let readonly = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . readonly. rawValue)
51- static let `static` = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . static. rawValue)
52- static let deprecated = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . deprecated. rawValue)
53- static let abstract = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . abstract. rawValue)
54- static let async = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . async . rawValue)
55- static let modification = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . modification. rawValue)
56- static let documentation = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . documentation. rawValue)
57- static let defaultLibrary = CaptureModifierSet ( rawValue: 1 << CaptureModifiers . defaultLibrary. rawValue)
98+ static let declaration = CaptureModifierSet ( rawValue: 1 << CaptureModifier . declaration. rawValue)
99+ static let definition = CaptureModifierSet ( rawValue: 1 << CaptureModifier . definition. rawValue)
100+ static let readonly = CaptureModifierSet ( rawValue: 1 << CaptureModifier . readonly. rawValue)
101+ static let `static` = CaptureModifierSet ( rawValue: 1 << CaptureModifier . static. rawValue)
102+ static let deprecated = CaptureModifierSet ( rawValue: 1 << CaptureModifier . deprecated. rawValue)
103+ static let abstract = CaptureModifierSet ( rawValue: 1 << CaptureModifier . abstract. rawValue)
104+ static let async = CaptureModifierSet ( rawValue: 1 << CaptureModifier . async . rawValue)
105+ static let modification = CaptureModifierSet ( rawValue: 1 << CaptureModifier . modification. rawValue)
106+ static let documentation = CaptureModifierSet ( rawValue: 1 << CaptureModifier . documentation. rawValue)
107+ static let defaultLibrary = CaptureModifierSet ( rawValue: 1 << CaptureModifier . defaultLibrary. rawValue)
58108
59109 /// All values in the set.
60- var values : [ CaptureModifiers ] {
110+ var values : [ CaptureModifier ] {
61111 var rawValue = self . rawValue
62112 var values : [ Int8 ] = [ ]
63113 while rawValue > 0 {
64114 values. append ( Int8 ( rawValue. trailingZeroBitCount) )
65115 rawValue &= ~ UInt( 1 << rawValue. trailingZeroBitCount)
66116 }
67- return values. compactMap ( { CaptureModifiers ( rawValue: $0) } )
117+ return values. compactMap ( { CaptureModifier ( rawValue: $0) } )
68118 }
69119}
0 commit comments