fixed fromatter, plugin, site, libs for new language features

This commit is contained in:
sergeych committed 2026-01-04 01:25:16 +01:00
1 parent abb262d9cf
commit 1d9befe101
14 files changed
+218 -36

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = "net.sergeych"
version = "1.1.0-SNAPSHOT"
version = "1.1.0-rc"
// Removed legacy buildscript classpath declarations; plugins are applied via the plugins DSL below
@@ -83,7 +83,7 @@ object LyngFormatter {
// property accessors ending with ) or =
if (isPropertyAccessor(t)) {
return t.endsWith(")") || t.endsWith("=")
return if (t.contains('=')) t.endsWith('=') else t.endsWith(')')
}
return false
}
@@ -186,7 +186,7 @@ object LyngFormatter {
val endsWithBrace = code.trimEnd().endsWith("{")
if (!endsWithBrace && isControlHeaderNoBrace(code)) {
// It's another header, increment
awaitingExtraIndent += 1
awaitingExtraIndent += if (isAccessor) 2 else 1
} else {
// It's the body, reset
awaitingExtraIndent = 0
@@ -195,7 +195,7 @@ object LyngFormatter {
// start awaiting if current line is a control header without '{'
val endsWithBrace = code.trimEnd().endsWith("{")
if (!endsWithBrace && isControlHeaderNoBrace(code)) {
awaitingExtraIndent = 1
awaitingExtraIndent = if (isAccessor) 2 else 1
}
}
@@ -802,4 +802,52 @@ class LyngFormatterTest {
val out = LyngFormatter.reindent(src, cfg)
assertEquals(expected, out)
}
@Test
fun propertyAccessor_followedByMethod() {
val src = """
var state: BarRequestState get() = getState()
set(value) = setState(value)
fun save() { cell.value = this }
""".trimIndent()
val expected = """
var state: BarRequestState get() = getState()
set(value) = setState(value)
fun save() { cell.value = this }
""".trimIndent()
val cfg = LyngFormatConfig(indentSize = 4, continuationIndentSize = 4)
val out = LyngFormatter.reindent(src, cfg)
assertEquals(expected, out)
}
@Test
fun propertyAccessor_dangling() {
val src1 = """
var x
get()
= 1
""".trimIndent()
val expected1 = """
var x
get()
= 1
""".trimIndent()
assertEquals(expected1, LyngFormatter.reindent(src1, LyngFormatConfig(indentSize = 4)))
val src2 = """
var x
get() =
1
""".trimIndent()
val expected2 = """
var x
get() =
1
""".trimIndent()
assertEquals(expected2, LyngFormatter.reindent(src2, LyngFormatConfig(indentSize = 4)))
}
}