Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 2fcb20e

Browse files
author
fc
committed
Hover improvement
1 parent db1814c commit 2fcb20e

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ out/
1111
*.log
1212
scala/server/ensimeServer-assembly*
1313
coursier
14+
.ensime

ensime-lsp/src/main/scala/org/github/dragos/vscode/EnsimeLanguageServer.scala

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,32 +264,35 @@ class EnsimeLanguageServer(in: InputStream, out: OutputStream) extends LanguageS
264264

265265
val res = for (doc <- documentManager.documentForUri(textDocument.uri)) yield {
266266
val pos = doc.positionToOffset(position)
267-
val future = ensimeActor ? TypeAtPointReq(
268-
Right(toSourceFileInfo(textDocument.uri, Some(new String(doc.contents)))),
269-
OffsetRange(pos, pos))
270267

271-
future.onComplete { f => logger.debug(s"Goto Definition future completed: succes? ${f.isSuccess}") }
268+
val futureDocUriAtPoint = ensimeActor ? DocUriAtPointReq(
269+
Right(toSourceFileInfo(textDocument.uri, Some(new String(doc.contents)))),
270+
OffsetRange(pos))
271+
futureDocUriAtPoint.onComplete { f => logger.debug(s"DocUriAtPointReq future completed: succes? ${f.isSuccess}") }
272+
val futureDocStrOpt = futureDocUriAtPoint.map {
273+
case Some(sigPair @ DocSigPair(DocSig(_, scalaSig), DocSig(_, javaSig))) =>
274+
val sig = scalaSig.orElse(javaSig).getOrElse("")
275+
logger.info(s"Retrieved signature $sig from @sigPair")
276+
Some(sig).filter(_ != "")
277+
}
272278

273-
future.map {
279+
val futureTypeAtPoint = ensimeActor ? TypeAtPointReq(
280+
Right(toSourceFileInfo(textDocument.uri, Some(new String(doc.contents)))),
281+
OffsetRange(pos, pos))
282+
futureTypeAtPoint.onComplete { f => logger.debug(s"TypeAtPointReq future completed: succes? ${f.isSuccess}") }
283+
val futureTypeStrOpt = futureTypeAtPoint.map {
274284
case typeInfo: TypeInfo =>
275285
logger.info(s"Retrieved typeInfo $typeInfo")
276-
Hover(Seq(RawMarkedString("scala", typeInfo.name +"\n"+ typeInfo.fullName)), Some(Range(position, position)))
286+
// Some(typeInfo.name)
287+
Some(typeInfo.fullName)
288+
}
289+
290+
for{ftp <- futureDocStrOpt; fdp <- futureTypeStrOpt} yield {
291+
val sig = ftp.orElse(fdp).getOrElse("")
292+
Hover(Seq(RawMarkedString("scala", sig)), Some(Range(position, position)))
277293
}
278294
}
279-
// val res = for (doc <- documentManager.documentForUri(textDocument.uri)) yield {
280-
// val future = ensimeActor ? DocUriAtPointReq(
281-
// Right(toSourceFileInfo(textDocument.uri, Some(new String(doc.contents)))),
282-
// OffsetRange(doc.positionToOffset(position)))
283-
284-
// future.onComplete { f => logger.debug(s"DocUriAtPointReq future completed: succes? ${f.isSuccess}") }
285-
286-
// future.map {
287-
// case Some(sigPair @ DocSigPair(DocSig(_, scalaSig), DocSig(_, javaSig))) =>
288-
// val sig = scalaSig.orElse(javaSig).getOrElse("")
289-
// logger.info(s"Retrieved signature $sig from @sigPair")
290-
// Hover(Seq(RawMarkedString("scala", sig)), Some(Range(position, position)))
291-
// }
292-
// }
295+
293296
res.map { f => Await.result(f, 5 seconds) } getOrElse Hover(Nil, None)
294297
}
295298

0 commit comments

Comments
 (0)