diff --git a/build.gradle.kts b/build.gradle.kts index 7c382c05c..0d8ba7e5f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,12 @@ import at.phatbl.shellexec.ShellExec plugins { - kotlin("jvm") version "1.7.0" apply false + kotlin("jvm") version "1.9.23" apply false id("at.phatbl.shellexec") version "1.5.2" } -val htmlBuildDir = "$buildDir/spec/html" -val pdfBuildDir = "$buildDir/spec/pdf" +val htmlBuildDir = "${layout.buildDirectory.get()}/spec/html" +val pdfBuildDir = "${layout.buildDirectory.get()}/spec/pdf" val resourcesBuildDir = "$htmlBuildDir/resources" val jsBuildDir = "$resourcesBuildDir/js" diff --git a/docker/Dockerfile b/docker/Dockerfile index e6c38e61e..fb82d6bbd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM pandoc/latex:2.14.2-ubuntu +FROM pandoc/latex:3.1.1-ubuntu MAINTAINER Marat Akhin WORKDIR /source @@ -12,12 +12,11 @@ RUN apt-get update RUN apt-get install -y zulu-11 # install packages for the Kotlin spec -RUN apt-get install -y git -RUN apt-get install -y gpp -RUN apt-get install -y librsvg2-bin -RUN apt-get install -y npm -RUN apt-get install -y curl -RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - +RUN apt-get install -y ca-certificates curl gnupg git gpp librsvg2-bin +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list +RUN apt-get update RUN apt-get install -y nodejs # install more TeX Live packages diff --git a/docs/build.gradle.kts b/docs/build.gradle.kts index c9c8753c4..a28a402bd 100644 --- a/docs/build.gradle.kts +++ b/docs/build.gradle.kts @@ -10,8 +10,8 @@ plugins { group = "org.jetbrains.kotlin.spec" version = "0.1" -val htmlBuildDir = "$buildDir/spec/html" -val pdfBuildDir = "$buildDir/spec/pdf" +val htmlBuildDir = "${layout.buildDirectory.get()}/spec/html" +val pdfBuildDir = "${layout.buildDirectory.get()}/spec/pdf" val resourcesBuildDir = "$htmlBuildDir/resources" val jsBuildDir = "$resourcesBuildDir/js" val scriptsDir = "$projectDir/scripts/build" @@ -24,6 +24,10 @@ repositories { mavenCentral() } +kotlin { + jvmToolchain(11) +} + sourceSets { main { java.srcDir("src/main/kotlin") @@ -40,7 +44,7 @@ dependencies { } } implementation("com.github.ajalt:clikt:2.8.0") - implementation("com.zaxxer:nuprocess:2.0.3") + implementation("com.zaxxer:nuprocess:2.0.6") implementation("org.antlr:antlr4:4.8") } @@ -91,12 +95,12 @@ tasks.create("prepareShell") { if (enableStaticMath) { appendLine("STATIC_MATH_OPTION=--enable-static-math") - appendLine("KATEX_BIN_OPTION=\"--katex=${rootProject.buildDir}/js/node_modules/.bin/katex\"") + appendLine("KATEX_BIN_OPTION=\"--katex=${rootProject.layout.buildDirectory.get()}/js/node_modules/.bin/katex\"") } else appendLine("STATIC_MATH_OPTION=--disable-static-math") } - File("$buildDir/prepare.sh").writeText("$res") + File("${layout.buildDirectory.get()}/prepare.sh").writeText("$res") } } diff --git a/docs/html/build.gradle.kts b/docs/html/build.gradle.kts index b77e3410e..543c10404 100644 --- a/docs/html/build.gradle.kts +++ b/docs/html/build.gradle.kts @@ -1,4 +1,4 @@ -val htmlBuildDir = "${project.parent?.buildDir}/spec/html" +val htmlBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/html" val scriptsDir = "${project.parent?.projectDir}/scripts/build" tasks.create("build") { diff --git a/docs/htmlSections/build.gradle.kts b/docs/htmlSections/build.gradle.kts index 7876b3990..333c93d74 100644 --- a/docs/htmlSections/build.gradle.kts +++ b/docs/htmlSections/build.gradle.kts @@ -1,6 +1,6 @@ import java.nio.file.Paths -val htmlBuildDir = "${project.parent?.buildDir}/spec/html" +val htmlBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/html" val scriptsDir = "${project.parent?.projectDir}/scripts/build" tasks.create("build") { diff --git a/docs/pdf/build.gradle.kts b/docs/pdf/build.gradle.kts index 01d55b1c7..049a6feeb 100644 --- a/docs/pdf/build.gradle.kts +++ b/docs/pdf/build.gradle.kts @@ -1,4 +1,4 @@ -val pdfBuildDir = "${project.parent?.buildDir}/spec/pdf" +val pdfBuildDir = "${project.parent?.layout?.buildDirectory}/spec/pdf" val scriptsDir = "${project.parent?.projectDir}/scripts/build" tasks.create("build") { diff --git a/docs/pdfSections/build.gradle.kts b/docs/pdfSections/build.gradle.kts index daf0cdc74..c26a94dda 100644 --- a/docs/pdfSections/build.gradle.kts +++ b/docs/pdfSections/build.gradle.kts @@ -1,6 +1,6 @@ import java.nio.file.Paths -val pdfBuildDir = "${project.parent?.buildDir}/spec/pdf" +val pdfBuildDir = "${project.parent?.layout?.buildDirectory?.get()}/spec/pdf" val scriptsDir = "${project.parent?.projectDir}/scripts/build" tasks.create("build") { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fcea..48c0a02ca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/grammar/build.gradle.kts b/grammar/build.gradle.kts index a69020886..c16a72c85 100644 --- a/grammar/build.gradle.kts +++ b/grammar/build.gradle.kts @@ -5,7 +5,7 @@ import java.util.regex.Pattern plugins { idea - id("org.jetbrains.intellij") version "1.6.0" + id("org.jetbrains.intellij") version "1.17.3" antlr `maven-publish` kotlin("jvm") @@ -47,13 +47,21 @@ sourceSets { dependencies { implementation("junit:junit:4.13.2") - antlr("org.antlr:antlr4:4.8") + antlr("org.antlr:antlr4:4.13.1") } tasks.compileKotlin { dependsOn("generateGrammarSource") } +java { + targetCompatibility = JavaVersion.VERSION_11 +} + +kotlin { + jvmToolchain(11) +} + intellij { version.set("IC-2022.1") } @@ -155,9 +163,9 @@ tasks.create("prepareDiagnosticsCompilerTests") { val instrumentTestCodeTask = tasks.named("instrumentTestCode") -tasks.named("inspectClassesForKotlinIC") { - dependsOn(instrumentTestCodeTask) -} +// tasks.named("inspectClassesForKotlinIC") { +// dependsOn(instrumentTestCodeTask) +// } tasks.withType { dependsOn(instrumentTestCodeTask) @@ -172,5 +180,7 @@ tasks.withType { ) } + duplicatesStrategy = DuplicatesStrategy.INCLUDE + from(configurations.runtimeClasspath.get().files.map { if (it.isDirectory) it else zipTree(it) }) } diff --git a/grammar/gradle/wrapper/gradle-wrapper.properties b/grammar/gradle/wrapper/gradle-wrapper.properties index d2c45a4b2..48c0a02ca 100644 --- a/grammar/gradle/wrapper/gradle-wrapper.properties +++ b/grammar/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/web/build.gradle.kts b/web/build.gradle.kts index 670467e8c..0324c05ad 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput plugins { - kotlin("js") + kotlin("multiplatform") } group = "org.jetbrains.kotlin.spec" @@ -12,7 +12,6 @@ val buildMode = findProperty("mode")?.toString() ?: "production" // production | repositories { mavenCentral() - jcenter() } tasks.create("copyKatex") { @@ -20,11 +19,11 @@ tasks.create("copyKatex") { group = "internal" from("$rootDir/build/js/node_modules/katex/dist") - into("$buildDir/js/katex".also { File(it).mkdirs() }) + into("${layout.buildDirectory.get()}/js/katex".also { File(it).mkdirs() }) } kotlin { - js { + js(IR) { moduleName = "main" compilations.all { packageJson { @@ -35,8 +34,9 @@ kotlin { moduleKind = "amd" } } + binaries.executable() browser { - webpackTask { + webpackTask(Action { dependsOn("copyKatex") output.apply { @@ -44,23 +44,23 @@ kotlin { library = "main" } - destinationDirectory = file("${buildDir}/js") - outputFileName = "main.js" + outputDirectory = file("${layout.buildDirectory.get()}/js") + mainOutputFileName = "main.js" - mode = Mode.valueOf(buildMode.toUpperCase()) + mode = Mode.valueOf(buildMode.uppercase()) sourceMaps = (mode == Mode.DEVELOPMENT) - } + }) } } sourceSets { - main { + val jsMain by getting { + kotlin.srcDir("src/main/kotlin") dependencies { - compileOnly("kotlin.js.externals:kotlin-js-jquery:2.0.0-0") - implementation(npm("katex", "0.11.1")) + implementation(npm("katex", "0.16.10")) implementation(npm("jquery", "2.2.4")) - implementation(npm("kotlin-playground", "1.24.2")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.12.0") + implementation(npm("kotlin-playground", "1.30.0")) + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") } } } diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/JQuery.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/JQuery.kt new file mode 100644 index 000000000..1d9bf639e --- /dev/null +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/JQuery.kt @@ -0,0 +1,88 @@ +package org.jetbrains.kotlin.spec + +import org.w3c.dom.Element +import org.w3c.dom.HTMLElement + +@JsModule("jquery") +@JsNonModule +external fun `$`(selector: dynamic): JQuery + +@JsModule("jquery") +@JsNonModule +external interface JQueryCoordinates { + // var left: Number + var top: Number +} + +@JsModule("jquery") +@JsNonModule +external interface JQueryEventObject { + fun stopPropagation() + var currentTarget: Element + var target: Element + var keyCode: Number + // var offsetX: Number + var offsetY: Number +} + +@JsModule("jquery") +@JsNonModule +external interface JQuery { + fun offset(): JQueryCoordinates + operator fun get(index: Number): HTMLElement? + fun ready(handler: (jQueryAlias: Any? /*= null*/) -> Any): JQuery + fun attr(attributeName: String): String + fun prop(propertyName: String): Any + fun contents(): JQuery + fun addClass(className: String): JQuery + fun removeClass(className: String): JQuery + fun hasClass(className: String): Boolean + fun toggleClass(className: String, swtch: Boolean? = definedExternally /* null */): JQuery + fun prepend(content1: String, vararg content2: Any): JQuery + fun append(content1: String, vararg content2: Any): JQuery + fun appendTo(target: String): JQuery + fun data(key: String, value: Any): JQuery + fun data(key: String): Any + fun data(): Any + fun get(): Array + fun children(selector: String? = definedExternally /* null */): JQuery + fun clone(withDataAndEvents: Boolean? = definedExternally /* null */, deepWithDataAndEvents: Boolean? = definedExternally /* null */): JQuery + fun eq(index: Number): JQuery + fun each(func: (index: Number, elem: Element) -> Any?): JQuery + fun empty(): JQuery + fun filter(func: (index: Number, element: Element) -> Any): JQuery + fun find(selector: String): JQuery + fun find(element: Element): JQuery + fun find(obj: JQuery): JQuery + fun first(): JQuery + fun `is`(selector: String): Boolean + var length: Number + fun parent(selector: String? = definedExternally /* null */): JQuery + fun parents(selector: String? = definedExternally /* null */): JQuery + fun next(selector: String? = definedExternally /* null */): JQuery + fun nextAll(selector: String? = definedExternally /* null */): JQuery + fun prevAll(selector: String? = definedExternally /* null */): JQuery + fun remove(selector: String? = definedExternally /* null */): JQuery + fun before(content1: String, vararg content2: Any): JQuery + fun html(htmlString: String): JQuery + fun css(propertyName: String, value: String): JQuery + fun css(propertyName: String, value: Number): JQuery + fun text(): String + fun focus(): JQuery + fun select(): JQuery + fun click(): JQuery + fun keydown(handler: (eventObject: JQueryEventObject) -> Any): JQuery + fun keyup(handler: (eventObject: JQueryEventObject) -> Any): JQuery + fun width(): Number + fun height(): Number + fun fadeTo(duration: Number, opacity: Number, easing: String? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery + fun show(duration: Number? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery + fun toggle(duration: Number? = definedExternally /* null */, complete: Function<*>? = definedExternally /* null */): JQuery + fun on(events: String, handler: (eventObject: JQueryEventObject, args: Any) -> Any): JQuery + fun on(events: String, selector: String, handler: (eventObject: JQueryEventObject, eventData: Any) -> Any): JQuery + fun scroll(handler: (eventObject: JQueryEventObject) -> Any): JQuery + fun scrollTop(): Number + fun scrollTop(value: Number): JQuery + fun `val`(): Any + fun `val`(value: String): JQuery +} \ No newline at end of file diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/entity/test/parameters/TestInfo.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/entity/test/parameters/TestInfo.kt index 26607c4d4..f89526dc2 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/entity/test/parameters/TestInfo.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/entity/test/parameters/TestInfo.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlin.spec.entity.test.parameters import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.jsonPrimitive /** contains all options which could be defined in testMap.json's tests */ private enum class TestElementKey(val value: String) { @@ -26,13 +27,13 @@ class TestInfo(jsonSpecTestInfo: JsonObject, val testNumber: Int) { init { - fun parse(testElementKey: TestElementKey) = jsonSpecTestInfo[testElementKey.value]?.primitive?.content + fun parse(testElementKey: TestElementKey) = jsonSpecTestInfo[testElementKey.value]?.jsonPrimitive?.content specVersion = parse(TestElementKey.SPEC_VERSION) ?: "" casesNumber = parse(TestElementKey.CASES_NUMBER)?.toInt() ?: 1 description = parse(TestElementKey.DESCRIPTION) ?: "" path = parse(TestElementKey.PATH) ?: "" unexpectedBehaviour = parse(TestElementKey.UNEXPECTED_BEHAVIOUR)?.toBoolean() ?: false linkType = parse(TestElementKey.LINK_TYPE)?.let { LinkType.valueOf(it) } ?: LinkType.main - helpers = parse(TestElementKey.HELPERS)?.split(",")?.map { it -> it.trim() }?.toSet() ?: emptySet() + helpers = parse(TestElementKey.HELPERS)?.split(",")?.map(String::trim)?.toSet() ?: emptySet() } } diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/GithubTestsLoader.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/GithubTestsLoader.kt index e921866bc..6fca0062e 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/GithubTestsLoader.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/GithubTestsLoader.kt @@ -1,10 +1,6 @@ package org.jetbrains.kotlin.spec.loader -import js.externals.jquery.JQueryAjaxSettings -import js.externals.jquery.JQueryXHR -import js.externals.jquery.`$` import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonConfiguration import org.jetbrains.kotlin.spec.entity.TestsLoadingInfo import org.jetbrains.kotlin.spec.entity.SpecSection import org.jetbrains.kotlin.spec.entity.test.SpecTest @@ -13,6 +9,9 @@ import org.jetbrains.kotlin.spec.entity.test.parameters.TestInfo import org.jetbrains.kotlin.spec.entity.test.parameters.testArea.TestArea import org.jetbrains.kotlin.spec.utils.format import kotlinx.browser.window +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive import kotlin.js.Promise interface GithubTestsLoader { @@ -30,32 +29,22 @@ interface GithubTestsLoader { const val DEFAULT_BRANCH = "spec-tests" - protected val testAreasToLoad = TestArea.values() + protected val testAreasToLoad = TestArea.entries fun getBranch() = window.localStorage.getItem("spec-tests-branch") ?: DEFAULT_BRANCH - fun loadHelperFromRawGithub(fileName: String, testArea: TestArea): Promise { - return Promise { requestResolve, requestReject -> - `$`.ajax(getFullHelperPath(testArea, fileName), - jQueryAjaxSettings { requestReject(Exception()) } - ).then({ response: Any?, _: Any -> - requestResolve(response.toString()) - }) - } - } + fun loadHelperFromRawGithub(fileName: String, testArea: TestArea): Promise = + window.fetch(getFullHelperPath(testArea, fileName)).then { it.text() }.then { it } fun loadTestFileFromRawGithub( path: String, testInfo: TestInfo, testPlace: TestPlace, testArea: TestArea - ): Promise = Promise { requestResolve, requestReject -> - `$`.ajax(getFullTestPath(path), - jQueryAjaxSettings { requestReject(Exception()) } - ).then({ response: Any?, _: Any -> - requestResolve(SpecTest(testInfo, testPlace, response.toString(), testArea)) - }) - } + ): Promise = + window.fetch(getFullTestPath(path)) + .then { it.text() } + .then { SpecTest(testInfo, testPlace, it, testArea) } fun loadTestMapFileFromRawGithub( @@ -63,7 +52,7 @@ interface GithubTestsLoader { path: String, testType: TestOrigin, sectionsMapByTestArea: Map - ): Promise> = Promise { resolve, _ -> + ): Promise> { val resultMap = mutableMapOf() val loadableTestAreas: MutableSet = mutableSetOf() testAreasToLoad.forEach { @@ -71,20 +60,19 @@ interface GithubTestsLoader { loadableTestAreas.add(it) } } - `$`.`when`( - *(loadableTestAreas.associateWith { - `$`.ajax(getFullTestMapPath(testType, it, mainSectionName, path), jQueryAjaxSettings { }) - .then({ response: Any?, _: Any -> - resultMap[it] = TestsLoadingInfo.Tests(parseJsonText(response.toString())) - }) - }.values.toTypedArray()) - ).then({ _: Any?, _: Any -> resolve(resultMap) }, { resolve(resultMap) }) + return Promise.all( + loadableTestAreas.map { ta -> + window.fetch(getFullTestMapPath(testType, ta, mainSectionName, path)) + .then { it.text() } + .then { resultMap[ta] = TestsLoadingInfo.Tests(parseJsonText(it)) } + }.toTypedArray() + ).then { resultMap } } private fun Map.isTestsMapExists(testArea: TestArea, requestedMainSection: String, requestedSubsectionPath: String): Boolean { val subsectionsArray = this[testArea]?.json?.jsonObject?.get(requestedMainSection) ?: return false subsectionsArray.jsonArray.forEach { jsonElement -> - if (jsonElement.primitive.content == requestedSubsectionPath) + if (jsonElement.jsonPrimitive.content == requestedSubsectionPath) return true } return false @@ -98,16 +86,15 @@ interface GithubTestsLoader { } - fun loadSectionsMapFileFromRawGithub(): Promise> = Promise { resolve, _ -> + fun loadSectionsMapFileFromRawGithub(): Promise> { val resultMap = mutableMapOf() - `$`.`when`( - *(testAreasToLoad.asList().associateWith { - `$`.ajax(getFullSectionsMapPath(it), jQueryAjaxSettings { }) - .then({ response: Any?, _: Any -> - resultMap[it] = TestsLoadingInfo.Sections(parseJsonText(response.toString())) - }) - }.values.toTypedArray()) - ).then({ _: Any?, _: Any -> resolve(resultMap) }, { resolve(resultMap) }) + return Promise.all( + testAreasToLoad.map { ta -> + window.fetch(getFullSectionsMapPath(ta)) + .then { it.text() } + .then { resultMap[ta] = TestsLoadingInfo.Sections(parseJsonText(it)) } + }.toTypedArray() + ).then { resultMap } } private fun getFullSectionsMapPath(testArea: TestArea) = "{1}/{2}/{3}/{4}/{5}/{6}" @@ -120,20 +107,9 @@ interface GithubTestsLoader { private fun getFullTestPath(path: String) = "{1}/{2}/{3}".format(RAW_GITHUB_URL, getBranch(), path) - private fun parseJsonText(text: String) = Json(JsonConfiguration.Stable).parseJson(text) - - private fun jQueryAjaxSettings(requestReject: (Throwable) -> Unit) = object : JQueryAjaxSettings { - override var cache: Boolean? - get() = false - set(_) {} - override var type: String? - get() = "GET" - set(_) {} - override val error: ((jqXHR: JQueryXHR, textStatus: String, errorThrown: String) -> Any)? - get() = { _, _, _ -> requestReject(Exception()) } - } + private fun parseJsonText(text: String) = Json.parseToJsonElement(text) } - fun loadTestFiles(sectionToLoadName: String, mainSectionPath: String, sectionsPath: List, sectionsMapsByTestArea: Map): Promise> + fun loadTestFiles(sectionToLoadName: String, mainSectionPath: String, sectionsPath: List, sectionsMapsByTestArea: Map): Promise } diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/LoaderByTestsMapFile.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/LoaderByTestsMapFile.kt index cb88fe979..0b066868b 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/LoaderByTestsMapFile.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/LoaderByTestsMapFile.kt @@ -1,5 +1,8 @@ package org.jetbrains.kotlin.spec.loader +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive import org.jetbrains.kotlin.spec.entity.SpecSection import org.jetbrains.kotlin.spec.entity.TestsLoadingInfo import org.jetbrains.kotlin.spec.entity.test.SpecTest @@ -37,7 +40,7 @@ class LoaderByTestsMapFile : GithubTestsLoader { for ((testType, testsByTypes) in testsByParagraphs.jsonObject) { for ((testSentence, testsBySentences) in testsByTypes.jsonObject) { testsBySentences.jsonArray.forEachIndexed { i, testInfo -> - val testFilePath = testInfo.jsonObject["path"]?.primitive?.content ?: return@forEachIndexed + val testFilePath = testInfo.jsonObject["path"]?.jsonPrimitive?.content ?: return@forEachIndexed val testElementInfo = TestInfo(testInfo.jsonObject, i + 1) val testPath = TestPlace(paragraph.toInt(), TestType.getByShortName(testType), testSentence.toInt()) promises.add(loadTestFileFromRawGithub(testFilePath, testElementInfo, testPath, testArea)) @@ -53,20 +56,21 @@ class LoaderByTestsMapFile : GithubTestsLoader { mainSectionPath: String, sectionsPath: List, sectionsMapsByTestArea: Map - ) = loadTestsMapFile(mainSectionName = mainSectionPath, + ): Promise = loadTestsMapFile(mainSectionName = mainSectionPath, sectionsPath = when { - mainSectionPath == sectionToLoadName && sectionsPath.isEmpty() -> ""; - sectionsPath.isNotEmpty() -> sectionsPath.joinToString("/") + "/" + sectionToLoadName; + mainSectionPath == sectionToLoadName && sectionsPath.isEmpty() -> "" + sectionsPath.isNotEmpty() -> sectionsPath.joinToString("/") + "/" + sectionToLoadName else -> sectionToLoadName }, sectionsMapByTestArea = sectionsMapsByTestArea) .then { testsMapsByTestArea -> val resultMap = mutableMapOf>() - Promise.all(testAreasToLoad.asList() - .associateWith { getPromiseForTests(it, testsMapsByTestArea, resultMap) } - .values.toTypedArray() + Promise.all( + testAreasToLoad.map { ta -> + getPromiseForTests(ta, testsMapsByTestArea, resultMap) + }.toTypedArray() ).then { SpecSection(resultMap) } - } + }.then { it } fun loadSectionsMapFiles() = loadSectionsMapFile() @@ -74,7 +78,7 @@ class LoaderByTestsMapFile : GithubTestsLoader { testArea: TestArea, testMaps: Map, mapOfTests: MutableMap> - ) = Promise.all( + ): Promise = Promise.all( getPromisesForTestFilesFromTestMap(testMaps[testArea], testArea)) .then { mapOfTests[testArea] = it.toList() } } \ No newline at end of file diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/SpecTestsLoader.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/SpecTestsLoader.kt index 327bb9db6..904dc0e86 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/SpecTestsLoader.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/loader/SpecTestsLoader.kt @@ -1,7 +1,6 @@ package org.jetbrains.kotlin.spec.loader -import js.externals.jquery.JQuery -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` import org.jetbrains.kotlin.spec.entity.TestsLoadingInfo import org.jetbrains.kotlin.spec.entity.SpecSection import org.jetbrains.kotlin.spec.entity.test.parameters.testArea.TestArea @@ -10,6 +9,7 @@ import org.jetbrains.kotlin.spec.utils.isDevMode import org.jetbrains.kotlin.spec.viewer.MarkUpArranger import org.jetbrains.kotlin.spec.viewer.SpecCoverageHighlighter import kotlinx.browser.window +import org.jetbrains.kotlin.spec.JQuery import kotlin.js.Promise class SpecTestsLoader { @@ -55,7 +55,7 @@ class SpecTestsLoader { fun getParagraphsInfo(sectionElement: JQuery): List>? { var nextSibling = sectionElement.get().run { - if (size == 0) return@getParagraphsInfo null + if (isEmpty()) return@getParagraphsInfo null this[0].nextElementSibling } val sectionName = sectionElement.attr("id") diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/main.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/main.kt index d16c3c6c1..a8ee060e9 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/main.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/main.kt @@ -1,6 +1,5 @@ package org.jetbrains.kotlin.spec -import js.externals.jquery.`$` import org.jetbrains.kotlin.spec.loader.SpecTestsLoader import org.jetbrains.kotlin.spec.utils.* import org.jetbrains.kotlin.spec.viewer.Header diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/utils/Popup.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/utils/Popup.kt index 90b8c16b3..563999a40 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/utils/Popup.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/utils/Popup.kt @@ -1,8 +1,8 @@ package org.jetbrains.kotlin.spec.utils -import js.externals.jquery.`$` import kotlinx.browser.document import kotlinx.browser.window +import org.jetbrains.kotlin.spec.`$` import kotlin.math.round data class PopupConfig( diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Header.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Header.kt index a35517ac2..1873d39ef 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Header.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Header.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlin.spec.viewer -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` import org.jetbrains.kotlin.spec.utils.format import org.jetbrains.kotlin.spec.utils.isDevMode import org.jetbrains.kotlin.spec.utils.shouldBeShowedMarkup diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/MarkUpArranger.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/MarkUpArranger.kt index 69cb42e85..9fc4d41a9 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/MarkUpArranger.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/MarkUpArranger.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlin.spec.viewer -import js.externals.jquery.JQuery -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` +import org.jetbrains.kotlin.spec.JQuery import org.jetbrains.kotlin.spec.utils.format import org.w3c.dom.HTMLElement diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Sidebar.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Sidebar.kt index 008e7ad62..380e2ccc0 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Sidebar.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/Sidebar.kt @@ -1,11 +1,11 @@ package org.jetbrains.kotlin.spec.viewer -import js.externals.jquery.JQuery -import js.externals.jquery.`$` import org.w3c.dom.HTMLInputElement import org.w3c.dom.events.KeyboardEvent import kotlinx.browser.document import kotlinx.browser.window +import org.jetbrains.kotlin.spec.`$` +import org.jetbrains.kotlin.spec.JQuery object Sidebar { private const val LOAD_PDF_ICON = "./resources/images/pdf.png" @@ -38,7 +38,7 @@ object Sidebar { val sectionIdFromHash = window.location.hash.removePrefix("#") val sectionIdFromPath = window.location.pathname.split("/").last().removeSuffix(".html") - expandItemsHierarchy(if (sectionIdFromHash.isNotBlank()) sectionIdFromHash else sectionIdFromPath) + expandItemsHierarchy(sectionIdFromHash.ifBlank { sectionIdFromPath }) if (shouldScrollToItem) { scrollToActiveItem() @@ -160,7 +160,7 @@ object Sidebar { `$`("h2").each { _, el -> val sectionName = `$`(el).attr("id") `$`(el).append("" - + """""".trimIndent() + "") + + """""".trimIndent() + "") } } } diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecCoverageHighlighter.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecCoverageHighlighter.kt index 9b1dd7b4a..1b843d78e 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecCoverageHighlighter.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecCoverageHighlighter.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlin.spec.viewer -import js.externals.jquery.JQuery -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` +import org.jetbrains.kotlin.spec.JQuery import org.jetbrains.kotlin.spec.entity.SpecParagraph import org.jetbrains.kotlin.spec.entity.SpecSection import org.jetbrains.kotlin.spec.entity.SpecSentence diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecTestsViewer.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecTestsViewer.kt index a45bc8030..84b82215f 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecTestsViewer.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/SpecTestsViewer.kt @@ -1,7 +1,7 @@ package org.jetbrains.kotlin.spec.viewer -import js.externals.jquery.JQuery -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` +import org.jetbrains.kotlin.spec.JQuery import org.jetbrains.kotlin.spec.entity.SpecSentence import org.jetbrains.kotlin.spec.entity.test.SpecTest import org.jetbrains.kotlin.spec.entity.test.TestCase @@ -145,7 +145,7 @@ class SpecTestsViewer { fun onTestAreaChange() { val testArea = TestArea.getByShortName(`$`(TEST_AREA_SELECTOR).`val`().toString().apply { if (isEmpty()) return }) currentSpecSentenceTests.getTests(testArea) ?: return - TestType.values().forEach { testType -> + TestType.entries.forEach { testType -> val tests = currentSpecSentenceTests.getTests(testArea, testType) ?: return@forEach if (tests.isNotEmpty()) `$`(TEST_TYPE_SELECTOR).append(TEST_TYPE_OPTION_TEMPLATE.format(testType.shortName, testType.name)) diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SentenceFinder.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SentenceFinder.kt index 6b3944402..e0b959761 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SentenceFinder.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SentenceFinder.kt @@ -1,6 +1,6 @@ package org.jetbrains.kotlin.spec.viewer.links -import js.externals.jquery.`$` +import org.jetbrains.kotlin.spec.`$` import org.jetbrains.kotlin.spec.viewer.links.SpecPlaceHighlighter.getSentenceInfoFromSearchField import org.jetbrains.kotlin.spec.viewer.links.SpecPlaceHighlighter.highlightParagraph import org.jetbrains.kotlin.spec.viewer.links.SpecPlaceHighlighter.highlightSentence diff --git a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SpecPlaceHighlighter.kt b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SpecPlaceHighlighter.kt index f7a9debf2..a5269fdd5 100644 --- a/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SpecPlaceHighlighter.kt +++ b/web/src/main/kotlin/org/jetbrains/kotlin/spec/viewer/links/SpecPlaceHighlighter.kt @@ -1,11 +1,11 @@ package org.jetbrains.kotlin.spec.viewer.links -import js.externals.jquery.JQuery -import js.externals.jquery.`$` import org.jetbrains.kotlin.spec.loader.SpecTestsLoader import org.jetbrains.kotlin.spec.utils.* import org.w3c.dom.HTMLElement import kotlinx.browser.window +import org.jetbrains.kotlin.spec.`$` +import org.jetbrains.kotlin.spec.JQuery data class SpecPlaceComponents( val sectionId: String,