@@ -72,6 +72,8 @@ class ExtractSemanticDB extends Phase:
72
72
/** The symbol occurrences generated so far, as a set */
73
73
private val generated = new mutable.HashSet [SymbolOccurrence ]
74
74
75
+ private val anotatedSymbols = new mutable.HashSet [Symbol ]
76
+
75
77
/** Definitions of this symbol should be excluded from semanticdb */
76
78
private def excludeDef (sym : Symbol )(using Context ): Boolean =
77
79
! sym.exists
@@ -104,13 +106,15 @@ class ExtractSemanticDB extends Phase:
104
106
|| sym == defn.Any_typeCast
105
107
|| qualifier.exists(excludeQual)
106
108
107
- private def traverseAnnotsOf (sym : Symbol )(using Context ): Unit =
108
- for annot <- sym.annotations do
109
- if annot.tree.span.exists
110
- && annot.tree.span.hasLength
111
- annot.tree match
112
- case tree : Typed => () // hack for inline code
113
- case tree => traverse(tree)
109
+ private def traverseAnnotsOfDefinition (sym : Symbol )(using Context ): Unit =
110
+ if (! anotatedSymbols.contains(sym)) then
111
+ anotatedSymbols += sym
112
+ for annot <- sym.annotations do
113
+ if annot.tree.span.exists
114
+ && annot.tree.span.hasLength
115
+ annot.tree match
116
+ case tree : Typed => () // hack for inline code
117
+ case tree => traverse(tree)
114
118
115
119
override def traverse (tree : Tree )(using Context ): Unit =
116
120
@@ -125,7 +129,11 @@ class ExtractSemanticDB extends Phase:
125
129
else
126
130
traverse(tpt)
127
131
128
- traverseAnnotsOf(tree.symbol)
132
+ tree match
133
+ case tree : DefTree if tree.symbol.exists =>
134
+ traverseAnnotsOfDefinition(tree.symbol)
135
+ case _ =>
136
+ ()
129
137
130
138
tree match
131
139
case tree : PackageDef =>
@@ -182,6 +190,7 @@ class ExtractSemanticDB extends Phase:
182
190
case tree : Template =>
183
191
val ctorSym = tree.constr.symbol
184
192
if ! excludeDef(ctorSym)
193
+ traverseAnnotsOfDefinition(ctorSym)
185
194
registerDefinition(ctorSym, tree.constr.span, Set .empty)
186
195
ctorParams(tree.constr.vparamss, tree.body)(traverseCtorParamTpt(ctorSym, _))
187
196
for parent <- tree.parentsOrDerived if parent.span.hasLength do
@@ -568,8 +577,8 @@ class ExtractSemanticDB extends Phase:
568
577
vparams <- vparamss
569
578
vparam <- vparams
570
579
do
571
- traverseAnnotsOf(vparam.symbol)
572
580
if ! excludeSymbol(vparam.symbol)
581
+ traverseAnnotsOfDefinition(vparam.symbol)
573
582
val symkinds =
574
583
getters.get(vparam.name).fold(SymbolKind .emptySet)(getter =>
575
584
if getter.mods.is(Mutable ) then SymbolKind .VarSet else SymbolKind .ValSet )
0 commit comments