Skip to content

Commit

Permalink
delete jquery. use preact
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Mar 10, 2024
1 parent e3c8c0a commit a65570d
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 484 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
44 changes: 26 additions & 18 deletions core/src/main/js/scalameta_ast/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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(""",
Expand Down Expand Up @@ -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)
Expand Down
194 changes: 1 addition & 193 deletions sources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
<head>
<meta charset="UTF-8" />
<title>scalameta-ast</title>
<script
type="text/javascript"
src="https://code.jquery.com/jquery-3.7.1.min.js"
></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/scala.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/highlightjs-copy.min.js"></script>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/highlightjs-copy.min.css"
Expand All @@ -40,191 +33,6 @@
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3"
crossorigin="anonymous"
></script>
<div class="container mw-100">
<details open id="header_all_scalafix_config">
<summary>close header</summary>
<div class="row">
<div class="col-5">
<pre id="info" class="alert" style="height: 100px"></pre>
</div>
<div class="col-3">
<div class="row">
<div>
<input type="checkbox" id="format" checked />
<label for="format">format output by scalafmt</label>
</div>
<div>
<input
type="checkbox"
id="wildcard_import"
name="wildcard_import"
/>
<label for="wildcard_import">wildcard import</label>
</div>
<div>
<input
type="checkbox"
id="remove_new_fields"
name="remove_new_fields"
/>
<label for="remove_new_fields"
>remove <code>@newField</code> for
<code>unapply</code> compatibility</label
>
</div>
<div>
<input
type="checkbox"
id="initial_extractor"
name="initial_extractor"
/>
<label for="initial_extractor"
><code>Initial</code> extractor</label
>
</div>
</div>
<div class="row">
<p></p>
</div>
<div class="row">
<div class="col">
<button class="btn btn-primary" id="format_input">
format input scala code
</button>
</div>
<div class="col">
<button class="btn btn-primary" id="clear_local_storage">
clear local storage
</button>
</div>
</div>
</div>
<div class="col-2">
<div class="row">
<fieldset>
<legend>output type</legend>
<div>
<input type="radio" id="raw" name="output_type" value="raw" />
<label for="raw">Raw Scalameta</label>
</div>
<div>
<input
type="radio"
id="syntactic"
name="output_type"
value="syntactic"
/>
<label for="syntactic">Scalafix SyntacticRule</label>
</div>
<div>
<input
type="radio"
id="semantic"
name="output_type"
value="semantic"
/>
<label for="semantic">Scalafix SemanticRule</label>
</div>
<div>
<input
type="radio"
id="tokens"
name="output_type"
value="tokens"
/>
<label for="tokens">Tokens</label>
</div>
</fieldset>
</div>
<div class="row">
<div>
<label for="dialect">dialect</label>
<select name="dialect" id="dialect">
<option value="Auto">Auto</option>
<option value="Scala3">Scala3</option>
<option value="Scala213Source3">Scala213Source3</option>
<option value="Scala213">Scala213</option>
<option value="Scala212Source3">Scala212Source3</option>
<option value="Scala212">Scala212</option>
<option value="Scala211">Scala211</option>
<option value="Scala210">Scala210</option>
</select>
</div>
</div>
</div>
<div class="col-2">
<div class="row">
<div>
<label for="scalameta">scalameta version</label>
<select name="scalameta" id="scalameta">
<option id="scalameta_scalafix_compat" value="scalafix">
scalafix 0.10.x compatible
</option>
<option id="scalameta_latest" value="latest">
scalafix 0.11.x compatible
</option>
</select>
</div>
</div>
<div class="row">
<div>
<label for="package">package</label>
<input type="text" id="package" maxlength="256" />
</div>
</div>
<div class="row">
<div>
<label for="rule_name">rule name</label>
<input type="text" id="rule_name" maxlength="128" />
</div>
</div>
<div class="row">
<div>
<label for="patch"
><a
target="_blank"
href="https://scalacenter.github.io/scalafix/docs/developers/patch.html"
>patch</a
></label
>
<select name="patch" id="patch">
<option value="warn">lint warn</option>
<option value="error">lint error</option>
<option value="info">lint info</option>
<option value="replace">replace</option>
<option value="left">add left</option>
<option value="right">add right</option>
<option value="empty">empty</option>
</select>
</div>
</div>
</div>
</div>
</details>
<div class="row">
<div class="col">
<textarea
id="input_scala"
style="width: 100%; height: 800px"
></textarea>
</div>
<div class="col">
<pre><code class="language-scala" id="output_scala" style="width: 100%; height: 800px; background-color:rgb(233, 233, 233);"></code></pre>
</div>
</div>
<div class="row">
<div class="col">
<p>
<a
href="https://scalameta.org/scalafmt/docs/configuration.html"
target="_blank"
>scalafmt config</a
>
</p>
<textarea id="scalafmt" style="width: 100%; height: 200px"></textarea>
</div>
</div>
<div class="row" id="footer"></div>
</div>
<div id="root"></div>
</body>
</html>
Loading

0 comments on commit a65570d

Please sign in to comment.