@@ -264,32 +264,35 @@ class EnsimeLanguageServer(in: InputStream, out: OutputStream) extends LanguageS
264
264
265
265
val res = for (doc <- documentManager.documentForUri(textDocument.uri)) yield {
266
266
val pos = doc.positionToOffset(position)
267
- val future = ensimeActor ? TypeAtPointReq (
268
- Right (toSourceFileInfo(textDocument.uri, Some (new String (doc.contents)))),
269
- OffsetRange (pos, pos))
270
267
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
+ }
272
278
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 {
274
284
case typeInfo : TypeInfo =>
275
285
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)))
277
293
}
278
294
}
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
+
293
296
res.map { f => Await .result(f, 5 seconds) } getOrElse Hover (Nil , None )
294
297
}
295
298
0 commit comments