From 31696659e55033ce04ff49b5d4e61669df940fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Tue, 24 Dec 2024 18:24:20 +0100 Subject: [PATCH] Backport non-controversial changes from treesitter branch (#506) * Backport non-controversial changes from treesitter branch * make build happy --- .github/workflows/ci.yml | 2 +- build.sbt | 23 +++++++++++++------ flake.lock | 14 +++++------ flake.nix | 4 ++-- .../main/scala/playground/smithyql/AST.scala | 11 +++++---- .../test/scala/playground/Assertions.scala | 2 +- .../test/scala/playground/e2e/E2ETests.scala | 7 +++--- .../playground/smithyql/WithSource.scala | 4 ++-- smithy-build.json | 2 +- 9 files changed, 39 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2267fc96..e08593a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,5 +55,5 @@ jobs: run: nix develop --command bash -c 'cd vscode-extension && yarn && SERVER_VERSION=$(cat ../.version) xvfb-run --auto-servernum yarn test' - name: Show extension test logs - if: job.status == 'failure' + if: always() && job.status == 'failure' run: cat vscode-extension/fixture/smithyql-log.txt | tail --lines 1000 diff --git a/build.sbt b/build.sbt index ba2bdc2e..65ef893f 100644 --- a/build.sbt +++ b/build.sbt @@ -228,17 +228,26 @@ lazy val e2e = module("e2e") buildInfoKeys ++= Seq[BuildInfoKey.Entry[_]]( // do you know how to simplify this? let me know please! Def - .task((lsp / Compile / fullClasspath).value.map(_.data).map(_.toString)) - .taskValue - .named("lspClassPath"), - Def - .task( - (lsp / Compile / mainClass).value.getOrElse(sys.error("didn't find main class in lsp")) + .task { + s"""${(lsp / organization).value}::${(lsp / moduleName).value}:${(lsp / version).value}""" + } + // todo: replace with a full publishLocal before e2e in particular gets run (but not before tests run normally) + .dependsOn( + lsp / publishLocal, + languageSupport / publishLocal, + core / publishLocal, + parser / publishLocal, + pluginCore / publishLocal, + source / publishLocal, + ast / publishLocal, + formatter / publishLocal, + protocol4s / publishLocal, ) .taskValue - .named("lspMainClass"), + .named("lspArtifact") ), publish / skip := true, + Test / fork := true, ) .dependsOn(lsp) diff --git a/flake.lock b/flake.lock index 42bd7c08..0ef3c0b0 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730272153, - "narHash": "sha256-B5WRZYsRlJgwVHIV6DvidFN7VX7Fg9uuwkRW9Ha8z+w=", + "lastModified": 1730602179, + "narHash": "sha256-efgLzQAWSzJuCLiCaQUCDu4NudNlHdg2NzGLX5GYaEY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d2a9ddbe3f2c00747398f3dc9b05f7f2ebb0f53", + "rev": "3c2f1c4ca372622cb2f9de8016c9a0b1cbd0f37c", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 35a33a30..c81ba451 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,10 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { nixpkgs, flake-utils, ... }: + outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem ( system: let diff --git a/modules/ast/src/main/scala/playground/smithyql/AST.scala b/modules/ast/src/main/scala/playground/smithyql/AST.scala index a542a1c7..1895de91 100644 --- a/modules/ast/src/main/scala/playground/smithyql/AST.scala +++ b/modules/ast/src/main/scala/playground/smithyql/AST.scala @@ -4,6 +4,7 @@ import cats.Applicative import cats.Functor import cats.Id import cats.Show +import cats.arrow.FunctionK import cats.data.NonEmptyList import cats.kernel.Eq import cats.kernel.Order @@ -87,7 +88,7 @@ final case class SourceFile[F[_]]( def mapK[G[_]: Functor]( fk: F ~> G - ): AST[G] = SourceFile( + ): SourceFile[G] = SourceFile( prelude = prelude.mapK(fk), statements = fk(statements).map(_.map(_.mapK(fk))), ) @@ -132,9 +133,9 @@ final case class OperationName[F[_]]( text: String ) extends AST[F] { - def mapK[G[_]: Functor]( - fk: F ~> G - ): OperationName[G] = copy() + def mapK[G[_]: Functor](fk: FunctionK[F, G]): OperationName[G] = retag[G] + + def retag[G[_]]: OperationName[G] = copy() } @@ -189,7 +190,7 @@ final case class QueryOperationName[F[_]]( fk: F ~> G ): QueryOperationName[G] = QueryOperationName( identifier.map(fk(_)), - fk(operationName).map(_.mapK(fk)), + fk(operationName).map(_.retag[G]), ) } diff --git a/modules/ast/src/test/scala/playground/Assertions.scala b/modules/ast/src/test/scala/playground/Assertions.scala index ea0f7ddd..ac2bd7b4 100644 --- a/modules/ast/src/test/scala/playground/Assertions.scala +++ b/modules/ast/src/test/scala/playground/Assertions.scala @@ -23,7 +23,7 @@ object Assertions extends Expectations.Helpers { val stringWithResets = d.show()(conf).linesWithSeparators.map(Console.RESET + _).mkString failure( - s"Diff failed:\n${Console.RESET}(${conf.left("expected")}, ${conf.right("actual")})\n\n" + stringWithResets + s"Diff failed:\n${Console.RESET}(${conf.left("actual")}, ${conf.right("expected")})\n\n" + stringWithResets ) } diff --git a/modules/e2e/src/test/scala/playground/e2e/E2ETests.scala b/modules/e2e/src/test/scala/playground/e2e/E2ETests.scala index e4440b0a..9592492d 100644 --- a/modules/e2e/src/test/scala/playground/e2e/E2ETests.scala +++ b/modules/e2e/src/test/scala/playground/e2e/E2ETests.scala @@ -74,10 +74,9 @@ object E2ETests extends SimpleIOSuite { val builder = new ProcessBuilder( - "java", - "-cp", - BuildInfo.lspClassPath.mkString(":"), - BuildInfo.lspMainClass, + "cs", + "launch", + BuildInfo.lspArtifact, ) // Watch process stderr in test runner .redirectError(Redirect.INHERIT) diff --git a/modules/source/src/main/scala/playground/smithyql/WithSource.scala b/modules/source/src/main/scala/playground/smithyql/WithSource.scala index 8004d272..a95e9768 100644 --- a/modules/source/src/main/scala/playground/smithyql/WithSource.scala +++ b/modules/source/src/main/scala/playground/smithyql/WithSource.scala @@ -64,8 +64,8 @@ final case class SourceRange( // Assuming this range corresponds to a bracket/brace/quote etc., // shrink it by one character on each side. def shrink1: SourceRange = copy( - start = start.copy(index = start.index + 1), - end = end.copy(index = end.index - 1), + start = start.moveRight(1), + end = end.moveLeft(1), ) def render: String = s"${start.index}-${end.index}" diff --git a/smithy-build.json b/smithy-build.json index b029b2a4..4364f960 100644 --- a/smithy-build.json +++ b/smithy-build.json @@ -1,5 +1,5 @@ { - "sources": ["modules/core/src/test/smithy"], + "sources": ["modules/examples/src/main/smithy"], "mavenDependencies": [ "com.disneystreaming.alloy:alloy-core:0.3.14", "com.disneystreaming.smithy4s:smithy4s-protocol:0.18.26",