KCL: User-defined KCL functions in examples etc now use keywords (#6603)

Preparing for the removal of positional functions from the language. The first big step is to change all our KCL code examples, test code, public samples etc to all use keyword functions.

Apologies for how large this PR is. Most of it is:

- Changing example KCL that defined its own functions, so the functions now use keyword arguments rather than positional arguments. E.g. change `cube([20, 20])` to be `cube(center = [20, 20])`.
- Some parts of the code assumed positional code and didn't handle keyword calls, e.g. the linter would only check for positional calls to startSketchOn. Now they should work with either positional or keyword.
- Update all the artifacts

This does _not_ remove support for positional calls. That will be in a follow-up PR.
This commit is contained in:
Adam Chalmers
2025-05-01 11:36:51 -05:00
committed by GitHub
parent 16f5d9c284
commit 89bae66257
254 changed files with 32085 additions and 20108 deletions

View File

@ -895,7 +895,7 @@ async fn test_kcl_lsp_on_hover() {
foo = 42
foo
fn bar(x: string): string {
fn bar(@x: string): string {
return x
}
@ -971,7 +971,7 @@ startSketchOn(XY)
match hover.unwrap().contents {
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
assert!(value.contains("bar(x: string): string"));
assert!(value.contains("bar(@x: string): string"));
}
_ => unreachable!(),
}
@ -2027,7 +2027,7 @@ insideRevolve = startSketchOn(XZ)
|> line(end = [0, -thickness])
|> line(end = [-overHangLength, 0])
|> close()
|> revolve({ axis = Y }, %)
|> revolve(axis = Y)
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
sphere = startSketchOn(XZ)
@ -2035,7 +2035,7 @@ sphere = startSketchOn(XZ)
|> line(end = [sphereDia - 0.1, 0])
|> arc(angle_start = 0, angle_end = -180, radius = sphereDia / 2 - 0.05)
|> close()
|> revolve({ axis = X }, %)
|> revolve(axis = X)
|> patternCircular3d(
axis = [0, 0, 1],
center = [0, 0, 0],
@ -2056,7 +2056,7 @@ outsideRevolve = startSketchOn(XZ)
|> line(end = [0, thickness])
|> line(end = [overHangLength - thickness, 0])
|> close()
|> revolve({ axis = Y }, %)"#
|> revolve(axis = Y)"#
.to_string(),
},
})
@ -2090,7 +2090,7 @@ outsideRevolve = startSketchOn(XZ)
start: tower_lsp::lsp_types::Position { line: 0, character: 0 },
end: tower_lsp::lsp_types::Position {
line: 50,
character: 29
character: 22
}
}
);
@ -2117,7 +2117,7 @@ insideRevolve = startSketchOn(XZ)
|> line(end = [0, -thickness])
|> line(end = [-overHangLength, 0])
|> close()
|> revolve({ axis = Y }, %)
|> revolve(axis = Y)
// Sketch and revolve one of the balls and duplicate it using a circular pattern. (This is currently a workaround, we have a bug with rotating on a sketch that touches the rotation axis)
sphere = startSketchOn(XZ)
@ -2128,7 +2128,7 @@ sphere = startSketchOn(XZ)
|> line(end = [sphereDia - 0.1, 0])
|> arc(angle_start = 0, angle_end = -180, radius = sphereDia / 2 - 0.05)
|> close()
|> revolve({ axis = X }, %)
|> revolve(axis = X)
|> patternCircular3d(
axis = [0, 0, 1],
center = [0, 0, 0],
@ -2152,7 +2152,7 @@ outsideRevolve = startSketchOn(XZ)
|> line(end = [0, thickness])
|> line(end = [overHangLength - thickness, 0])
|> close()
|> revolve({ axis = Y }, %)"#
|> revolve(axis = Y)"#
);
}
@ -3891,7 +3891,7 @@ async fn test_kcl_lsp_on_hover_untitled_file_scheme() {
foo = 42
foo
fn bar(x: string): string {
fn bar(@x: string): string {
return x
}
@ -3967,7 +3967,7 @@ startSketchOn(XY)
match hover.unwrap().contents {
tower_lsp::lsp_types::HoverContents::Markup(tower_lsp::lsp_types::MarkupContent { value, .. }) => {
assert!(value.contains("bar(x: string): string"));
assert!(value.contains("bar(@x: string): string"));
}
_ => unreachable!(),
}