Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class ClientCoordinator(val server: ViperServerService)(implicit executor: Verif
.exists(fm => fm.startVerification(backendClassName, customArgs, manuallyTriggered))
}

def getDocumentation(uri: String): Option[String] = {
_files.get(uri).getDocumentation()
}

/** flushes verification cache, optionally only for a particular file */
def flushCache(uriOpt: Option[String], backendOpt: Option[String]): Future[Unit] = {
(uriOpt, backendOpt) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object C2S_Commands {
final val GetViperFileEndings = "GetViperFileEndings"
final val FlushCache = "FlushCache"
final val GetIdentifier = "GetIdentifier"
final val GetDocumentation = "GetDocumentation"
}

object S2C_Commands {
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/viper/server/frontends/lsp/DataProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ case class GetIdentifierResponse(identifier: String)

case class VerificationNotStartedParams(uri: String)

case class GetDocumentationRequest(uri: String)

case class GetDocumentationResponse(documentation: String)

////////////////////////////////////////////////////////////////////////////////////////////////////
////// SETTINGS ///////
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/viper/server/frontends/lsp/FileManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import viper.silver.ast
import viper.silver.ast.{AbstractSourcePosition, Domain, Field, Function, HasLineColumn, Method, Predicate, SourcePosition}
import viper.silver.reporter._
import viper.silver.verifier.{AbortedExceptionally, AbstractError, ErrorMessage}
import viper.server.utility.DocProvider

import scala.jdk.CollectionConverters._
import scala.collection.mutable.ArrayBuffer
Expand Down Expand Up @@ -125,6 +126,11 @@ class FileManager(coordinator: ClientCoordinator, file_uri: String)(implicit exe
}
}

def getDocumentation(): Option[String] = {
val docProvider = new DocProvider(coordinator.logger)
docProvider.generateViperdocData(uri.getPath())
}

object RelayActor {
def props(task: FileManager, backendClassName: String): Props = Props(new RelayActor(task, backendClassName))

Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/viper/server/frontends/lsp/Receiver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ class CustomReceiver(config: ViperConfig, server: ViperServerService, serverUrl:
}
}

@JsonRequest(C2S_Commands.GetDocumentation)
def onGetDocumentation(request: GetDocumentationRequest): CompletionStage[GetDocumentationResponse] = {
coordinator.logger.debug("On getting documentation")
val uri = request.uri
val data = coordinator.getDocumentation(uri).getOrElse("")
CompletableFuture.completedFuture(GetDocumentationResponse(data))
}

override def connect(client: LanguageClient): Unit = {
val c = client.asInstanceOf[IdeLanguageClient]
coordinator.setClient(c)
Expand Down