@@ -191,6 +191,45 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
191
191
192
192
def isTrait : Boolean = symbol.flags.is(Flags .Trait )
193
193
194
+ def isConstructor (implicit ctx : Context ): Boolean =
195
+ symbol.name == " <init>"
196
+
197
+ def isVarAccessor (implicit ctx : Context ): Boolean = {
198
+ symbol.isVal && symbol.flags.is(Flags .Mutable )
199
+ }
200
+
201
+ def isValMethod (implicit ctx : Context ): Boolean = {
202
+ symbol.isMethod && {
203
+ (symbol.flags.is(Flags .FieldAccessor ) && symbol.flags.is(Flags .Stable ) ) ||
204
+ (symbol.isUsefulField && ! symbol.flags.is(Flags .Mutable ) )
205
+ }
206
+ }
207
+
208
+ def isAnonymousClassConstructor (implicit ctx : Context ): Boolean = {
209
+ symbol.isConstructor && symbol.owner.isAnonymousClass
210
+ }
211
+
212
+ def isAnonymousSelfParameter (implicit ctx : Context ): Boolean = {
213
+ symbol.isSelfParameter && {
214
+ symbol.name == tpnme.this_.toString || // hardlinked in ClassSignature.self
215
+ symbol.name.startsWith(" x$" ) // wildcards can't be referenced: class A { _: B => }
216
+ }
217
+ }
218
+
219
+ def isWildCard (implicit ctx : Context ): Boolean = {
220
+ symbol.name.startsWith(tpnme.WILDCARD .toString) &&
221
+ symbol.name != tpnme.THIS .toString
222
+ }
223
+
224
+ def isAnonymousInit (implicit ctx : Context ): Boolean = {
225
+ return symbol.exists && symbol.owner.exists &&
226
+ (symbol.owner.isAnonymousFunction || symbol.owner.isAnonymousClass) &&
227
+ symbol.name == " <init>"
228
+ }
229
+
230
+ /* The following methods are directly extracted from the scala
231
+ implementation of SemanticDB (scalameta/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/SymbolOps.scala)
232
+ */
194
233
def isValueParameter : Boolean = symbol.isParameter && ! symbol.isType && ! symbol.flags.is(Flags .ParamAccessor )
195
234
196
235
def isJavaClass : Boolean = (symbol.isClass || symbol.isObject) && symbol.flags.is(Flags .JavaDefined )
@@ -214,9 +253,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
214
253
! definitelyGlobal && (definitelyLocal || ownerLocal)
215
254
}
216
255
217
- def isConstructor (implicit ctx : Context ): Boolean =
218
- symbol.name == " <init>"
219
-
220
256
def isSyntheticConstructor (implicit ctx : Context ): Boolean = {
221
257
val isObjectConstructor = symbol.isConstructor && symbol.owner.exists && symbol.owner.flags.is(Flags .Object )
222
258
val isModuleConstructor = symbol.isConstructor && symbol.owner.isClass
@@ -247,17 +283,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
247
283
}
248
284
}
249
285
250
- def isVarAccessor (implicit ctx : Context ): Boolean = {
251
- symbol.isVal && symbol.flags.is(Flags .Mutable )
252
- }
253
-
254
- def isValMethod (implicit ctx : Context ): Boolean = {
255
- symbol.isMethod && {
256
- (symbol.flags.is(Flags .FieldAccessor ) && symbol.flags.is(Flags .Stable ) ) ||
257
- (symbol.isUsefulField && ! symbol.flags.is(Flags .Mutable ) )
258
- }
259
- }
260
-
261
286
/* the `isFieldForPrivateThis` is commented out otherwise class members of the form
262
287
"private[this] val foo" are not converted to symbol occurences.
263
288
In the original semanticdb this line is commented out.
@@ -284,9 +309,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
284
309
}
285
310
! resolved.flags.is(Flags .Package ) && resolved.flags.is(Flags .JavaDefined ) && resolved.flags.is(Flags .Object )
286
311
}
287
- def isAnonymousClassConstructor (implicit ctx : Context ): Boolean = {
288
- symbol.isConstructor && symbol.owner.isAnonymousClass
289
- }
290
312
def isSyntheticAbstractType (implicit ctx : Context ): Boolean = {
291
313
symbol.flags.is(Flags .Synthetic ) && symbol.isAbstractType // these are hardlinked to TypeOps
292
314
}
@@ -297,12 +319,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
297
319
symbol.name.startsWith(" x$" ) &&
298
320
symbol.owner.isAnonymousFunction
299
321
}
300
- def isAnonymousSelfParameter (implicit ctx : Context ): Boolean = {
301
- symbol.isSelfParameter && {
302
- symbol.name == tpnme.this_.toString || // hardlinked in ClassSignature.self
303
- symbol.name.startsWith(" x$" ) // wildcards can't be referenced: class A { _: B => }
304
- }
305
- }
306
322
def isStaticMember (implicit ctx : Context ): Boolean =
307
323
symbol.exists &&
308
324
(symbol.flags.is(Flags .Static ) || symbol.owner.flags.is(Flags .ImplClass ) ||
@@ -312,6 +328,8 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
312
328
(symbol.isStaticMember && symbol.isClassConstructor) || (symbol.name == tpnme.STATIC_CONSTRUCTOR .toString)
313
329
}
314
330
331
+ /* End of methods imported from the scala version of SemanticDB */
332
+
315
333
def isInitChild (implicit ctx : Context ): Boolean = {
316
334
if (symbol.exists && symbol.owner.exists) {
317
335
return symbol.owner.name == " <init>" || symbol.owner.isInitChild
@@ -320,17 +338,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
320
338
}
321
339
}
322
340
323
- def isWildCard (implicit ctx : Context ): Boolean = {
324
- symbol.name.startsWith(tpnme.WILDCARD .toString) &&
325
- symbol.name != tpnme.THIS .toString
326
- }
327
-
328
- def isAnonymousInit (implicit ctx : Context ): Boolean = {
329
- return symbol.exists && symbol.owner.exists &&
330
- (symbol.owner.isAnonymousFunction || symbol.owner.isAnonymousClass) &&
331
- symbol.name == " <init>"
332
- }
333
-
334
341
def isUseless (implicit ctx : Context ): Boolean = {
335
342
! symbol.exists ||
336
343
symbol.isReservedName ||
0 commit comments