Skip to content

Commit 06329de

Browse files
feat: Add support for extends (#11)
* extends working * fix inputs * Add jsonPayload * refactor * update snapshot * use inline i/o (#12) * Use inline i/o shapes * Resolve todos --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com> * Apply review comments * Add tests from TopologicalSort * Add mixed type of cycle * Use ModelDiff for better assertions * Regenerate lsp.smithy --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com> Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
1 parent 41928cb commit 06329de

8 files changed

Lines changed: 2233 additions & 1203 deletions

File tree

build.sc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import smithytraitcodegen.SmithyTraitCodegenPlugin
1010

1111
import $meta._
1212

13-
val jsonrpcVersion = "0.0.8+39-109d210f-SNAPSHOT"
13+
val jsonrpcVersion = "0.0.8+41-0a28e99d-SNAPSHOT"
14+
val langoustineVersion = "0.0.24"
15+
val smithyVersion = "1.57.1"
1416

1517
trait CommonScalaModule extends ScalaModule with ScalafixModule {
1618
override def repositoriesTask: Task[Seq[Repository]] = T.task {
@@ -54,9 +56,10 @@ object lspSmithy extends CommonScalaModule with SmithyTraitCodegenPlugin.SmithyT
5456
def mainClass = Some("org.scala.abusers.lspsmithy.main")
5557

5658
def ivyDeps = Agg(
57-
ivy"tech.neander::langoustine-meta::0.0.23",
59+
ivy"tech.neander::langoustine-meta::$langoustineVersion",
5860
ivy"com.lihaoyi::os-lib:0.11.4",
59-
ivy"software.amazon.smithy:smithy-model:1.57.1",
61+
ivy"software.amazon.smithy:smithy-model:$smithyVersion",
62+
ivy"software.amazon.smithy:smithy-diff:$smithyVersion",
6063
ivy"tech.neander:jsonrpclib-smithy:$jsonrpcVersion",
6164
ivy"com.disneystreaming.alloy:alloy-core:0.3.20",
6265
)
@@ -83,7 +86,8 @@ object exampleClientSmithy extends CommonScalaModule with Smithy4sModule {
8386
super.smithy4sInputDirs() ++ Seq(PathRef(millSourcePath / os.up / "target"))
8487
}
8588
override def ivyDeps = Agg(
86-
ivy"com.disneystreaming.smithy4s::smithy4s-core:${smithy4sVersion()}"
89+
ivy"com.disneystreaming.smithy4s::smithy4s-core:${smithy4sVersion()}",
90+
ivy"tech.neander::jsonrpclib-smithy4s:$jsonrpcVersion",
8791
)
8892
}
8993

@@ -105,8 +109,8 @@ object exampleClient extends CommonScalaModule with Smithy4sModule {
105109

106110
object dummyServer extends CommonScalaModule {
107111
override def ivyDeps = Agg(
108-
ivy"tech.neander::langoustine-lsp::0.0.24",
109-
ivy"tech.neander::langoustine-app::0.0.24",
112+
ivy"tech.neander::langoustine-lsp::$langoustineVersion",
113+
ivy"tech.neander::langoustine-app::$langoustineVersion",
110114
)
111115

112116
}

exampleClient/src/org/scala/abusers/example/SmithyClientMain.scala

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ object SmithyClientMain extends IOApp.Simple {
3838
rp <- Stream.resource(
3939
Processes[IO]
4040
.spawn(
41-
fs2.io.process.ProcessBuilder("java", "-jar", serverJar)
41+
fs2.io.process.ProcessBuilder(
42+
"java",
43+
"-jar",
44+
serverJar,
45+
)
4246
)
4347
)
4448
// Creating a channel that will be used to communicate to the server
@@ -48,16 +52,35 @@ object SmithyClientMain extends IOApp.Simple {
4852
// Creating stubs to talk to the remote server
4953
server: ExampleLspServer[IO] = ClientStub(ExampleLspServer, fs2Channel)
5054
_ <- Stream(())
51-
.concurrently(fs2Channel.output.through(lsp.encodeMessages).through(rp.stdin))
52-
.concurrently(rp.stdout.through(lsp.decodeMessages).through(fs2Channel.inputOrBounce))
55+
.concurrently(
56+
fs2Channel.output
57+
// .evalTap(IO.println)
58+
.through(lsp.encodeMessages)
59+
// .through(lsp.decodePayloads)
60+
// .evalTap(IO.println)
61+
// .through(lsp.encodePayloads)
62+
.through(rp.stdin)
63+
)
64+
.concurrently(
65+
rp.stdout
66+
// .through(lsp.decodePayloads)
67+
// .evalTap(IO.println(_))
68+
// .through(lsp.encodePayloads)
69+
.through(lsp.decodeMessages)
70+
.through(fs2Channel.inputOrBounce)
71+
)
5372
.concurrently(rp.stderr.through(fs2.io.stderr[IO]))
5473

5574
////////////////////////////////////////////////////////
5675
/////// INTERACTION
5776
////////////////////////////////////////////////////////
5877
result1 <- Stream.eval(
5978
server.initializeOp(
60-
InitializeParams()
79+
InitializeParams(
80+
processId = IntegerOrNULL.case0(1),
81+
rootUri = DocumentUriOrNULL.case0("/bin/"),
82+
capabilities = ClientCapabilities(),
83+
)
6184
)
6285
)
6386
_ <- log(s"Client received $result1")

lspSmithy/src/org/scala/abusers/lspsmithy/GenerateSmithy.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import langoustine.meta.MetaModel
55
import software.amazon.smithy.model.shapes.SmithyIdlModelSerializer
66
import upickle.default.*
77

8+
import java.nio.file.Paths
89
import scala.io.Source
910
import scala.jdk.CollectionConverters.*
1011

@@ -19,7 +20,8 @@ def main() = {
1920
val targetDir = os.Path(sys.env("TARGET_PATH"))
2021
os.remove.all(targetDir)
2122

22-
for (path, content) <- outputMap do
23-
val outputPath = targetDir / path.toString
23+
outputMap.get(Paths.get("lsp.smithy")).foreach { content =>
24+
val outputPath = targetDir / "lsp.smithy"
2425
os.write.over(outputPath, content, createFolders = true)
26+
}
2527
}

0 commit comments

Comments
 (0)