Skip to content

Commit

Permalink
Move toURI to kiama
Browse files Browse the repository at this point in the history
  • Loading branch information
b-studios committed Dec 21, 2024
1 parent b274a6b commit 02b1f02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
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

0 comments on commit 02b1f02

Please sign in to comment.