@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
1212import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
1313import org.jetbrains.kotlin.name.FqName
1414import org.scip_code.scip.Document
15- import org.scip_code.scip.SymbolRole
1615
1716/* *
1817 * Per-file accumulator of SCIP occurrences and symbols. The FIR checkers in
@@ -39,12 +38,12 @@ class SemanticdbVisitor(
3938
4039 private fun Sequence<SymbolDescriptorPair>?.emitAll (
4140 element : KtSourceElement ,
42- role : Int ,
41+ isDefinition : Boolean ,
4342 context : CheckerContext ,
4443 enclosingSource : KtSourceElement ? = null,
4544 ): List <Symbol >? =
4645 this ?.onEach { (firBasedSymbol, symbol) ->
47- documentBuilder.emitSemanticdbData(firBasedSymbol, symbol, element, role , context, enclosingSource)
46+ documentBuilder.emitSemanticdbData(firBasedSymbol, symbol, element, isDefinition , context, enclosingSource)
4847 }
4948 ?.map { it.symbol }
5049 ?.toList()
@@ -53,55 +52,55 @@ class SemanticdbVisitor(
5352 this .map { SymbolDescriptorPair (firBasedSymbol, it) }
5453
5554 fun visitPackage (pkg : FqName , element : KtSourceElement , context : CheckerContext ) {
56- cache[pkg].with (null ).emitAll(element, SymbolRole . UnspecifiedSymbolRole_VALUE , context)
55+ cache[pkg].with (null ).emitAll(element, isDefinition = false , context)
5756 }
5857
5958 fun visitClassReference (firClassSymbol : FirClassLikeSymbol <* >, element : KtSourceElement , context : CheckerContext ) {
60- cache[firClassSymbol].with (firClassSymbol).emitAll(element, SymbolRole . UnspecifiedSymbolRole_VALUE , context)
59+ cache[firClassSymbol].with (firClassSymbol).emitAll(element, isDefinition = false , context)
6160 }
6261
6362 fun visitCallableReference (firClassSymbol : FirCallableSymbol <* >, element : KtSourceElement , context : CheckerContext ) {
64- cache[firClassSymbol].with (firClassSymbol).emitAll(element, SymbolRole . UnspecifiedSymbolRole_VALUE , context)
63+ cache[firClassSymbol].with (firClassSymbol).emitAll(element, isDefinition = false , context)
6564 }
6665
6766 fun visitClassOrObject (firClass : FirClassLikeDeclaration , element : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
68- cache[firClass.symbol].with (firClass.symbol).emitAll(element, SymbolRole . Definition_VALUE , context, enclosingSource)
67+ cache[firClass.symbol].with (firClass.symbol).emitAll(element, isDefinition = true , context, enclosingSource)
6968 }
7069
7170 fun visitPrimaryConstructor (firConstructor : FirConstructor , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
72- cache[firConstructor.symbol].with (firConstructor.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
71+ cache[firConstructor.symbol].with (firConstructor.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
7372 }
7473
7574 fun visitSecondaryConstructor (firConstructor : FirConstructor , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
76- cache[firConstructor.symbol].with (firConstructor.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
75+ cache[firConstructor.symbol].with (firConstructor.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
7776 }
7877
7978 fun visitNamedFunction (firFunction : FirFunction , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
80- cache[firFunction.symbol].with (firFunction.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
79+ cache[firFunction.symbol].with (firFunction.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
8180 }
8281
8382 fun visitProperty (firProperty : FirProperty , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
84- cache[firProperty.symbol].with (firProperty.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
83+ cache[firProperty.symbol].with (firProperty.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
8584 }
8685
8786 fun visitParameter (firParameter : FirValueParameter , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
88- cache[firParameter.symbol].with (firParameter.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
87+ cache[firParameter.symbol].with (firParameter.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
8988 }
9089
9190 fun visitTypeParameter (firTypeParameter : FirTypeParameter , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
9291 cache[firTypeParameter.symbol]
9392 .with (firTypeParameter.symbol)
94- .emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
93+ .emitAll(source, isDefinition = true , context, enclosingSource)
9594 }
9695
9796 fun visitTypeAlias (firTypeAlias : FirTypeAlias , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
98- cache[firTypeAlias.symbol].with (firTypeAlias.symbol).emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
97+ cache[firTypeAlias.symbol].with (firTypeAlias.symbol).emitAll(source, isDefinition = true , context, enclosingSource)
9998 }
10099
101100 fun visitPropertyAccessor (firPropertyAccessor : FirPropertyAccessor , source : KtSourceElement , context : CheckerContext , enclosingSource : KtSourceElement ? = null) {
102101 cache[firPropertyAccessor.symbol]
103102 .with (firPropertyAccessor.symbol)
104- .emitAll(source, SymbolRole . Definition_VALUE , context, enclosingSource)
103+ .emitAll(source, isDefinition = true , context, enclosingSource)
105104 }
106105
107106 fun visitSimpleNameExpression (
@@ -110,6 +109,6 @@ class SemanticdbVisitor(
110109 ) {
111110 cache[firResolvedNamedReference.resolvedSymbol]
112111 .with (firResolvedNamedReference.resolvedSymbol)
113- .emitAll(source, SymbolRole . UnspecifiedSymbolRole_VALUE , context)
112+ .emitAll(source, isDefinition = false , context)
114113 }
115114}
0 commit comments