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

Commit 8512ef6

Browse files
authored
Merge pull request #65 from fede0664/master
Updated to Ensime 2.0.0. Using TypeAtPointReq for hover request
2 parents ceba58e + 01c6e22 commit 8512ef6

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ out/
1111
*.log
1212
scala/server/ensimeServer-assembly*
1313
coursier
14-
.hydra
14+
.ensime
15+
.hydra

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ lazy val `ensime-lsp` = project.
6262
settings(
6363
resolvers += Resolver.sonatypeRepo("snapshots"),
6464
libraryDependencies ++= Seq(
65-
"org.ensime" %% "core" % "2.0.0-M4"
65+
"org.ensime" %% "core" % "2.0.0"
6666
),
6767
pomExtra in Global := {
6868
<url>https://github.com/dragos/dragos-vscode-scala/</url>

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -262,34 +262,37 @@ class EnsimeLanguageServer(in: InputStream, out: OutputStream) extends LanguageS
262262
import scala.concurrent.ExecutionContext.Implicits._
263263
logger.info(s"Got hover request at (${position.line}, ${position.character}).")
264264

265-
// val res = for (doc <- documentManager.documentForUri(textDocument.uri)) yield {
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-
271-
// future.onComplete { f => logger.debug(s"Goto Definition future completed: succes? ${f.isSuccess}") }
272-
273-
// future.map {
274-
// case typeInfo: TypeInfo =>
275-
// logger.info(s"Retrieved typeInfo $typeInfo")
276-
// Hover(Seq(RawMarkedString("scala", typeInfo.toString)), Some(Range(position, position)))
277-
// }
278-
// }
279265
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}") }
266+
val pos = doc.positionToOffset(position)
285267

286-
future.map {
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 {
287273
case Some(sigPair @ DocSigPair(DocSig(_, scalaSig), DocSig(_, javaSig))) =>
288274
val sig = scalaSig.orElse(javaSig).getOrElse("")
289275
logger.info(s"Retrieved signature $sig from @sigPair")
290-
Hover(Seq(RawMarkedString("scala", sig)), Some(Range(position, position)))
276+
Some(sig).filter(_ != "")
277+
}
278+
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 {
284+
case typeInfo: TypeInfo =>
285+
logger.info(s"Retrieved typeInfo $typeInfo")
286+
// Some(typeInfo.name)
287+
Some(typeInfo.fullName)
288+
}
289+
290+
for{fdStrOpt <- futureDocStrOpt; ftStrOpt <- futureTypeStrOpt} yield {
291+
val sig = fdStrOpt.orElse(ftStrOpt).getOrElse("")
292+
Hover(Seq(RawMarkedString("scala", sig)), Some(Range(position, position)))
291293
}
292294
}
295+
293296
res.map { f => Await.result(f, 5 seconds) } getOrElse Hover(Nil, None)
294297
}
295298

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("org.ensime" % "sbt-ensime" % "1.12.0")
1+
addSbtPlugin("org.ensime" % "sbt-ensime" % "2.0.1")
22

33
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
44

0 commit comments

Comments
 (0)