Commit Graph

529 Commits

Author SHA1 Message Date
Jen Basch
7bf150055c Assert that formatter snippet test output is stable (#1270) 2025-10-29 17:08:43 -07:00
Jen Basch
1d6261b263 Correctly handle trailing commas in function type literals in the generic parser (#1267) 2025-10-29 15:08:26 -07:00
Islon Scherer
72874ec34a Get style guide in line with formatter (#1265) 2025-10-29 16:00:05 +01:00
Islon Scherer
28c20a8652 Don't break lines in module name (#1266) 2025-10-29 15:24:08 +01:00
Daniel Chao
bbeeffdd32 Adjust formatting of line comments in lets (#1256) 2025-10-28 17:53:06 -07:00
Daniel Chao
825fcf5d1d Respect newlines in if/else and let expressions (#1259)
Change the formatter to prevent multiline if/else and let expressions
from collapsing into a single line.
2025-10-28 11:26:31 -07:00
Daniel Chao
fbcf83aa76 Adjust formatting of argument lists (#1260)
This changes code so that multiple lambda arguments makes the whole
argument list wrap.

Improves the readability of code like:

```
foo
  .toMap(
    (it) -> makeSomeKey(it),
    (it) -> makeSomeValue(it)
  )
```
2025-10-28 10:46:19 -07:00
Islon Scherer
be0142d46b Add grammar compatibility option to the formatter (#1249) 2025-10-28 13:29:08 +01:00
Daniel Chao
ef4989aa35 Wrap comments in base.pkl to 100 chars (#1258)
Also, strip line numbers from reflectedDeclaration.pcf
2025-10-27 16:00:48 -07:00
Daniel Chao
1a25e044ac Polish documentation for pkl-binary (#1250) 2025-10-26 21:23:57 -07:00
Spencer Phillip Young
fdb2bd8c75 Fix Lexer EOF sentinel collision with valid Unicode code points (#1251)
Fixes an issue where sentinel value (U+7FFF) occurring literally in the source could cause a premature termination of parsing, leading to potential EOF injection attacks.

---------

Co-authored-by: Dan Chao <dan.chao@apple.com>
2025-10-26 15:53:48 -07:00
Daniel Chao
a8f76d6209 Adjust formatting of qualified access chains (#1252)
This adjusts formatting of qualified access chains so that leading
dot calls are kept in the same line if possible.
2025-10-24 16:48:21 -07:00
Daniel Chao
c7680aea1f Enforce Pkl formatting of stdlib with spotless (#1253)
This adds a spotless formatting step using the new pkl formatter.

This only formats Pkl sources in the stdlib, because other sources
are possibly test input and not meant to be formatted.
2025-10-24 10:15:14 -07:00
Daniel Chao
3223083324 Format interpolated expressions as single line (#1247)
This forces iterpolated expressions to be single-line, so that newline
literals within the bounds of two string delimiters can be seen as
verbatime newlines in the resulting string.

Edge case: in the case of a line comment, it's not possible to keep
this as a single line expression.
These are kept as multi-line expressions.

Also:

* Remove `ForceWrap`, this node is not used.
* Rename `StringConstant` -> `StringChars`
2025-10-24 03:23:41 -07:00
Daniel Chao
cce49a40fa Add internal intellij plugin (#1248)
This introduces an IntelliJ plugin that's meant to assist with development of the Pkl codebase itself.

The plugin adds a file editor that opens snippet tests in a split editor pane, showing the input on the left side and output on the right side.
2025-10-21 03:42:21 -07:00
Islon Scherer
f6d3fb1228 Fix let formatting (#1246) 2025-10-21 09:45:27 +02:00
Jen Basch
6c036bf82a Implement Pkl binary renderer and parser (#1203)
Implements a binary renderer for Pkl values, which is a lossless capturing of Pkl data.

This follows the pkl binary format that is already used with `pkl server` calls, and is
made available as a Java API and also an in-language API.

Also, introduces a binary parser into the corresponding `PObject` types in Java.
2025-10-20 09:10:22 -07:00
Jen Basch
c602dbb84c Fix macOS Intel native builds (#1244) 2025-10-16 19:20:14 -07:00
Jen Basch
bed008b3da Update macOS release in CI (#1243) 2025-10-16 15:48:23 -07:00
Daniel Chao
80a4dc9617 Fix typos (#1242) 2025-10-16 14:18:49 -07:00
Daniel Chao
b8aad85943 Fix tracking of known usages/subtypes (#1241)
Fixes an issue where known subtype/usage information is not gathered.

Also: change class RuntimeData to not return pairs for better composability.
2025-10-16 12:48:35 -07:00
Daniel Chao
91fec70668 Fix publication of pkl-config-kotlin (#1240)
This fixes a regression where the pkl-config-kotlin library would not
publish after upgrading to Gradle 9.1
2025-10-16 00:44:08 -07:00
Daniel Chao
8c5bd3b7dd Apply pkl formatter to codebase (#1236)
This applies the Pkl formatter to `stdlib/` and `.circleci/`
2025-10-09 15:16:38 -07:00
Daniel Chao
42dcad25c6 Fix error message when reading a resource/module past root dir (#1234) 2025-10-09 10:16:33 -07:00
Daniel Chao
3a29ea8998 Format lambda chains (#1235)
This changes the formatter to only force line on call chains
with multiple lambdas

With this change, this is kept as a single line:

```
foo.bar.map((it) -> it + 1)
```
2025-10-09 10:16:13 -07:00
Daniel Chao
98ab741c54 Bump Kotlin to 2.2.20, minimum Kotlin to 2.1 (#1232)
The current version of the kotlin-gradle plugin is not compatible with
Gradle 9.1, causing error `java.lang.NoSuchMethodError:
 'org.gradle.api.Project org.gradle.api.artifacts.ProjectDependency.getDependencyProject()'`

Also, the Kotlin 2.0 language target is deprecated as of Kotlin 2.2.
2025-10-08 21:40:35 -07:00
Jen Basch
ffa3c14fb3 Pass trace mode from CLI/PklProject to the evaluator (#1230) 2025-10-08 10:49:55 -07:00
Jen Basch
e230fcf1a9 Follow up for trace pretty printing (#1227) 2025-10-08 09:36:42 -07:00
Daniel Chao
cf9d87373d Bump Gradle to 9.1.0 (#1228)
* Bump Gradle to 9.1.0
* Bump foojay resolver to 1.0.0
* Fix build logic on windows

Also, remove support for kotlin gradle plugin less than 1.8.x, because:

* Class `org.gradle.api.plugins.Convention` is no longer available in the classpath in Gradle
* Continued support for legacy plugin would require heavy reflection, which is brittle and hard to verify
* Kotlin 1.7 is 3 years old and no longer updated
2025-10-08 08:54:43 -07:00
Daniel Chao
55eac2088b Bump GraalVM to 25.0.0 (#1226)
* Migrate shadow plugin to org.gradleup to correctly bundle Truffle in
  a fat jar
* Switch to GraalVM Community Edition
2025-10-07 21:23:15 -07:00
Steve Salevan
cecaf39aff Adds traceMode evaluator setting to support trace() pretty printing (#1100) 2025-10-07 12:31:16 -07:00
Daniel Chao
d03a074f63 Bump dependencies (#1225)
* byte-buddy to 1.17.7
* commonmark to 0.26

And also test dependencies (junit, assertj)
2025-10-04 13:59:54 -07:00
Daniel Chao
c585a40601 Fix pkl-doc native test (#1224) 2025-10-03 17:15:14 -07:00
Daniel Chao
2e77d44877 Disable multi-jdk testing when running on Windows ARM (#1223)
Gradle does not support Java toolchains on Windows ARM right now.
To enable running the project in this os/arch, we must omit multi-jdk
test tasks.
2025-10-03 10:36:25 -07:00
Daniel Chao
5d90cf8f4e Introduce pkl-doc model version 2 (#1169)
Currently, in order to update a pkl-doc documentation site,
almost the entire existing site is read in order to update metadata
like known versions, known subtypes, and more.

For example, adding a new version of a package requires that the
existing runtime data of all existing versions be updated.
Eventually, this causes the required storage size to balloon
exponentially to the number of versions.

This addresses these limitations by:

1. Updating the runtime data structure to move "known versions" metadata
   to the package level (the same JSON file is used for all versions).
2. Eliminating known subtype and known usage information at a
   cross-package level.
3. Generating the search index by consuming the previously generated
   search index.
4. Generating the main page by consuming the search index.

Because this changes how runtime data is stored, an existing docsite
needs to be migrated.

This also introduces a new migration command, `pkl-doc --migrate`,
which transforms an older version of the website into a newer version.
2025-09-29 16:10:44 -07:00
Jen Basch
63f89fb679 Expose collected superclass properties/methods in pkl:reflect (#1106) 2025-09-19 12:23:57 -07:00
Simon Rüegg
d1171db3d5 Only format changed files (#1217) 2025-09-19 15:16:32 +02:00
Simon Rüegg
f327c8e086 Allow formatting multiple files/directories (#1215)
This makes it easier to work with tools which return a list of file to
format, e.g. to only handle files which have changed in a PR.
2025-09-19 15:13:22 +02:00
Islon Scherer
618c6243c5 Fix bug in format apply (#1211) 2025-09-19 11:28:40 +02:00
Islon Scherer
222741dccd Fix broken test (#1208) 2025-09-17 13:53:15 -07:00
Islon Scherer
fdc501a35c Implement canonical formatter (#1107)
CLI commands also added: `pkl format check` and `pkl format apply`.
2025-09-17 11:12:04 +02:00
Vladimir Matveev
6a06ab7caa Fixed fallback certificates not working in certain classloader setups (#1198)
In the original implementation the `org/pkl/commons/cli/PklCARoots.pem` resource is resolved relatively to the classloader associated with the class returned by `javaClass`. However, since this is an extension method for `HttpClient.Builder`, it means calling `javaClass` on the builder instance, which is actually defined in the system classpath.

Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.

The solution is to resolve `javaClass` against `this@CliCommand`, to use the classloader which loaded the jar with the `CliCommand` class to find the CA resource.
2025-09-04 15:49:43 -07:00
Daniel Chao
a66ac0eb35 Refine documentation for class Any (#1194) 2025-09-02 08:19:39 -07:00
Jen Basch
bef0375285 Improve interrupt handling in pkl repl (#1188) 2025-08-29 13:39:49 -07:00
Jen Basch
44cc154501 Prepare 0.29.1 release (#1192)
Co-authored-by: Daniel Chao <dan.chao@apple.com>
2025-08-27 14:33:25 -07:00
Artem Yarmoliuk
af7057b75f Fix shell completion for paths (#1161) 2025-08-26 10:46:54 -07:00
Jen Basch
a8806416b9 Correctly handle EOF after unmatched backtick (#1187) 2025-08-25 14:31:26 -07:00
Jen Basch
b32039a4f1 Add me as a maintainer (#1185) 2025-08-25 13:17:53 -07:00
Daniel Chao
a779316cc2 Update dependencies (#1184)
Bump test dependencies, and also commonmark
2025-08-21 21:32:56 -07:00
Daniel Chao
d9db939bdc Fix missing resources in native pkldoc, and disable test mode (#1175)
This fixes two issues:

1. Test mode is enabled in pkldoc without the ability to turn it off
2. Native pkldoc is missing required resources

This also adds tests for both `jpkldoc` and `pkldoc`.
2025-08-21 06:44:13 -07:00