Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/kiama lsp #753

Merged
merged 6 commits into from
Dec 21, 2024
Merged
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
15 changes: 12 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ lazy val replDependencies = Seq(
)

lazy val lspDependencies = Seq(
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.12.0",
"com.google.code.gson" % "gson" % "2.8.9"
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.23.1"
)

lazy val testingDependencies = Seq(
Expand All @@ -63,7 +62,8 @@ lazy val kiama: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("ki
name := "kiama"
)
.jvmSettings(
libraryDependencies ++= (replDependencies ++ lspDependencies)
libraryDependencies ++= (replDependencies ++ lspDependencies ++ testingDependencies),
testFrameworks += new TestFramework("utest.runner.Framework")
)

lazy val root = project.in(file("effekt"))
Expand Down Expand Up @@ -116,6 +116,15 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e

assembly / assemblyJarName := "effekt.jar",

// there is a conflict between the two transitive dependencies "gson:2.11.0"
// and "error_prone_annotations:2.27.0", so we need the merge strategy here for `sbt install`
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "versions", "9", "module-info.class") => MergeStrategy.first
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
},

// we use the lib folder as resource directory to include it in the JAR
Compile / unmanagedResourceDirectories += (ThisBuild / baseDirectory).value / "libraries",

Expand Down
28 changes: 2 additions & 26 deletions effekt/jvm/src/main/scala/effekt/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import effekt.core.PrettyPrinter
import effekt.source.{ FunDef, Hole, ModuleDecl, Tree }
import effekt.util.{ PlainMessaging, getOrElseAborting }
import effekt.util.messages.EffektError

import kiama.util.{ Filenames, Position, Services, Source }
import kiama.util.{ Filenames, Notebook, NotebookCell, Position, Services, Source }
import kiama.output.PrettyPrinterTypes.Document

import org.eclipse.lsp4j.{ Diagnostic, DocumentSymbol, SymbolKind, ExecuteCommandParams }
import org.eclipse.lsp4j.{ Diagnostic, DocumentSymbol, ExecuteCommandParams, SymbolKind }

/**
* effekt.Intelligence <--- gathers information -- LSPServer --- provides LSP interface ---> kiama.Server
Expand Down Expand Up @@ -95,28 +93,6 @@ trait LSPServer extends kiama.util.Server[Tree, EffektConfig, EffektError] with
info <- getHoleInfo(tree)(context)
} yield info

// The implementation in kiama.Server does not support file sources
def toURI(filename: String): String = {
if (filename startsWith "file://")
filename
else
if (filename startsWith "./")
"file://" ++ Filenames.cwd() ++ "/" ++ Filenames.dropPrefix(filename, ".")
else
s"file://$filename"
}

override def locationOfNode(node: Tree): Location = {
(positions.getStart(node), positions.getFinish(node)) match {
case (start @ Some(st), finish @ Some(_)) =>
val s = convertPosition(start)
val f = convertPosition(finish)
new Location(toURI(st.source.name), new LSPRange(s, f))
case _ =>
null
}
}

def positionToLocation(p: Position): Location = {
val s = convertPosition(Some(p))
new Location(p.source.name, new LSPRange(s, s))
Expand Down
Loading