Implement canonical formatter (#1107)

CLI commands also added: `pkl format check` and `pkl format apply`.
This commit is contained in:
Islon Scherer
2025-09-17 11:12:04 +02:00
committed by GitHub
parent 6a06ab7caa
commit fdc501a35c
78 changed files with 5491 additions and 26 deletions

View File

@@ -0,0 +1,10 @@
class Foo {
}
class Bar
{
qux = 1
}
class Baz { prop = 0; prop2 = 1 }

View File

@@ -0,0 +1,16 @@
function fun(a, b, c, d) = a
noTrailingCommas = fun(1, 2, 3, 4,)
trailingCommas = fun("loooooooooooooooooooongString", "loooooooooooooooongString", "looooooooooooooooongString", "notTooLong")
noTrailingCommaObjParams {
fooooooooooooooooooooooooooooooooo, baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaz ->
1 + 1
}
trailingCommaInLambdas = (fooooooooooooooooooooooooooooooooo, baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaz) -> 1
trailingCommaInConstraints: String(isSomethingSomethingSomething, isSomethingElse, isSomethingSomethingSomethingElse)
trailingCommaInTypeParameters: Mapping<SomethingSomethingSomethingSomething, SomethingSomething | SomethingElse>

View File

@@ -0,0 +1,31 @@
module comment.interleaved
local test: Int|String =
if (true)
1 // It's the same as "100%"
else
"8%"
foo: ( // some comment
* String(
// if dtstart is defined and a datetime, until must also be a datetime if defined
true
)
|Int
// trailing comment
)?
foo2: (// some comment
Int, // other comment
String
) ->Int
bar = ( // some comment
10 + 10
// another comment
)
bar2 = ( // some comment
foo, bar
// another comment
) -> foo + bar

View File

@@ -0,0 +1,8 @@
module dangling
/// Doc comment.
///
/// for this field
// sepearted by a stray comment
/// but continues here.
some: String

View File

@@ -0,0 +1,14 @@
//// line 1
///// line 2
foo = 1
/// line 1
///
///
/// line 2
bar = 1
///line 1
///line 2
baz = 1

View File

@@ -0,0 +1,25 @@
foo {
123123123123 + 123123123123 * 123123123123 - 123123123123 / 123123123123 + 123123123123 ** 123123123123
2
3
4
}
bar = clazz.superclass == null || clazz.superclass.reflectee == Module || clazz.superclass.reflectee == Typed
baz =
new Listing {
1
2
} |> mixin1 |> mixin2
qux =
(baz) {
1
2
} {
3
4
}
minus = superLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongVariable - 100000

View File

@@ -0,0 +1,5 @@
res = myList.map((it) -> it.partition).filter((it) -> someList.contains(it))
res2 = myList.map(lambda1).filter(lambda2)
res3 = myList.map((it) -> it.partition)

View File

@@ -0,0 +1,7 @@
foo =
if (someCondition) 10000
else
if (someOtherCondition) 20000
else
if (someAnotherCondition) 30000
else 4

View File

@@ -0,0 +1,11 @@
foo = let (vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaariable = 10) 1 * 1
bar = let (someVariable = new Listing {
1
}) 1 * 1
baz =
let (someVariable = 10000000)
let (someOtherVariable = 2000000)
let (someAnotherVariable = 3000000) someVariable + someOtherVariable + someAnotherVariable

View File

@@ -0,0 +1,19 @@
// top level comment
import "@foo/Foo.pkl" as foo
import* "**.pkl"
import "pkl:math"
import "package://example.com/myPackage@1.0.0#/Qux.pkl"
import* "file:///tmp/*.pkl"
import "https://example.com/baz.pkl"
import "module2.pkl"
import "pkl:reflect"
import "..."
import* "@foo/**.pkl"
import "@bar/Bar.pkl"
import "Module12.pkl"
import "module11.pkl"
import "module1.pkl"

View File

@@ -0,0 +1,51 @@
foo = new {
bar = 1
}
class Foo {
baz: Int
}
bar =
new Listing {
1
2
}
baz =
(foo) {
2
3
}
qux =
(x, y) -> new Listing {
x
y
}
forGen = new Listing {
for (someVar in new Listing {
1
2
}) {
[someVar] = someVar
}
}
objParams: Listing<Int> =
new {
default {
key -> key + 1
}
}
objParams2: Listing<Int> = new {
default { someVeryLongParameter1, someVeryLongParameter2, someVeryLongParameter3, someVeryLongParameter4 ->
1
}
}
parenType: (ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType(reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalylongConstraint))
functionType: (ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType,ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType2) -> String

View File

@@ -0,0 +1,64 @@
module
foo.bar.baz
amends
"bar.pkl"
import
"@foo/Foo.pkl"
as foo
local
open
class Bar {}
const
local
baz = 10
local
function
fun(x) =
x
const local prooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooperty: String = "foo"
local function function2(parameter1: Parameter1Type, parameter2: Parameter2Type, parameter3: Parameter3Type, parameter4: Parameter4Type): String = ""
local const function function3(parameter1: String|Int, parameter2: String|Int): Mapping<String|Int, String> =
new {}
prop = function2(loooooooooooooooooogParameter1, loooooooooooooooooogParameter2, loooooooooooooooooogParameter3, loooooooooooooooooogParameter4)
prop2: String
|Int
|Boolean
funcParam = fun(
(x, y) -> new Listing {
x
y
})
funcParam2 = aFun(foo, 10 * 10, anotherVariable, if (true) 100000 else 200000, (param1, param2) -> param1 * param2)
funcParam3 = aFun(foo, 10 * 10, anotherVariable, 200000, (param1, param2) -> param1 * param2)
funcParam4 = aFun(foo, 10 * 10, anotherVariable, if (true) 100000 else 200000, new Listing {
1
2
})
open local class SomeReallyInterestingClassName<in SomeInParameter, out SomeOutParameter> extends AnotherInterestingClassName {
foo: Int
}
local function resourceMapping(type): Mapping<String, unknown> =
new Mapping { default = (key) -> (type) { metadata { name = key } } }
local const function biiiiiiiiiiiiiiiiiiiiiiiiigFunction(param1: String, param2: String(!isBlank)): Boolean
local const function someFunction(param1: String, param2: String(!isBlank)): Boolean
local function render(currentIndent: String) =
"\(currentIndent)@\(identifier.render(currentIndent))" +
if (body == null) "" else " " + body.render(currentIndent)

View File

@@ -0,0 +1,20 @@
module reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly.loooooooooooooooooooooooooooooooog.naaaaaaaaaaaaaaaaaaaaaaaaaame
extends "reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl"
import "reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl" as foo
local open class LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName {}
local open class ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongName {}
const hidden loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName = 99
const hidden reallyLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName = 99
const local function looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName(x: Int, y) = x + y
typealias Foo = LooooooooooooooooooooooooongTypeName|AnotherLooooooooooooooooooooooooongTypeName|OtherLooooooooooooooooooooooooongTypeName
bar: Boolean|Mapping<LooooooooooooooooooooooooooooongTypeName, AnotherLooooooooooooooooooooooooooooongTypeName>(loooooooooooooooooooogConstraint)
hidden foobar: LongType(someVeryyyyyyyloooong, requirements.might.be.even_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger)

View File

@@ -0,0 +1,18 @@
module reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly.loooooooooooooooooooooooooooooooog.naaaaaaaaaaaaaaaaaaaaaaaaaaaaame
extends "reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl"
local reallyLongVariableName = true
local anotherReallyLongName = 1
local evenLongerVariableName = 2
/// this property has a reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly long doc comment
property = if (reallyLongVariableName) anotherReallyLongName else evenLongerVariableName + anotherReallyLongName
longString = "reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly long string"
shortProperty = 1
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongVariableName = 10
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongVariableName2 =
if (reallyLongVariableName) anotherReallyLongName else evenLongerVariableName + anotherReallyLongName

View File

@@ -0,0 +1,4 @@
foo = Map(1000, "some random string", 20000, "another random string", 30000, "yet another random string")
incorrect = Map("This has", 1000000, "an incorrect number", 2000000, "of parameters", 30000000, "passed to Map")

View File

@@ -0,0 +1,3 @@
hidden const foo = 1
open local class Foo {}

View File

@@ -0,0 +1,13 @@
// comment
// one
/// doc comment
open
module
foo
.bar
amends
"baz.pkl"

View File

@@ -0,0 +1,29 @@
foo = """
asd \(new {
bar = 1
}) asd
"""
bar = """
line 1
line 2
line3
"""
baz = """
\n
\(bar)
line
\u{123}
"""
// remove unneeded spaces
qux = """
foo
bar
baz
\(foo)
"""

View File

@@ -0,0 +1,22 @@
foo: Listing<Int> = new {1 2 3; 4;5 6 7}
bar: Listing<Int> = new { 1 2
3
4
}
lineIsTooBig: Listing<Int> = new { 999999; 1000000; 1000001; 1000002; 1000003; 1000004; 1000005; 1000006; 1000007; 1000008; 1000009 }
lineIsTooBig2 { 999999; 1000000; 1000001; 1000002; 1000003; 1000004; 1000005; 1000006; 1000007; 1000008; 1000009; 1000010 }
baz = new Dynamic {
1 2
3 4
["foo"] = 3; bar = 30
baz = true
}
qux = new Dynamic {1 2 3 prop="prop"; [0]=9}

View File

@@ -0,0 +1,12 @@
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
typealias Foo = String
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
foo = "should fit in a single line"
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
function bar(x): String = "result: \(x)"

View File

@@ -0,0 +1,23 @@
import"foo.pkl"
bar=new Listing < Int > ( !isEmpty ){1;2}//a bar
typealias Typealias=(String,Int)->Boolean
///a baz
///returns its parameter
baz = (x,y,z)->x+y+z
function fun ( x:Int ? ,b :Boolean )= if(b)/***return x**/x else x+bar [0 ]
prop = trace (1) + super . foo + module .foo
prop2 {
for(x in List(1)) {
when(x == 1){
x
}
}
}
choices: "foo" | * "bar" | String

View File

@@ -0,0 +1,6 @@
typealias
Foo
=
String
typealias VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongTypeAlias = String(!isEmpty)

View File

@@ -0,0 +1,9 @@
foo {
when (true)
{
bar = 1
}
else {
bar = 2
}
}

View File

@@ -0,0 +1,11 @@
class Foo {}
class Bar {
qux = 1
}
class Baz {
prop = 0
prop2 = 1
}

View File

@@ -0,0 +1,35 @@
function fun(a, b, c, d) = a
noTrailingCommas = fun(1, 2, 3, 4)
trailingCommas =
fun(
"loooooooooooooooooooongString",
"loooooooooooooooongString",
"looooooooooooooooongString",
"notTooLong",
)
noTrailingCommaObjParams {
fooooooooooooooooooooooooooooooooo,
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaaz ->
1 + 1
}
trailingCommaInLambdas = (
fooooooooooooooooooooooooooooooooo,
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaaz,
) -> 1
trailingCommaInConstraints: String(
isSomethingSomethingSomething,
isSomethingElse,
isSomethingSomethingSomethingElse,
)
trailingCommaInTypeParameters: Mapping<
SomethingSomethingSomethingSomething,
SomethingSomething | SomethingElse,
>

View File

@@ -0,0 +1,34 @@
module comment.interleaved
local test: Int | String =
if (true)
1 // It's the same as "100%"
else
"8%"
foo: ( // some comment
*String(
// if dtstart is defined and a datetime, until must also be a datetime if defined
true,
)
| Int
// trailing comment
)?
foo2: ( // some comment
Int, // other comment
String,
) ->
Int
bar =
( // some comment
10 + 10
// another comment
)
bar2 = ( // some comment
foo,
bar
// another comment
) -> foo + bar

View File

@@ -0,0 +1,8 @@
module dangling
/// Doc comment.
///
/// for this field
// sepearted by a stray comment
/// but continues here.
some: String

View File

@@ -0,0 +1,13 @@
/// / line 1
/// // line 2
foo = 1
/// line 1
///
///
/// line 2
bar = 1
/// line 1
/// line 2
baz = 1

View File

@@ -0,0 +1,34 @@
foo {
123123123123
+ 123123123123 * 123123123123 -
123123123123 / 123123123123
+ 123123123123 ** 123123123123
2
3
4
}
bar =
clazz.superclass == null
|| clazz.superclass.reflectee == Module
|| clazz.superclass.reflectee == Typed
baz =
new Listing {
1
2
}
|> mixin1
|> mixin2
qux = (baz) {
1
2
} {
3
4
}
minus =
superLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongVariable -
100000

View File

@@ -0,0 +1,8 @@
res =
myList
.map((it) -> it.partition)
.filter((it) -> someList.contains(it))
res2 = myList.map(lambda1).filter(lambda2)
res3 = myList.map((it) -> it.partition)

View File

@@ -0,0 +1,9 @@
foo =
if (someCondition)
10000
else if (someOtherCondition)
20000
else if (someAnotherCondition)
30000
else
4

View File

@@ -0,0 +1,18 @@
foo =
let (vaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaariable =
10
)
1 * 1
bar =
let (someVariable = new Listing {
1
}
)
1 * 1
baz =
let (someVariable = 10000000)
let (someOtherVariable = 2000000)
let (someAnotherVariable = 3000000)
someVariable + someOtherVariable + someAnotherVariable

View File

@@ -0,0 +1,21 @@
// top level comment
import "https://example.com/baz.pkl"
import "package://example.com/myPackage@1.0.0#/Qux.pkl"
import "pkl:math"
import "pkl:reflect"
import "@bar/Bar.pkl"
import "@foo/Foo.pkl" as foo
import "..."
import "module1.pkl"
import "module2.pkl"
import "module11.pkl"
import "Module12.pkl"
import* "file:///tmp/*.pkl"
import* "@foo/**.pkl"
import* "**.pkl"

View File

@@ -0,0 +1,61 @@
foo = new {
bar = 1
}
class Foo {
baz: Int
}
bar = new Listing {
1
2
}
baz = (foo) {
2
3
}
qux = (x, y) -> new Listing {
x
y
}
forGen = new Listing {
for (
someVar in new Listing {
1
2
}
) {
[someVar] = someVar
}
}
objParams: Listing<Int> = new {
default { key ->
key + 1
}
}
objParams2: Listing<Int> = new {
default {
someVeryLongParameter1,
someVeryLongParameter2,
someVeryLongParameter3,
someVeryLongParameter4 ->
1
}
}
parenType: (
ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType(
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalylongConstraint,
)
)
functionType: (
ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType,
ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongType2,
) ->
String

View File

@@ -0,0 +1,75 @@
module foo.bar.baz
amends "bar.pkl"
import "@foo/Foo.pkl" as foo
open local class Bar {}
local const baz = 10
local function fun(x) = x
local const prooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooperty: String =
"foo"
local function function2(
parameter1: Parameter1Type,
parameter2: Parameter2Type,
parameter3: Parameter3Type,
parameter4: Parameter4Type,
): String = ""
local const function function3(
parameter1: String | Int,
parameter2: String | Int,
): Mapping<String | Int, String> = new {}
prop =
function2(
loooooooooooooooooogParameter1,
loooooooooooooooooogParameter2,
loooooooooooooooooogParameter3,
loooooooooooooooooogParameter4,
)
prop2: String | Int | Boolean
funcParam =
fun((x, y) -> new Listing {
x
y
})
funcParam2 =
aFun(foo, 10 * 10, anotherVariable, if (true) 100000 else 200000, (param1, param2) ->
param1 * param2
)
funcParam3 = aFun(foo, 10 * 10, anotherVariable, 200000, (param1, param2) -> param1 * param2)
funcParam4 =
aFun(foo, 10 * 10, anotherVariable, if (true) 100000 else 200000, new Listing {
1
2
})
open local class SomeReallyInterestingClassName<in SomeInParameter, out SomeOutParameter>
extends AnotherInterestingClassName {
foo: Int
}
local function resourceMapping(type): Mapping<String, unknown> = new Mapping {
default = (key) -> (type) { metadata { name = key } }
}
local const function biiiiiiiiiiiiiiiiiiiiiiiiigFunction(
param1: String,
param2: String(!isBlank),
): Boolean
local const function someFunction(param1: String, param2: String(!isBlank)): Boolean
local function render(currentIndent: String) =
"\(currentIndent)@\(identifier.render(currentIndent))"
+ if (body == null) "" else " " + body.render(currentIndent)

View File

@@ -0,0 +1,42 @@
module
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly
.loooooooooooooooooooooooooooooooog
.naaaaaaaaaaaaaaaaaaaaaaaaaame
extends
"reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl"
import
"reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl"
as foo
open local class LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName {}
open local class ReaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongName {}
hidden const loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName =
99
hidden const reallyLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName =
99
local const function looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName(
x: Int,
y,
) = x + y
typealias Foo =
LooooooooooooooooooooooooongTypeName
| AnotherLooooooooooooooooooooooooongTypeName
| OtherLooooooooooooooooooooooooongTypeName
bar: Boolean
| Mapping<
LooooooooooooooooooooooooooooongTypeName,
AnotherLooooooooooooooooooooooooooooongTypeName,
>(loooooooooooooooooooogConstraint)
hidden foobar: LongType(
someVeryyyyyyyloooong,
requirements.might.be.even_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooonger,
)

View File

@@ -0,0 +1,32 @@
module
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly
.loooooooooooooooooooooooooooooooog
.naaaaaaaaaaaaaaaaaaaaaaaaaaaaame
extends
"reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongModule.pkl"
local reallyLongVariableName = true
local anotherReallyLongName = 1
local evenLongerVariableName = 2
/// this property has a reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly long doc comment
property =
if (reallyLongVariableName)
anotherReallyLongName
else
evenLongerVariableName + anotherReallyLongName
longString =
"reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly long string"
shortProperty = 1
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongVariableName =
10
reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalyLongVariableName2 =
if (reallyLongVariableName)
anotherReallyLongName
else
evenLongerVariableName + anotherReallyLongName

View File

@@ -0,0 +1,14 @@
foo =
Map(
1000, "some random string",
20000, "another random string",
30000, "yet another random string",
)
incorrect =
Map(
"This has", 1000000,
"an incorrect number", 2000000,
"of parameters", 30000000,
"passed to Map",
)

View File

@@ -0,0 +1,3 @@
hidden const foo = 1
open local class Foo {}

View File

@@ -0,0 +1,7 @@
// comment
// one
/// doc comment
open module foo.bar
amends "baz.pkl"

View File

@@ -0,0 +1,33 @@
foo =
"""
asd \(new {
bar = 1
}) asd
"""
bar =
"""
line 1
line 2
line3
"""
baz =
"""
\n
\(bar)
line
\u{123}
"""
// remove unneeded spaces
qux =
"""
foo
bar
baz
\(foo)
"""

View File

@@ -0,0 +1,51 @@
foo: Listing<Int> = new { 1; 2; 3; 4; 5; 6; 7 }
bar: Listing<Int> = new {
1
2
3
4
}
lineIsTooBig: Listing<Int> = new {
999999
1000000
1000001
1000002
1000003
1000004
1000005
1000006
1000007
1000008
1000009
}
lineIsTooBig2 {
999999
1000000
1000001
1000002
1000003
1000004
1000005
1000006
1000007
1000008
1000009
1000010
}
baz = new Dynamic {
1
2
3
4
["foo"] = 3
bar = 30
baz = true
}
qux = new Dynamic { 1; 2; 3; prop = "prop"; [0] = 9 }

View File

@@ -0,0 +1,11 @@
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
typealias Foo = String
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
foo = "should fit in a single line"
/// Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong doc comment
@Annotation { looooooooooooooooooooooooooooooooooooooooooooooooooongVariableName = 10 }
function bar(x): String = "result: \(x)"

View File

@@ -0,0 +1,23 @@
import "foo.pkl"
bar = new Listing<Int>(!isEmpty) { 1; 2 } //a bar
typealias Typealias = (String, Int) -> Boolean
/// a baz
/// returns its parameter
baz = (x, y, z) -> x + y + z
function fun(x: Int?, b: Boolean) = if (b) /***return x**/ x else x + bar[0]
prop = trace(1) + super.foo + module.foo
prop2 {
for (x in List(1)) {
when (x == 1) {
x
}
}
}
choices: "foo" | *"bar" | String

View File

@@ -0,0 +1,4 @@
typealias Foo = String
typealias VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongTypeAlias =
String(!isEmpty)

View File

@@ -0,0 +1,7 @@
foo {
when (true) {
bar = 1
} else {
bar = 2
}
}