From a65570db9ac8c59d59b79a3f8a07134a90a3c6f2 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Sun, 10 Mar 2024 20:43:15 +0900 Subject: [PATCH] delete jquery. use preact --- build.sbt | 2 +- core/src/main/js/scalameta_ast/Main.scala | 44 +- .../scala/scalameta_ast/IntegrationTest.scala | 5 +- sources/index.html | 194 +---- sources/main.js | 705 +++++++++++------- 5 files changed, 466 insertions(+), 484 deletions(-) diff --git a/build.sbt b/build.sbt index ab3f732..e53c253 100644 --- a/build.sbt +++ b/build.sbt @@ -150,7 +150,7 @@ lazy val localServer = project.settings( commonSettings, run / fork := true, run / baseDirectory := (LocalRootProject / baseDirectory).value, - Test / testOptions += Tests.Argument("-oD"), + Test / testOptions += Tests.Argument("-oDF"), Test / test := (Test / test).dependsOn(LocalRootProject / copyFilesFull).value, Test / testOptions ++= { if (scala.util.Properties.isMac) { diff --git a/core/src/main/js/scalameta_ast/Main.scala b/core/src/main/js/scalameta_ast/Main.scala index 1c060c0..c71d395 100644 --- a/core/src/main/js/scalameta_ast/Main.scala +++ b/core/src/main/js/scalameta_ast/Main.scala @@ -26,24 +26,32 @@ object Main { removeNewFields: Boolean, initialExtractor: Boolean, ): js.Object = { - val output = - new ScalametaAST().convert( - src = source, - format = format, - scalafmtConfig = hoconToMetaConfig(scalafmtConfJsonStr), - outputType = outputType, - packageName = Option(packageName).filter(_.trim.nonEmpty), - wildcardImport = wildcardImport, - ruleNameOption = Option(ruleName).filter(_.trim.nonEmpty), - dialect = Option(dialect).filter(_.trim.nonEmpty), - patch = Option(patch).filter(_.trim.nonEmpty), - removeNewFields = removeNewFields, - initialExtractor = initialExtractor, - ) - new js.Object { - var ast = output.ast - var astBuildMs = output.astBuildMs.toDouble - var formatMs = output.formatMs.toDouble + try { + val output = + new ScalametaAST().convert( + src = source, + format = format, + scalafmtConfig = hoconToMetaConfig(scalafmtConfJsonStr), + outputType = outputType, + packageName = Option(packageName).filter(_.trim.nonEmpty), + wildcardImport = wildcardImport, + ruleNameOption = Option(ruleName).filter(_.trim.nonEmpty), + dialect = Option(dialect).filter(_.trim.nonEmpty), + patch = Option(patch).filter(_.trim.nonEmpty), + removeNewFields = removeNewFields, + initialExtractor = initialExtractor, + ) + new js.Object { + var ast = output.ast + var astBuildMs = output.astBuildMs.toDouble + var formatMs = output.formatMs.toDouble + } + } catch { + case e: Throwable => + new js.Object { + var error = e + var errorString: String = e.toString + } } } diff --git a/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala b/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala index 0e3c663..13e9e45 100644 --- a/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala +++ b/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala @@ -116,7 +116,7 @@ abstract class IntegrationTest(browserType: Playwright => BrowserType) extends A .getByRole(AriaRole.RADIO) .all() .asScala - .find(_.getAttribute("id") == outputType) + .find(_.getAttribute("value") == outputType) .getOrElse(sys.error(s"not found ${outputType}")) .check() } @@ -145,6 +145,7 @@ abstract class IntegrationTest(browserType: Playwright => BrowserType) extends A } "change input" in withBrowser { page => + changeOutputType(page, "raw") setInput(page, "class A") val expect = Seq( """Defn.Class.After_4_6_0(""", @@ -350,7 +351,7 @@ abstract class IntegrationTest(browserType: Playwright => BrowserType) extends A assert(wildcardImport(page).isChecked == wildcard) assert(initialExtractor(page).isChecked == _initialExtractor) assert( - page.getByRole(AriaRole.RADIO).all().asScala.filter(_.isChecked).map(_.getAttribute("id")) == Seq(outputType) + page.getByRole(AriaRole.RADIO).all().asScala.filter(_.isChecked).map(_.getAttribute("value")) == Seq(outputType) ) assert(selectedDialect(page) == dialect) assert(packageName(page).inputValue() == pkg) diff --git a/sources/index.html b/sources/index.html index 3a673cc..96a05d5 100644 --- a/sources/index.html +++ b/sources/index.html @@ -3,17 +3,10 @@
- - scalafmt config -
- -