1
1
package dotty .tools .dotc .semanticdb
2
2
3
- import dotty .tools .dotc .core .Symbols .{ Symbol , defn }
3
+ import dotty .tools .dotc .core .Symbols .{ Symbol , defn }
4
4
import dotty .tools .dotc .core .Contexts .Context
5
5
import dotty .tools .dotc .core .Names
6
6
import dotty .tools .dotc .core .Names .Name
@@ -14,6 +14,7 @@ import scala.annotation.internal.sharable
14
14
import scala .annotation .switch
15
15
16
16
object Scala with
17
+ import Symbols ._
17
18
import NameOps .given
18
19
19
20
@ sharable private val unicodeEscape = raw " \ $$ u(\p{XDigit}{4}) " .r
@@ -30,15 +31,16 @@ object Scala with
30
31
def isVar : Boolean = kind match
31
32
case Var | Setter => true
32
33
case _ => false
33
-
34
34
def isVal : Boolean = kind == Val
35
-
36
35
def isVarOrVal : Boolean = kind.isVar || kind.isVal
37
36
37
+ end SymbolKind
38
+
38
39
object SymbolKind with
39
40
val ValSet = Set (Val )
40
41
val VarSet = Set (Var )
41
42
val emptySet = Set .empty[SymbolKind ]
43
+ end SymbolKind
42
44
43
45
object Symbols with
44
46
@@ -62,9 +64,7 @@ object Scala with
62
64
else
63
65
symbol.name.show
64
66
65
- given symbolOps : (symbol : String ) with
66
- def unescapeUnicode =
67
- unicodeEscape.replaceAllIn(symbol, m => String .valueOf(Integer .parseInt(m.group(1 ), 16 ).toChar))
67
+ end Symbols
68
68
69
69
given nameOps : (name : Name ) with
70
70
@@ -79,6 +79,7 @@ object Scala with
79
79
case NameKinds .ModuleClassName (original) => original.isScala2PackageObjectName
80
80
case _ => false
81
81
82
+ end nameOps
82
83
83
84
given symbolOps : (sym : Symbol ) with
84
85
@@ -100,33 +101,40 @@ object Scala with
100
101
101
102
sym.owner.info.decls.find(s => s.name == setterName && s.info.matchingType)
102
103
104
+ end symbolOps
105
+
103
106
object LocalSymbol with
104
107
def unapply (symbolInfo : SymbolInformation ): Option [Int ] =
105
- symbolInfo.symbol match
106
- case locals(ints) =>
107
- val bi = BigInt (ints)
108
- if bi.isValidInt then Some (bi.toInt) else None
109
- case _ => None
110
-
111
- given (symbol : String ) with
112
-
113
- def isNoSymbol : Boolean =
114
- symbol == Symbols .NoSymbol
115
- def isRootPackage : Boolean =
116
- symbol == Symbols .RootPackage
117
- def isEmptyPackage : Boolean =
118
- symbol == Symbols .EmptyPackage
108
+ symbolInfo.symbol match
109
+
110
+ case locals(ints) =>
111
+ val bi = BigInt (ints)
112
+ if bi.isValidInt
113
+ Some (bi.toInt)
114
+ else
115
+ None
116
+
117
+ case _ => None
118
+
119
+ end LocalSymbol
120
+
121
+ given stringOps : (symbol : String ) with
122
+
123
+ def isNoSymbol : Boolean = NoSymbol == symbol
124
+ def isRootPackage : Boolean = RootPackage == symbol
125
+ def isEmptyPackage : Boolean = EmptyPackage == symbol
126
+
119
127
def isGlobal : Boolean =
120
128
! symbol.isNoSymbol
121
129
&& ! symbol.isMulti
122
130
&& { (symbol.last: @ switch) match
123
131
case '.' | '#' | '/' | ')' | ']' => true
124
132
case _ => false
125
133
}
126
- def isLocal : Boolean =
127
- locals matches symbol
128
- def isMulti : Boolean =
129
- symbol startsWith " ; "
134
+
135
+ def isLocal : Boolean = ! symbol.isGlobal
136
+ def isMulti : Boolean = symbol startsWith " ; "
137
+
130
138
def isConstructor : Boolean =
131
139
ctor matches symbol
132
140
def isTerm : Boolean =
@@ -140,33 +148,55 @@ object Scala with
140
148
def isTypeParameter : Boolean =
141
149
! symbol.isNoSymbol && ! symbol.isMulti && symbol.last == ']'
142
150
143
- given (info : SymbolInformation ) with
151
+ def unescapeUnicode =
152
+ unicodeEscape.replaceAllIn(symbol, m => String .valueOf(Integer .parseInt(m.group(1 ), 16 ).toChar))
153
+
154
+ end stringOps
155
+
156
+ given infoOps : (info : SymbolInformation ) with
144
157
145
- def isPrimary : Boolean =
146
- (info.properties & SymbolInformation .Property .PRIMARY .value) != 0
147
158
def isAbstract : Boolean =
148
159
(info.properties & SymbolInformation .Property .ABSTRACT .value) != 0
160
+
149
161
def isFinal : Boolean =
150
162
(info.properties & SymbolInformation .Property .FINAL .value) != 0
163
+
151
164
def isSealed : Boolean =
152
165
(info.properties & SymbolInformation .Property .SEALED .value) != 0
166
+
153
167
def isImplicit : Boolean =
154
168
(info.properties & SymbolInformation .Property .IMPLICIT .value) != 0
169
+
155
170
def isLazy : Boolean =
156
171
(info.properties & SymbolInformation .Property .LAZY .value) != 0
172
+
157
173
def isCase : Boolean =
158
174
(info.properties & SymbolInformation .Property .CASE .value) != 0
175
+
159
176
def isCovariant : Boolean =
160
177
(info.properties & SymbolInformation .Property .COVARIANT .value) != 0
178
+
161
179
def isContravariant : Boolean =
162
180
(info.properties & SymbolInformation .Property .CONTRAVARIANT .value) != 0
181
+
182
+ def isPrimary : Boolean =
183
+ (info.properties & SymbolInformation .Property .PRIMARY .value) != 0
184
+
163
185
def isVal : Boolean =
164
186
(info.properties & SymbolInformation .Property .VAL .value) != 0
187
+
165
188
def isVar : Boolean =
166
189
(info.properties & SymbolInformation .Property .VAR .value) != 0
190
+
167
191
def isStatic : Boolean =
168
192
(info.properties & SymbolInformation .Property .STATIC .value) != 0
193
+
169
194
def isEnum : Boolean =
170
195
(info.properties & SymbolInformation .Property .ENUM .value) != 0
196
+
171
197
def isDefault : Boolean =
172
198
(info.properties & SymbolInformation .Property .DEFAULT .value) != 0
199
+
200
+ end infoOps
201
+
202
+ end Scala
0 commit comments