@@ -13,7 +13,6 @@ import scala.collection.mutable
1313import scala .collection .mutable .ArrayBuffer
1414import scala .collection .mutable .ListBuffer
1515import scala .jdk .CollectionConverters ._
16-
1716import com .google .common .graph .EndpointPair
1817import com .google .common .graph .Graph
1918import com .google .common .graph .GraphBuilder
@@ -27,10 +26,8 @@ import com.sourcegraph.lsif_protocol.LsifHover
2726import com .sourcegraph .lsif_protocol .LsifObject
2827import com .sourcegraph .lsif_protocol .LsifPosition
2928import com .sourcegraph .semanticdb_javac .Semanticdb
30- import com .sourcegraph .semanticdb_javac .Semanticdb .Language
31- import com .sourcegraph .semanticdb_javac .Semanticdb .SymbolOccurrence
29+ import com .sourcegraph .semanticdb_javac .Semanticdb .{Language , SymbolInformation , SymbolOccurrence , TextDocument }
3230import com .sourcegraph .semanticdb_javac .Semanticdb .SymbolOccurrence .Role
33- import com .sourcegraph .semanticdb_javac .Semanticdb .TextDocument
3431import moped .annotations .CommandName
3532import moped .annotations .Inline
3633import moped .annotations .PositionalArguments
@@ -119,6 +116,29 @@ object SnapshotLsifCommand {
119116 .setSymbol(symbol)
120117 .build()
121118 doc.addOccurrences(occ)
119+
120+ if (isDefinition) {
121+ val hover =
122+ (
123+ for {
124+ resultSetId <- lsif.next.get(o.getId)
125+ hoverId <- lsif.hoverEdges.get(resultSetId)
126+ hover <- lsif.hoverVertexes.get(hoverId)
127+ } yield hover
128+ ).get.getContentsList.asScala.map { h =>
129+ println(h.getLanguage)
130+ h
131+ }.find { h => h.getLanguage != Language .UNKNOWN_LANGUAGE .toString.toLowerCase }.get.getValue
132+ val symInfo = SymbolInformation
133+ .newBuilder()
134+ // we cheese it a bit here, as this is less work than trying to reconstruct
135+ // a Signature from the pretty-printed Signature, with accompanying logic
136+ // to fallback to display_name in SemanticdbPrinters.scala
137+ .setDisplayName(hover)
138+ .setSymbol(symbol)
139+ .build()
140+ doc.addSymbols(symInfo)
141+ }
122142 }
123143 lsif.documents.values.map(_.build()).toList
124144 }
0 commit comments