Skip to content

Commit 4fc0ce9

Browse files
committed
fix lsif snapshot diff with extra cheese
1 parent b284432 commit 4fc0ce9

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lsif-java/src/main/scala/com/sourcegraph/lsif_java/SemanticdbPrinters.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ object SemanticdbPrinters {
8787
.append(
8888
symbols.get(occ.getSymbol) match {
8989
case Some(info) if occ.getRole == Role.DEFINITION =>
90-
" " + new SignatureFormatter(info, symtab).formatSymbol() + ""
90+
val sig = new SignatureFormatter(info, symtab).formatSymbol()
91+
if (sig == "")
92+
" " + info.getDisplayName
93+
else
94+
" " + sig + ""
9195
case _ =>
9296
""
9397
}

lsif-java/src/main/scala/com/sourcegraph/lsif_java/commands/SnapshotLsifCommand.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.sourcegraph.lsif_protocol.LsifObject
2828
import com.sourcegraph.lsif_protocol.LsifPosition
2929
import com.sourcegraph.semanticdb_javac.Semanticdb
3030
import com.sourcegraph.semanticdb_javac.Semanticdb.Language
31+
import com.sourcegraph.semanticdb_javac.Semanticdb.SymbolInformation
3132
import com.sourcegraph.semanticdb_javac.Semanticdb.SymbolOccurrence
3233
import com.sourcegraph.semanticdb_javac.Semanticdb.SymbolOccurrence.Role
3334
import com.sourcegraph.semanticdb_javac.Semanticdb.TextDocument
@@ -119,6 +120,29 @@ object SnapshotLsifCommand {
119120
.setSymbol(symbol)
120121
.build()
121122
doc.addOccurrences(occ)
123+
124+
if (isDefinition) {
125+
val hover =
126+
(
127+
for {
128+
resultSetId <- lsif.next.get(o.getId)
129+
hoverId <- lsif.hoverEdges.get(resultSetId)
130+
hover <- lsif.hoverVertexes.get(hoverId)
131+
} yield hover
132+
).get.getContentsList.asScala.map { h =>
133+
println(h.getLanguage)
134+
h
135+
}.find { h => h.getLanguage != Language.UNKNOWN_LANGUAGE.toString.toLowerCase }.get.getValue
136+
val symInfo = SymbolInformation
137+
.newBuilder()
138+
// we cheese it a bit here, as this is less work than trying to reconstruct
139+
// a Signature from the pretty-printed Signature, with accompanying logic
140+
// to fallback to display_name in SemanticdbPrinters.scala
141+
.setDisplayName(hover)
142+
.setSymbol(symbol)
143+
.build()
144+
doc.addSymbols(symInfo)
145+
}
122146
}
123147
lsif.documents.values.map(_.build()).toList
124148
}

semanticdb-java/src/main/protobuf/semanticdb.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,16 @@ message Type {
160160
reserved 1, 3, 4, 5, 6, 11, 12, 15, 16;
161161
oneof sealed_value {
162162
TypeRef type_ref = 2;
163-
IntersectionType intersection_type = 17;
164163
ExistentialType existential_type = 9;
164+
IntersectionType intersection_type = 17;
165165
}
166166
}
167167

168168
message TypeRef {
169169
string symbol = 2;
170170
repeated Type type_arguments = 3;
171171
}
172+
172173
message IntersectionType {
173174
repeated Type types = 1;
174175
}

0 commit comments

Comments
 (0)