Skip to content

Commit 83ae6da

Browse files
committed
more symbols in symbol section
1 parent 18d003b commit 83ae6da

File tree

5 files changed

+227
-101
lines changed

5 files changed

+227
-101
lines changed

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,24 @@ class ExtractSemanticDB extends Phase with
165165
|| sym.is(Synthetic)
166166
|| sym.owner.is(Synthetic) && !sym.owner.isAnonymous && !sym.isAllOf(EnumCase)
167167
|| sym.isConstructor && sym.owner.is(ModuleClass)
168-
|| sym.isAnonymous
169168
|| excludeDefStrict(sym)
170169

171170
private def excludeDefStrict(sym: Symbol)(given Context): Boolean =
172171
sym.name.is(NameKinds.DefaultGetterName)
173-
|| sym.name.isWildcard
172+
|| excludeSymbolStrict(sym)
173+
174+
private inline def (name: Name) isEmptyNumbered: Boolean = name match
175+
case NameKinds.AnyNumberedName(nme.EMPTY, _) => true
176+
case _ => false
177+
178+
private def excludeSymbolStrict(sym: Symbol)(given Context): Boolean =
179+
sym.name.isWildcard
180+
|| sym.isAnonymous
181+
|| sym.name.isEmptyNumbered
182+
183+
private def excludeChildren(sym: Symbol)(given Context): Boolean =
184+
sym.isAllOf(HigherKinded | Param)
185+
|| !sym.isAnonymous && sym.is(Synthetic, butNot=Module)
174186

175187
/** Uses of this symbol where the reference has given span should be excluded from semanticdb */
176188
private def excludeUseStrict(sym: Symbol, span: Span)(given Context): Boolean =
@@ -359,7 +371,7 @@ class ExtractSemanticDB extends Phase with
359371
vparams <- vparamss
360372
vparam <- vparams
361373
do
362-
if !vparam.name.isWildcard
374+
if !excludeSymbolStrict(vparam.symbol)
363375
val symkinds =
364376
getters.get(vparam.name).fold(SymbolKind.emptySet)(getter =>
365377
if getter.mods.is(Mutable) then SymbolKind.VarSet else SymbolKind.ValSet)
@@ -392,13 +404,16 @@ class ExtractSemanticDB extends Phase with
392404
traverse(qual)
393405
case tree => registerDefinition(tree.symbol, tree.span, Set.empty)
394406
tree.stats.foreach(traverse)
395-
case tree: ValDef if tree.symbol.is(Module) => // skip module val
396-
case tree: NamedDefTree
397-
if !excludeDef(tree.symbol) && tree.span.hasLength =>
398-
registerDefinition(tree.symbol, tree.nameSpan, symbolKinds(tree))
399-
val privateWithin = tree.symbol.privateWithin
400-
if privateWithin.exists
401-
registerUse(privateWithin, spanOfSymbol(privateWithin, tree.span))
407+
case tree: NamedDefTree =>
408+
if tree.symbol.isAllOf(ModuleValCreationFlags)
409+
return
410+
if !excludeDef(tree.symbol) && tree.span.hasLength
411+
registerDefinition(tree.symbol, tree.nameSpan, symbolKinds(tree))
412+
val privateWithin = tree.symbol.privateWithin
413+
if privateWithin.exists
414+
registerUse(privateWithin, spanOfSymbol(privateWithin, tree.span))
415+
else if !excludeSymbolStrict(tree.symbol)
416+
registerSymbol(tree.symbol, symbolName(tree.symbol), symbolKinds(tree))
402417
tree match
403418
case tree: ValDef if tree.symbol.isAllOf(EnumValue) =>
404419
tree.rhs match
@@ -411,8 +426,9 @@ class ExtractSemanticDB extends Phase with
411426
case tree: DefDef if tree.symbol.isConstructor => // ignore typeparams for secondary ctors
412427
tree.vparamss.foreach(_.foreach(traverse))
413428
traverse(tree.rhs)
414-
case _ => traverseChildren(tree)
415-
case tree: (ValDef|DefDef|TypeDef) if tree.symbol.is(Synthetic, butNot=Module) && !tree.symbol.isAnonymous => // skip
429+
case tree =>
430+
if !excludeChildren(tree.symbol)
431+
traverseChildren(tree)
416432
case tree: Template =>
417433
val ctorSym = tree.constr.symbol
418434
if !excludeDef(ctorSym)

tests/semanticdb/expect/ForComprehension.expect.scala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@ class ForComprehension/*<-example::ForComprehension#*/ {
88
c/*<-local2*//*->local2*/ = a/*->local0*/ +/*->scala::Int#`+`(+4).*/ b/*->local1*//*->scala::collection::immutable::List#map().*/
99
} yield (a/*->local0*/, b/*->local1*/, c/*->local2*/)
1010
for {
11-
a/*<-local3*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(1)/*->scala::collection::immutable::List#flatMap().*/
12-
b/*<-local4*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(a/*->local3*/)/*->scala::collection::IterableOps#withFilter().*/
11+
a/*<-local4*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(1)/*->scala::collection::immutable::List#flatMap().*/
12+
b/*<-local5*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(a/*->local4*/)/*->scala::collection::IterableOps#withFilter().*/
1313
if (
14-
a/*->local3*/,
15-
b/*->local4*/
14+
a/*->local4*/,
15+
b/*->local5*/
1616
) ==/*->scala::Any#`==`().*/ (1, 2)/*->scala::collection::WithFilter#flatMap().*/
1717
(
18-
/*<-local7*/ c/*<-local5*/,
19-
d/*<-local6*/
20-
) <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/((a/*->local3*/, b/*->local4*/))/*->scala::collection::WithFilter#withFilter().*//*->scala::collection::IterableOps#withFilter().*/
18+
c/*<-local7*/,
19+
d/*<-local8*/
20+
) <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/((a/*->local4*/, b/*->local5*/))/*->scala::collection::WithFilter#withFilter().*//*->scala::collection::IterableOps#withFilter().*/
2121
if (
22-
a/*->local3*/,
23-
b/*->local4*/,
24-
c/*->local5*/,
25-
d/*->local6*/
22+
a/*->local4*/,
23+
b/*->local5*/,
24+
c/*->local7*/,
25+
d/*->local8*/
2626
) ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)/*->scala::collection::WithFilter#map().*/
27-
e/*<-local8*//*->local7*//*->local8*/ = (
28-
a/*->local3*/,
29-
b/*->local4*/,
30-
c/*->local5*/,
31-
d/*->local6*/
27+
e/*<-local9*//*->local9*/ = (
28+
a/*->local4*/,
29+
b/*->local5*/,
30+
c/*->local7*/,
31+
d/*->local8*/
3232
)/*->scala::collection::IterableOps#withFilter().*/
33-
if e/*->local8*/ ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)/*->scala::collection::WithFilter#flatMap().*/
34-
f/*<-local9*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(e/*->local8*/)/*->scala::collection::immutable::List#map().*/
33+
if e/*->local9*/ ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)/*->scala::collection::WithFilter#flatMap().*/
34+
f/*<-local10*/ <- List/*->scala::package.List.*//*->scala::collection::IterableFactory#apply().*/(e/*->local9*/)/*->scala::collection::immutable::List#map().*/
3535
} yield {
3636
(
37-
a/*->local3*/,
38-
b/*->local4*/,
39-
c/*->local5*/,
40-
d/*->local6*/,
41-
e/*->local8*/,
42-
f/*->local9*/
37+
a/*->local4*/,
38+
b/*->local5*/,
39+
c/*->local7*/,
40+
d/*->local8*/,
41+
e/*->local9*/,
42+
f/*->local10*/
4343
)
4444
}
4545
}

tests/semanticdb/expect/Methods.expect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Methods/*<-example::Methods#*/[T/*<-example::Methods#[T]*/] {
1515
def m6/*<-example::Methods#m6().*/(x/*<-example::Methods#m6().(x)*/: Int/*->scala::Int#*/) = ???/*->scala::Predef.`???`().*/
1616
def m6/*<-example::Methods#m6(+1).*/(x/*<-example::Methods#m6(+1).(x)*/: List/*->example::Methods#List#*/[T/*->example::Methods#[T]*/]) = ???/*->scala::Predef.`???`().*/
1717
def m6/*<-example::Methods#m6(+2).*/(x/*<-example::Methods#m6(+2).(x)*/: scala.List/*->scala::package.List#*/[T/*->example::Methods#[T]*/]) = ???/*->scala::Predef.`???`().*/
18-
def m7/*<-example::Methods#m7().*/[U/*<-example::Methods#m7().[U]*//*<-example::Methods#m7().(evidence$1)*/: Ordering/*->scala::math::Ordering#*//*->example::Methods#m7().[U]*/](c/*<-example::Methods#m7().(c)*/: Methods/*->example::Methods#*/[T/*->example::Methods#[T]*/], l/*<-example::Methods#m7().(l)*/: List/*->example::Methods#List#*/[U/*->example::Methods#m7().[U]*/]) = ???/*->scala::Predef.`???`().*/
18+
def m7/*<-example::Methods#m7().*/[U/*<-example::Methods#m7().[U]*/: Ordering/*->scala::math::Ordering#*//*->example::Methods#m7().[U]*/](c/*<-example::Methods#m7().(c)*/: Methods/*->example::Methods#*/[T/*->example::Methods#[T]*/], l/*<-example::Methods#m7().(l)*/: List/*->example::Methods#List#*/[U/*->example::Methods#m7().[U]*/]) = ???/*->scala::Predef.`???`().*/
1919
def `m8().`() =/*<-example::Methods#`m8().`().*/ ???/*->scala::Predef.`???`().*/
2020
class `m9().`
2121
d/*<-example::Methods#`m9().`#*/ef m9/*<-example::Methods#m9().*/(x/*<-example::Methods#m9().(x)*/: `m9().`/*->example::Methods#`m9().`#*/) = ???/*->scala::Predef.`???`().*/

tests/semanticdb/expect/Synthetic.expect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Synthetic/*<-example::Synthetic#*/ {
2828
null.asInstanceOf/*->scala::Any#asInstanceOf().*/[Int/*->scala::Int#*/ => Int/*->scala::Int#*/]/*->scala::Function1#apply().*/(2)
2929
}
3030

31-
class J/*<-example::Synthetic#J#*/[T/*<-example::Synthetic#J#[T]*//*<-example::Synthetic#J#evidence$2.*/: Manifest/*->scala::Predef.Manifest#*//*->example::Synthetic#J#[T]*/] { val arr/*<-example::Synthetic#J#arr.*/ = Array/*->scala::Array.*/.empty/*->scala::Array.empty().*/[T/*->example::Synthetic#J#[T]*/]/*->example::Synthetic#J#evidence$2.*/ }
31+
class J/*<-example::Synthetic#J#*/[T/*<-example::Synthetic#J#[T]*/: Manifest/*->scala::Predef.Manifest#*//*->example::Synthetic#J#[T]*/] { val arr/*<-example::Synthetic#J#arr.*/ = Array/*->scala::Array.*/.empty/*->scala::Array.empty().*/[T/*->example::Synthetic#J#[T]*/] }
3232

3333
class F/*<-example::Synthetic#F#*/
3434
implicit val ordering/*<-example::Synthetic#ordering.*/: Ordering/*->scala::package.Ordering#*/[F/*->example::Synthetic#F#*/] = ???/*->scala::Predef.`???`().*/

0 commit comments

Comments
 (0)