@@ -42,7 +42,7 @@ class ExtractSemanticDB extends Phase with
42
42
val unit = ctx.compilationUnit
43
43
val extract = Extractor ()
44
44
extract.traverse(unit.tpdTree)
45
- ExtractSemanticDB .write(unit.source, extract.occurrences.toList, extract.symbols .toList)
45
+ ExtractSemanticDB .write(unit.source, extract.occurrences.toList, extract.symbolInfos .toList)
46
46
47
47
/** Extractor of symbol occurrences from trees */
48
48
class Extractor extends TreeTraverser with
@@ -60,7 +60,10 @@ class ExtractSemanticDB extends Phase with
60
60
val occurrences = new mutable.ListBuffer [SymbolOccurrence ]()
61
61
62
62
/** The extracted symbol infos */
63
- val symbols = new mutable.HashSet [SymbolInformation ]()
63
+ val symbolInfos = new mutable.HashSet [SymbolInformation ]()
64
+
65
+ /** A cache of localN names */
66
+ val localNames = new mutable.HashSet [String ]()
64
67
65
68
/** The symbol occurrences generated so far, as a set */
66
69
private val generated = new mutable.HashSet [SymbolOccurrence ]
@@ -76,7 +79,7 @@ class ExtractSemanticDB extends Phase with
76
79
if isJavaIdent(str) then b append str
77
80
else b append '`' append str append '`'
78
81
79
- /** Is symbol global? Non-global symbols get localX names */
82
+ /** Is symbol global? Non-global symbols get localNå names */
80
83
def isGlobal (sym : Symbol ): Boolean =
81
84
sym.is(Package )
82
85
|| ! sym.isSelfSym && (sym.is(Param ) || sym.owner.isClass) && isGlobal(sym.owner)
@@ -265,7 +268,11 @@ class ExtractSemanticDB extends Phase with
265
268
)
266
269
267
270
private def registerSymbol (sym : Symbol , symbolName : String , symkinds : Set [SymbolKind ])(given Context ): Unit =
268
- symbols += symbolInfo(sym, symbolName, symkinds)
271
+ val isLocal = symbolName.isLocal
272
+ if ! isLocal || ! localNames.contains(symbolName)
273
+ if isLocal
274
+ localNames += symbolName
275
+ symbolInfos += symbolInfo(sym, symbolName, symkinds)
269
276
270
277
private def registerOccurrence (symbol : String , span : Span , role : SymbolOccurrence .Role )(given Context ): Unit =
271
278
val occ = SymbolOccurrence (symbol, range(span), role)
@@ -351,7 +358,7 @@ class ExtractSemanticDB extends Phase with
351
358
val symkinds = mutable.HashSet .empty[SymbolKind ]
352
359
tree match
353
360
case tree : ValDef =>
354
- if ! tree.symbol.owner. is(Method )
361
+ if ! tree.symbol.is(Param )
355
362
symkinds += (if tree.mods is Mutable then SymbolKind .Var else SymbolKind .Val )
356
363
if tree.rhs.isEmpty && ! tree.symbol.isOneOf(TermParam | CaseAccessor | ParamAccessor )
357
364
symkinds += SymbolKind .Abstract
@@ -360,7 +367,8 @@ class ExtractSemanticDB extends Phase with
360
367
symkinds += SymbolKind .Setter
361
368
else if tree.rhs.isEmpty
362
369
symkinds += SymbolKind .Abstract
363
- case tree : Bind => symkinds += SymbolKind .Val
370
+ case tree : Bind =>
371
+ symkinds += SymbolKind .Val
364
372
case _ =>
365
373
symkinds.toSet
366
374
@@ -493,7 +501,7 @@ object ExtractSemanticDB with
493
501
494
502
val name : String = " extractSemanticDB"
495
503
496
- def write (source : SourceFile , occurrences : List [SymbolOccurrence ], symbols : List [SymbolInformation ])(given ctx : Context ): Unit =
504
+ def write (source : SourceFile , occurrences : List [SymbolOccurrence ], symbolInfos : List [SymbolInformation ])(given ctx : Context ): Unit =
497
505
def absolutePath (path : Path ): Path = path.toAbsolutePath.normalize
498
506
val sourcePath = absolutePath(source.file.jpath)
499
507
val sourceRoot = absolutePath(Paths .get(ctx.settings.sourceroot.value))
@@ -516,7 +524,7 @@ object ExtractSemanticDB with
516
524
uri = relPath.toString,
517
525
text = " " ,
518
526
md5 = internal.MD5 .compute(String (source.content)),
519
- symbols = symbols ,
527
+ symbols = symbolInfos ,
520
528
occurrences = occurrences
521
529
)
522
530
val docs = TextDocuments (List (doc))
0 commit comments