@@ -191,6 +191,45 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
191191
192192 def isTrait : Boolean = symbol.flags.is(Flags .Trait )
193193
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+ */
194233 def isValueParameter : Boolean = symbol.isParameter && ! symbol.isType && ! symbol.flags.is(Flags .ParamAccessor )
195234
196235 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
214253 ! definitelyGlobal && (definitelyLocal || ownerLocal)
215254 }
216255
217- def isConstructor (implicit ctx : Context ): Boolean =
218- symbol.name == " <init>"
219-
220256 def isSyntheticConstructor (implicit ctx : Context ): Boolean = {
221257 val isObjectConstructor = symbol.isConstructor && symbol.owner.exists && symbol.owner.flags.is(Flags .Object )
222258 val isModuleConstructor = symbol.isConstructor && symbol.owner.isClass
@@ -247,17 +283,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
247283 }
248284 }
249285
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-
261286 /* the `isFieldForPrivateThis` is commented out otherwise class members of the form
262287 "private[this] val foo" are not converted to symbol occurences.
263288 In the original semanticdb this line is commented out.
@@ -284,9 +309,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
284309 }
285310 ! resolved.flags.is(Flags .Package ) && resolved.flags.is(Flags .JavaDefined ) && resolved.flags.is(Flags .Object )
286311 }
287- def isAnonymousClassConstructor (implicit ctx : Context ): Boolean = {
288- symbol.isConstructor && symbol.owner.isAnonymousClass
289- }
290312 def isSyntheticAbstractType (implicit ctx : Context ): Boolean = {
291313 symbol.flags.is(Flags .Synthetic ) && symbol.isAbstractType // these are hardlinked to TypeOps
292314 }
@@ -297,12 +319,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
297319 symbol.name.startsWith(" x$" ) &&
298320 symbol.owner.isAnonymousFunction
299321 }
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- }
306322 def isStaticMember (implicit ctx : Context ): Boolean =
307323 symbol.exists &&
308324 (symbol.flags.is(Flags .Static ) || symbol.owner.flags.is(Flags .ImplClass ) ||
@@ -312,6 +328,8 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
312328 (symbol.isStaticMember && symbol.isClassConstructor) || (symbol.name == tpnme.STATIC_CONSTRUCTOR .toString)
313329 }
314330
331+ /* End of methods imported from the scala version of SemanticDB */
332+
315333 def isInitChild (implicit ctx : Context ): Boolean = {
316334 if (symbol.exists && symbol.owner.exists) {
317335 return symbol.owner.name == " <init>" || symbol.owner.isInitChild
@@ -320,17 +338,6 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum
320338 }
321339 }
322340
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-
334341 def isUseless (implicit ctx : Context ): Boolean = {
335342 ! symbol.exists ||
336343 symbol.isReservedName ||
0 commit comments