-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server integration tests, support workspace directory (#128)
- Loading branch information
Showing
33 changed files
with
766 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
**/target | ||
.direnv/ | ||
.idea/ | ||
.vscode/ | ||
**/.DS_Store | ||
.smithy.lsp.log | ||
.sbt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Contributing | ||
|
||
Not much to be found here, but feel free to extend this document with anything useful. | ||
|
||
## Infrastructure | ||
|
||
There are two main infrastructure components: | ||
|
||
- the language client: a VS Code extension using the `vscode-languageclient` library to start and communicate with a language server (using Coursier to fetch and run the jars) | ||
- the langauge server: a Scala (JVM) application using the [`lsp4j`](https://github.com/eclipse/lsp4j) library to implement the LSP protocol. | ||
|
||
The communication happens over standard I/O. Stdout (your `println` inside the server) is redirected to the logfile,`smithyql-log.txt` inside the workspace. Note: it might not work, so I suggest you write to `System.err` or use Main's `logOut` directly. | ||
|
||
## Resources | ||
|
||
- [lsp4j documentation](https://github.com/eclipse/lsp4j/blob/main/documentation/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
modules/language-support/src/main/scala/playground/language/TextDocumentProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
modules/language-support/src/main/scala/playground/language/Uri.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package playground.language | ||
|
||
import fs2.io.file.Path | ||
|
||
import java.nio.file.Paths | ||
import java.net.URI | ||
|
||
final case class Uri private (value: String) extends AnyVal { | ||
def toPath: Path = Path.fromNioPath(Paths.get(new URI(value))) | ||
|
||
// :/ | ||
// only for tests! | ||
def /(subdir: String): Uri = Uri(value + "/" + subdir) | ||
} | ||
|
||
object Uri { | ||
def fromPath(path: Path): Uri = fromUriString(path.toNioPath.toUri().toString()) | ||
def fromUriString(s: String): Uri = new Uri(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
modules/lsp/src/main/scala/playground/lsp/ConfigurationValue.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package playground.lsp | ||
|
||
import io.circe.Codec | ||
import io.circe.Encoder | ||
import io.circe.Decoder | ||
import org.http4s.Uri | ||
import cats.implicits._ | ||
import io.circe.Json | ||
|
||
trait ConfigurationValue[T] { | ||
def key: String | ||
def codec: Codec[T] | ||
def apply(value: T): ConfigurationValue.Applied[T] = ConfigurationValue.Applied(this, value) | ||
} | ||
|
||
object ConfigurationValue { | ||
|
||
def make[A: Encoder: Decoder](k: String): ConfigurationValue[A] = | ||
new ConfigurationValue[A] { | ||
val key: String = k | ||
val codec: Codec[A] = Codec.from(implicitly, implicitly) | ||
} | ||
|
||
final case class Applied[T](cv: ConfigurationValue[T], value: T) { | ||
def encoded: Json = cv.codec.apply(value) | ||
} | ||
|
||
implicit val uriJsonDecoder: Decoder[Uri] = Decoder[String].emap( | ||
Uri.fromString(_).leftMap(_.message) | ||
) | ||
|
||
implicit val uriJsonEncoder: Encoder[Uri] = Encoder[String].contramap(_.renderString) | ||
|
||
val maxWidth: ConfigurationValue[Int] = make[Int]("smithyql.formatter.maxWidth") | ||
val baseUri: ConfigurationValue[Uri] = make[Uri]("smithyql.http.baseUrl") | ||
|
||
val authorizationHeader: ConfigurationValue[String] = make[String]( | ||
"smithyql.http.authorizationHeader" | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.