@@ -41,67 +41,82 @@ object Scala3:
4141 case class TypeParamRefSymbol (owner : Symbol , name : Name , tp : TypeBounds ) extends FakeSymbol
4242 case class RefinementSymbol (owner : Symbol , name : Name , tp : Type ) extends FakeSymbol
4343 type SemanticSymbol = Symbol | FakeSymbol
44- extension (sym : SemanticSymbol )
45- def name (using Context ): Name = sym match
46- case s : Symbol => s.name
47- case s : WildcardTypeSymbol => nme.WILDCARD
48- case s : TermParamRefSymbol => s.name
49- case s : TypeParamRefSymbol => s.name
50- case s : RefinementSymbol => s.name
51-
52- def symbolName (using builder : SemanticSymbolBuilder )(using Context ): String =
53- sym match
54- case s : Symbol => SymbolOps .symbolName(s)
55- case s : FakeSymbol =>
56- s.sname.getOrElse {
57- val sname = builder.symbolName(s)
58- s.sname = Some (sname)
59- sname
60- }
61-
62- def symbolInfo (symkinds : Set [SymbolKind ])(using LinkMode , TypeOps , SemanticSymbolBuilder , Context ): SymbolInformation =
63- sym match
64- case s : Symbol => SymbolOps .symbolInfo(s)(symkinds)
65- case s : WildcardTypeSymbol =>
66- SymbolInformation (
67- symbol = symbolName,
68- language = Language .SCALA ,
69- kind = SymbolInformation .Kind .TYPE ,
70- displayName = nme.WILDCARD .show,
71- signature = s.bounds.toSemanticSig(s.owner),
72- )
73- case s : TermParamRefSymbol =>
74- SymbolInformation (
75- symbol = symbolName,
76- language = Language .SCALA ,
77- kind = SymbolInformation .Kind .PARAMETER ,
78- displayName = s.name.show.unescapeUnicode,
79- signature = s.tp.toSemanticSig(s.owner),
80- )
81- case s : TypeParamRefSymbol =>
82- SymbolInformation (
83- symbol = symbolName,
84- language = Language .SCALA ,
85- kind = SymbolInformation .Kind .TYPE_PARAMETER ,
86- displayName = s.name.show.unescapeUnicode,
87- signature = s.tp.toSemanticSig(s.owner),
88- )
89- case s : RefinementSymbol =>
90- val signature = s.tp.toSemanticSig(s.owner)
91- val kind = signature match
92- case _ : TypeSignature => SymbolInformation .Kind .TYPE
93- case _ : MethodSignature => SymbolInformation .Kind .METHOD
94- case _ : ValueSignature => SymbolInformation .Kind .FIELD
95- case _ => SymbolInformation .Kind .UNKNOWN_KIND
96- SymbolInformation (
97- symbol = symbolName,
98- language = Language .SCALA ,
99- kind = kind,
100- displayName = s.name.show.unescapeUnicode,
101- properties =
102- SymbolInformation .Property .ABSTRACT .value,
103- signature = signature,
104- )
44+
45+ given SemanticSymbolOps : AnyRef with
46+ extension (sym : SemanticSymbol )
47+ def name (using Context ): Name = sym match
48+ case s : Symbol => s.name
49+ case s : WildcardTypeSymbol => nme.WILDCARD
50+ case s : TermParamRefSymbol => s.name
51+ case s : TypeParamRefSymbol => s.name
52+ case s : RefinementSymbol => s.name
53+
54+ def symbolName (using builder : SemanticSymbolBuilder )(using Context ): String =
55+ sym match
56+ case s : Symbol => builder.symbolName(s)
57+ case s : FakeSymbol =>
58+ s.sname.getOrElse {
59+ val sname = builder.symbolName(s)
60+ s.sname = Some (sname)
61+ sname
62+ }
63+
64+ def symbolInfo (symkinds : Set [SymbolKind ])(using LinkMode , TypeOps , SemanticSymbolBuilder , Context ): SymbolInformation =
65+ sym match
66+ case s : Symbol =>
67+ val kind = s.symbolKind(symkinds)
68+ val sname = sym.symbolName
69+ val signature = s.info.toSemanticSig(s)
70+ SymbolInformation (
71+ symbol = sname,
72+ language = Language .SCALA ,
73+ kind = kind,
74+ properties = s.symbolProps(symkinds),
75+ displayName = Symbols .displaySymbol(s),
76+ signature = signature,
77+ access = s.symbolAccess(kind),
78+ )
79+ case s : WildcardTypeSymbol =>
80+ SymbolInformation (
81+ symbol = symbolName,
82+ language = Language .SCALA ,
83+ kind = SymbolInformation .Kind .TYPE ,
84+ displayName = nme.WILDCARD .show,
85+ signature = s.bounds.toSemanticSig(s.owner),
86+ )
87+ case s : TermParamRefSymbol =>
88+ SymbolInformation (
89+ symbol = symbolName,
90+ language = Language .SCALA ,
91+ kind = SymbolInformation .Kind .PARAMETER ,
92+ displayName = s.name.show.unescapeUnicode,
93+ signature = s.tp.toSemanticSig(s.owner),
94+ )
95+ case s : TypeParamRefSymbol =>
96+ SymbolInformation (
97+ symbol = symbolName,
98+ language = Language .SCALA ,
99+ kind = SymbolInformation .Kind .TYPE_PARAMETER ,
100+ displayName = s.name.show.unescapeUnicode,
101+ signature = s.tp.toSemanticSig(s.owner),
102+ )
103+ case s : RefinementSymbol =>
104+ val signature = s.tp.toSemanticSig(s.owner)
105+ val kind = signature match
106+ case _ : TypeSignature => SymbolInformation .Kind .TYPE
107+ case _ : MethodSignature => SymbolInformation .Kind .METHOD
108+ case _ : ValueSignature => SymbolInformation .Kind .FIELD
109+ case _ => SymbolInformation .Kind .UNKNOWN_KIND
110+ SymbolInformation (
111+ symbol = symbolName,
112+ language = Language .SCALA ,
113+ kind = kind,
114+ displayName = s.name.show.unescapeUnicode,
115+ properties =
116+ SymbolInformation .Property .ABSTRACT .value,
117+ signature = signature,
118+ )
119+ end SemanticSymbolOps
105120
106121 enum SymbolKind derives CanEqual :
107122 kind =>
@@ -205,28 +220,14 @@ object Scala3:
205220 def isSyntheticWithIdent (using Context ): Boolean =
206221 sym.is(Synthetic ) && ! sym.isAnonymous && ! sym.name.isEmptyNumbered
207222
208- def symbolInfo (symkinds : Set [SymbolKind ])(using LinkMode , TypeOps , SemanticSymbolBuilder , Context ): SymbolInformation =
209- val sname = sym.symbolName
210- val signature = sym.info.toSemanticSig(sym)
211- val kind = symbolKind(symkinds)
212- SymbolInformation (
213- symbol = sname,
214- language = Language .SCALA ,
215- kind = kind,
216- properties = sym.symbolProps(symkinds),
217- displayName = Symbols .displaySymbol(sym),
218- signature = signature,
219- access = symbolAccess(kind),
220- )
221-
222223 /** The semanticdb name of the given symbol */
223224 def symbolName (using builder : SemanticSymbolBuilder )(using Context ): String =
224225 builder.symbolName(sym)
225226
226227 def funParamSymbol (using builder : SemanticSymbolBuilder )(using Context ): Name => String =
227228 builder.funParamSymbol(sym)
228229
229- private def symbolKind (symkinds : Set [SymbolKind ])(using Context ): SymbolInformation .Kind =
230+ def symbolKind (symkinds : Set [SymbolKind ])(using Context ): SymbolInformation .Kind =
230231 if sym.isTypeParam then
231232 SymbolInformation .Kind .TYPE_PARAMETER
232233 else if sym.is(TermParam ) then
@@ -260,7 +261,7 @@ object Scala3:
260261 else
261262 SymbolInformation .Kind .UNKNOWN_KIND
262263
263- private def symbolProps (symkinds : Set [SymbolKind ])(using Context ): Int =
264+ def symbolProps (symkinds : Set [SymbolKind ])(using Context ): Int =
264265 if sym.is(ModuleClass ) then
265266 return sym.sourceModule.symbolProps(symkinds)
266267 var props = 0
@@ -308,7 +309,7 @@ object Scala3:
308309 props |= SymbolInformation .Property .OPAQUE .value
309310 props
310311
311- private def symbolAccess (kind : SymbolInformation .Kind )(using Context , SemanticSymbolBuilder ): Access =
312+ def symbolAccess (kind : SymbolInformation .Kind )(using Context , SemanticSymbolBuilder ): Access =
312313 kind match
313314 case k.LOCAL | k.PARAMETER | k.SELF_PARAMETER | k.TYPE_PARAMETER | k.PACKAGE | k.PACKAGE_OBJECT =>
314315 Access .Empty
0 commit comments