KCL: Make shell stdlib fn use keyword arguments (#5293)
Before: ``` shell({ faces = ['end'], thickness = caseThickness }, case) ``` After: ``` shell(case, faces = ['end'], thickness = caseThickness) ```
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4681
docs/kcl/std.json
4681
docs/kcl/std.json
File diff suppressed because it is too large
Load Diff
@ -1890,7 +1890,7 @@ chamfer04 = chamfer({ length = 5, tags = [getOppositeEdge(seg02)]}, extrude001
|
||||
const testPoint = { x: 575, y: 200 }
|
||||
const [clickOnCap] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
|
||||
const shellDeclaration =
|
||||
"shell001 = shell({ faces = ['end'], thickness = 5 }, extrude001)"
|
||||
"shell001 = shell(extrude001, faces = ['end'], thickness = 5)"
|
||||
|
||||
await test.step(`Look for the grey of the shape`, async () => {
|
||||
await scene.expectPixelColor([127, 127, 127], testPoint, 15)
|
||||
@ -1990,8 +1990,7 @@ extrude001 = extrude(sketch001, length = 40)
|
||||
const [clickOnWall] = scene.makeMouseHelpers(testPoint.x, testPoint.y + 70)
|
||||
const mutatedCode = 'xLine(-40, %, $seg01)'
|
||||
const shellDeclaration =
|
||||
"shell001 = shell({ faces = ['end', seg01], thickness = 5}, extrude001)"
|
||||
const formattedOutLastLine = '}, extrude001)'
|
||||
"shell001 = shell(extrude001, faces = ['end', seg01], thickness = 5)"
|
||||
|
||||
await test.step(`Look for the grey of the shape`, async () => {
|
||||
await scene.expectPixelColor([99, 99, 99], testPoint, 15)
|
||||
@ -2034,7 +2033,7 @@ extrude001 = extrude(sketch001, length = 40)
|
||||
await editor.expectEditor.toContain(shellDeclaration)
|
||||
await editor.expectState({
|
||||
diagnostics: [],
|
||||
activeLines: [formattedOutLastLine],
|
||||
activeLines: [shellDeclaration],
|
||||
highlightedCode: '',
|
||||
})
|
||||
await scene.expectPixelColor([49, 49, 49], testPoint, 15)
|
||||
@ -2088,9 +2087,8 @@ extrude002 = extrude(sketch002, length = 50)
|
||||
// One dumb hardcoded screen pixel value
|
||||
const testPoint = { x: 550, y: 295 }
|
||||
const [clickOnCap] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
|
||||
const shellDeclaration = `shell001 = shell({ faces = ['end'], thickness = 5 }, ${
|
||||
hasExtrudesInPipe ? 'sketch002' : 'extrude002'
|
||||
})`
|
||||
const shellTarget = hasExtrudesInPipe ? 'sketch002' : 'extrude002'
|
||||
const shellDeclaration = `shell001 = shell(${shellTarget}, faces = ['end'], thickness = 5)`
|
||||
|
||||
await test.step(`Look for the grey of the shape`, async () => {
|
||||
await toolbar.closePane('code')
|
||||
|
@ -253,7 +253,7 @@ extrude001 = extrude(sketch001, length = 50)
|
||||
|>
|
||||
|
||||
example = extrude(exampleSketch, length = 5)
|
||||
shell({ faces: ['end'], thickness: 0.25 }, exampleSketch)`
|
||||
shell(exampleSketch, faces = ['end'], thickness = 0.25)`
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
"fmt": "prettier --write ./src *.ts *.json *.js ./e2e ./packages",
|
||||
"fmt-check": "prettier --check ./src *.ts *.json *.js ./e2e ./packages",
|
||||
"fetch:wasm": "./get-latest-wasm-bundle.sh",
|
||||
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/kcl-samples/main/manifest.json",
|
||||
"fetch:samples": "echo \"Fetching latest KCL samples...\" && curl -o public/kcl-samples-manifest-fallback.json https://raw.githubusercontent.com/KittyCAD/kcl-samples/achalmers/kw-shell/manifest.json",
|
||||
"isomorphic-copy-wasm": "(copy src/wasm-lib/pkg/wasm_lib_bg.wasm public || cp src/wasm-lib/pkg/wasm_lib_bg.wasm public)",
|
||||
"build:wasm-dev": "yarn wasm-prep && (cd src/wasm-lib && wasm-pack build --dev --target web --out-dir pkg && cargo test -p kcl-lib export_bindings) && yarn isomorphic-copy-wasm && yarn fmt",
|
||||
"build:wasm": "yarn wasm-prep && cd src/wasm-lib && wasm-pack build --release --target web --out-dir pkg && cargo test -p kcl-lib export_bindings && cd ../.. && yarn isomorphic-copy-wasm && yarn fmt",
|
||||
|
@ -28,7 +28,14 @@ try {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
child_process.spawnSync('git', ['clone', URL_GIT_KCL_SAMPLES, DIR_KCL_SAMPLES])
|
||||
child_process.spawnSync('git', [
|
||||
'clone',
|
||||
'--single-branch',
|
||||
'--branch',
|
||||
'achalmers/kw-shell',
|
||||
URL_GIT_KCL_SAMPLES,
|
||||
DIR_KCL_SAMPLES,
|
||||
])
|
||||
|
||||
// @ts-expect-error
|
||||
let files = await fs.readdir(DIR_KCL_SAMPLES)
|
||||
|
@ -17,6 +17,8 @@ import {
|
||||
createObjectExpression,
|
||||
createArrayExpression,
|
||||
createVariableDeclaration,
|
||||
createCallExpressionStdLibKw,
|
||||
createLabeledArg,
|
||||
} from 'lang/modifyAst'
|
||||
import { KCL_DEFAULT_CONSTANT_PREFIXES } from 'lib/constants'
|
||||
import { KclManager } from 'lang/KclSingleton'
|
||||
@ -121,13 +123,14 @@ export function addShell({
|
||||
}
|
||||
|
||||
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SHELL)
|
||||
const shell = createCallExpressionStdLib('shell', [
|
||||
createObjectExpression({
|
||||
faces: createArrayExpression(expressions),
|
||||
thickness,
|
||||
}),
|
||||
const shell = createCallExpressionStdLibKw(
|
||||
'shell',
|
||||
createIdentifier(extrudeNode.node.id.name),
|
||||
])
|
||||
[
|
||||
createLabeledArg('faces', createArrayExpression(expressions)),
|
||||
createLabeledArg('thickness', thickness),
|
||||
]
|
||||
)
|
||||
const declaration = createVariableDeclaration(name, shell)
|
||||
|
||||
// TODO: check if we should append at the end like here or right after the extrude
|
||||
@ -137,8 +140,7 @@ export function addShell({
|
||||
[modifiedAst.body.length - 1, 'index'],
|
||||
['declaration', 'VariableDeclaration'],
|
||||
['init', 'VariableDeclarator'],
|
||||
['arguments', 'CallExpression'],
|
||||
[0, 'index'],
|
||||
['unlabeled', 'CallExpressionKw'],
|
||||
]
|
||||
return {
|
||||
modifiedAst,
|
||||
|
@ -242,7 +242,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, ctx, _) = parse_execute(new).await.unwrap();
|
||||
|
||||
@ -273,7 +273,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
@ -285,7 +285,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program_old, ctx, _) = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -318,7 +318,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
@ -330,7 +330,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, ctx, _) = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -363,7 +363,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch) "#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
@ -375,7 +375,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, ctx, _) = parse_execute(old).await.unwrap();
|
||||
|
||||
@ -409,7 +409,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||
|
||||
@ -451,7 +451,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||
|
||||
@ -486,7 +486,7 @@ firstSketch = startSketchOn('XY')
|
||||
|> extrude(length = 6)
|
||||
|
||||
// Remove the end face for the extrusion.
|
||||
shell({ faces = ['end'], thickness = 0.25 }, firstSketch)"#;
|
||||
shell(firstSketch, faces = ['end'], thickness = 0.25)"#;
|
||||
|
||||
let (program, mut ctx, _) = parse_execute(new).await.unwrap();
|
||||
|
||||
|
@ -1590,10 +1590,10 @@ let w = f() + f()
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> extrude(length = 40.14)
|
||||
|> shell({
|
||||
faces: [seg01],
|
||||
thickness: 3.14,
|
||||
}, %)
|
||||
|> shell(
|
||||
thickness = 3.14,
|
||||
faces = [seg01]
|
||||
)
|
||||
"#;
|
||||
|
||||
let ctx = crate::test_server::new_context(UnitLength::Mm, true, None)
|
||||
@ -1620,10 +1620,10 @@ let w = f() + f()
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> extrude(length = 40.14)
|
||||
|> shell({
|
||||
faces: [seg01],
|
||||
thickness: 3.14,
|
||||
}, %)
|
||||
|> shell(
|
||||
faces = [seg01],
|
||||
thickness = 3.14,
|
||||
)
|
||||
"#;
|
||||
|
||||
// Execute a slightly different program again.
|
||||
|
@ -120,10 +120,11 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
|
||||
/// |> close()
|
||||
/// |> extrude(length = 6)
|
||||
///
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// |> appearance({
|
||||
/// color = '#ff0000',
|
||||
/// metalness = 90,
|
||||
@ -147,10 +148,11 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result<KclVa
|
||||
/// roughness = 90
|
||||
/// }, %)
|
||||
///
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
|
@ -1019,15 +1019,6 @@ impl<'a> FromKclValue<'a> for super::sketch::BezierData {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::shell::ShellData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, thickness);
|
||||
let_field_of!(obj, faces);
|
||||
Some(Self { thickness, faces })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromKclValue<'a> for super::chamfer::ChamferData {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
|
@ -4,8 +4,6 @@ use anyhow::Result;
|
||||
use derive_docs::stdlib;
|
||||
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, ModelingCmd};
|
||||
use kittycad_modeling_cmds as kcmc;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
@ -13,22 +11,13 @@ use crate::{
|
||||
std::{sketch::FaceTag, Args},
|
||||
};
|
||||
|
||||
/// Data for shells.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ShellData {
|
||||
/// The thickness of the shell.
|
||||
pub thickness: f64,
|
||||
/// The faces you want removed.
|
||||
pub faces: Vec<FaceTag>,
|
||||
}
|
||||
|
||||
/// Create a shell.
|
||||
pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let (data, solid_set): (ShellData, SolidSet) = args.get_data_and_solid_set()?;
|
||||
let solid_set = args.get_unlabeled_kw_arg("solidSet")?;
|
||||
let thickness = args.get_kw_arg("thickness")?;
|
||||
let faces = args.get_kw_arg("faces")?;
|
||||
|
||||
let result = inner_shell(data, solid_set, exec_state, args).await?;
|
||||
let result = inner_shell(solid_set, thickness, faces, exec_state, args).await?;
|
||||
Ok(result.into())
|
||||
}
|
||||
|
||||
@ -47,10 +36,11 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 6)
|
||||
///
|
||||
/// // Remove the end face for the extrusion.
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['end'],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -64,10 +54,11 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 6)
|
||||
///
|
||||
/// // Remove the start face for the extrusion.
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = ['start'],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -81,10 +72,11 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 6)
|
||||
///
|
||||
/// // Remove a tagged face for the extrusion.
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = [myTag],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -98,10 +90,11 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 6)
|
||||
///
|
||||
/// // Remove a tagged face and the end face for the extrusion.
|
||||
/// shell({
|
||||
/// shell(
|
||||
/// firstSketch,
|
||||
/// faces = [myTag, 'end'],
|
||||
/// thickness = 0.25,
|
||||
/// }, firstSketch)
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -124,7 +117,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "case" in the shell function to shell the entire object.
|
||||
/// shell({ faces = ['start'], thickness = 5 }, case)
|
||||
/// shell(case, faces = ['start'], thickness = 5)
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -147,7 +140,7 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "thing1" in the shell function to shell the end face of the object.
|
||||
/// shell({ faces = ['end'], thickness = 5 }, thing1)
|
||||
/// shell(thing1, faces = ['end'], thickness = 5)
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
@ -172,21 +165,29 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> extrude(length = 50)
|
||||
///
|
||||
/// // We put "thing1" and "thing2" in the shell function to shell the end face of the object.
|
||||
/// shell({ faces = ['end'], thickness = 5 }, [thing1, thing2])
|
||||
/// shell([thing1, thing2], faces = ['end'], thickness = 5)
|
||||
/// ```
|
||||
#[stdlib {
|
||||
name = "shell",
|
||||
feature_tree_operation = true,
|
||||
keywords = true,
|
||||
unlabeled_first = true,
|
||||
args = {
|
||||
solid_set = { docs = "Which solid (or solids) to shell out"},
|
||||
thickness = {docs = "The thickness of the shell"},
|
||||
faces = {docs = "The faces you want removed"},
|
||||
}
|
||||
}]
|
||||
async fn inner_shell(
|
||||
data: ShellData,
|
||||
solid_set: SolidSet,
|
||||
thickness: f64,
|
||||
faces: Vec<FaceTag>,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<SolidSet, KclError> {
|
||||
if data.faces.is_empty() {
|
||||
if faces.is_empty() {
|
||||
return Err(KclError::Type(KclErrorDetails {
|
||||
message: "Expected at least one face".to_string(),
|
||||
message: "You must shell at least one face".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
}
|
||||
@ -194,7 +195,7 @@ async fn inner_shell(
|
||||
let solids: Vec<Box<Solid>> = solid_set.clone().into();
|
||||
if solids.is_empty() {
|
||||
return Err(KclError::Type(KclErrorDetails {
|
||||
message: "Expected at least one solid".to_string(),
|
||||
message: "You must shell at least one solid".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
}));
|
||||
}
|
||||
@ -205,7 +206,7 @@ async fn inner_shell(
|
||||
// If we do not do these for sketch on face, things will fail with face does not exist.
|
||||
args.flush_batch_for_solid_set(exec_state, solid.clone().into()).await?;
|
||||
|
||||
for tag in &data.faces {
|
||||
for tag in &faces {
|
||||
let extrude_plane_id = tag.get_face_id(solid, exec_state, &args, false).await?;
|
||||
|
||||
face_ids.push(extrude_plane_id);
|
||||
@ -235,7 +236,7 @@ async fn inner_shell(
|
||||
hollow: false,
|
||||
face_ids,
|
||||
object_id: solids[0].id,
|
||||
shell_thickness: LengthUnit(data.thickness),
|
||||
shell_thickness: LengthUnit(thickness),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
@ -2542,7 +2542,7 @@ snapshot_kind: text
|
||||
"cmdId": "[uuid]",
|
||||
"range": [
|
||||
2047,
|
||||
2110,
|
||||
2102,
|
||||
0
|
||||
],
|
||||
"command": {
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Result of parsing fillet-and-shell.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
@ -2582,50 +2583,39 @@ description: Result of parsing fillet-and-shell.kcl
|
||||
"type": "ExpressionStatement"
|
||||
},
|
||||
{
|
||||
"end": 2110,
|
||||
"end": 2102,
|
||||
"expression": {
|
||||
"arguments": [
|
||||
{
|
||||
"end": 2103,
|
||||
"properties": [
|
||||
{
|
||||
"end": 2072,
|
||||
"key": {
|
||||
"end": 2062,
|
||||
"name": "faces",
|
||||
"start": 2057,
|
||||
"type": "Identifier"
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"type": "Identifier",
|
||||
"name": "faces"
|
||||
},
|
||||
"start": 2057,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"arg": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 2071,
|
||||
"end": 2073,
|
||||
"raw": "'end'",
|
||||
"start": 2066,
|
||||
"start": 2068,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "end"
|
||||
}
|
||||
],
|
||||
"end": 2072,
|
||||
"start": 2065,
|
||||
"end": 2074,
|
||||
"start": 2067,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 2101,
|
||||
"key": {
|
||||
"end": 2085,
|
||||
"name": "thickness",
|
||||
"start": 2076,
|
||||
"type": "Identifier"
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"type": "Identifier",
|
||||
"name": "thickness"
|
||||
},
|
||||
"start": 2076,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"arg": {
|
||||
"end": 2101,
|
||||
"name": "caseThickness",
|
||||
"start": 2088,
|
||||
@ -2634,35 +2624,30 @@ description: Result of parsing fillet-and-shell.kcl
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 2053,
|
||||
"type": "ObjectExpression",
|
||||
"type": "ObjectExpression"
|
||||
},
|
||||
{
|
||||
"end": 2109,
|
||||
"name": "case",
|
||||
"start": 2105,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 2052,
|
||||
"name": "shell",
|
||||
"start": 2047,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 2110,
|
||||
"end": 2102,
|
||||
"start": 2047,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"end": 2057,
|
||||
"name": "case",
|
||||
"start": 2053,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
}
|
||||
},
|
||||
"start": 2047,
|
||||
"type": "ExpressionStatement",
|
||||
"type": "ExpressionStatement"
|
||||
}
|
||||
],
|
||||
"end": 2111,
|
||||
"end": 2103,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"1": [
|
||||
|
@ -74,7 +74,4 @@ m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLengt
|
||||
|
||||
m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), screwHeight)
|
||||
|
||||
shell({
|
||||
faces = ['end'],
|
||||
thickness = caseThickness
|
||||
}, case)
|
||||
shell(case, faces = ['end'], thickness = caseThickness)
|
||||
|
@ -402,17 +402,17 @@ snapshot_kind: text
|
||||
},
|
||||
{
|
||||
"labeledArgs": {
|
||||
"data": {
|
||||
"faces": {
|
||||
"sourceRange": [
|
||||
2053,
|
||||
2103,
|
||||
2067,
|
||||
2074,
|
||||
0
|
||||
]
|
||||
},
|
||||
"solid_set": {
|
||||
"thickness": {
|
||||
"sourceRange": [
|
||||
2105,
|
||||
2109,
|
||||
2088,
|
||||
2101,
|
||||
0
|
||||
]
|
||||
}
|
||||
@ -420,10 +420,16 @@ snapshot_kind: text
|
||||
"name": "shell",
|
||||
"sourceRange": [
|
||||
2047,
|
||||
2110,
|
||||
2102,
|
||||
0
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
"unlabeledArg": null
|
||||
"unlabeledArg": {
|
||||
"sourceRange": [
|
||||
2053,
|
||||
2057,
|
||||
0
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Artifact commands import_whole.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
@ -525,7 +526,7 @@ description: Artifact commands import_whole.kcl
|
||||
"cmdId": "[uuid]",
|
||||
"range": [
|
||||
83,
|
||||
130,
|
||||
123,
|
||||
0
|
||||
],
|
||||
"command": {
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Result of parsing import_whole.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
@ -26,7 +27,7 @@ description: Result of parsing import_whole.kcl
|
||||
},
|
||||
{
|
||||
"declaration": {
|
||||
"end": 130,
|
||||
"end": 123,
|
||||
"id": {
|
||||
"end": 71,
|
||||
"name": "bar",
|
||||
@ -45,49 +46,38 @@ description: Result of parsing import_whole.kcl
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"end": 126,
|
||||
"properties": [
|
||||
{
|
||||
"end": 106,
|
||||
"key": {
|
||||
"end": 96,
|
||||
"name": "faces",
|
||||
"start": 91,
|
||||
"type": "Identifier"
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"type": "Identifier",
|
||||
"name": "faces"
|
||||
},
|
||||
"start": 91,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"arg": {
|
||||
"elements": [
|
||||
{
|
||||
"end": 105,
|
||||
"end": 103,
|
||||
"raw": "'end'",
|
||||
"start": 100,
|
||||
"start": 98,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": "end"
|
||||
}
|
||||
],
|
||||
"end": 106,
|
||||
"start": 99,
|
||||
"end": 104,
|
||||
"start": 97,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"end": 124,
|
||||
"key": {
|
||||
"end": 117,
|
||||
"name": "thickness",
|
||||
"start": 108,
|
||||
"type": "Identifier"
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"type": "Identifier",
|
||||
"name": "thickness"
|
||||
},
|
||||
"start": 108,
|
||||
"type": "ObjectProperty",
|
||||
"value": {
|
||||
"end": 124,
|
||||
"arg": {
|
||||
"end": 122,
|
||||
"raw": "0.25",
|
||||
"start": 120,
|
||||
"start": 118,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
@ -97,30 +87,20 @@ description: Result of parsing import_whole.kcl
|
||||
}
|
||||
}
|
||||
],
|
||||
"start": 89,
|
||||
"type": "ObjectExpression",
|
||||
"type": "ObjectExpression"
|
||||
},
|
||||
{
|
||||
"end": 129,
|
||||
"start": 128,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"end": 88,
|
||||
"name": "shell",
|
||||
"start": 83,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"end": 130,
|
||||
"end": 123,
|
||||
"start": 83,
|
||||
"type": "CallExpression",
|
||||
"type": "CallExpression"
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"end": 130,
|
||||
"end": 123,
|
||||
"start": 74,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
@ -128,14 +108,14 @@ description: Result of parsing import_whole.kcl
|
||||
"start": 68,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 130,
|
||||
"end": 123,
|
||||
"kind": "const",
|
||||
"start": 68,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"end": 131,
|
||||
"end": 124,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
|
@ -2,4 +2,4 @@
|
||||
import "exported_mod.kcl" as foo
|
||||
|
||||
bar = foo
|
||||
|> shell({ faces = ['end'], thickness = 0.25 }, %)
|
||||
|> shell(faces = ['end'], thickness = 0.25)
|
||||
|
@ -1,21 +1,22 @@
|
||||
---
|
||||
source: kcl/src/simulation_tests.rs
|
||||
description: Operations executed import_whole.kcl
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
{
|
||||
"labeledArgs": {
|
||||
"data": {
|
||||
"faces": {
|
||||
"sourceRange": [
|
||||
89,
|
||||
126,
|
||||
97,
|
||||
104,
|
||||
0
|
||||
]
|
||||
},
|
||||
"solid_set": {
|
||||
"thickness": {
|
||||
"sourceRange": [
|
||||
128,
|
||||
129,
|
||||
118,
|
||||
122,
|
||||
0
|
||||
]
|
||||
}
|
||||
@ -23,7 +24,7 @@ description: Operations executed import_whole.kcl
|
||||
"name": "shell",
|
||||
"sourceRange": [
|
||||
83,
|
||||
130,
|
||||
123,
|
||||
0
|
||||
],
|
||||
"type": "StdLibCall",
|
||||
|
@ -75,7 +75,7 @@ m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLengt
|
||||
|
||||
m25Screw(border + rpizWidth / 2 + widthBetweenScrews / 2, 0 + border + rpizLength / 2 - (lengthBetweenScrews / 2), screwHeight)
|
||||
|
||||
shell({
|
||||
faces: ['end'],
|
||||
thickness: caseThickness
|
||||
}, case)
|
||||
shell(
|
||||
faces = ['end'],
|
||||
thickness = caseThickness
|
||||
)
|
||||
|
@ -1534,10 +1534,10 @@ async fn kcl_test_shell_with_tag() {
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> extrude(length = 40.14)
|
||||
|> shell({
|
||||
faces: [seg01],
|
||||
thickness: 3.14,
|
||||
}, %)
|
||||
|> shell(
|
||||
faces = [seg01],
|
||||
thickness = 3.14,
|
||||
)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap();
|
||||
@ -1998,10 +1998,10 @@ async fn kcl_test_error_no_auth_websocket() {
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
||||
|> extrude(length = 40.14)
|
||||
|> shell({
|
||||
faces: [seg01],
|
||||
thickness: 3.14,
|
||||
}, %)
|
||||
|> shell(
|
||||
faces = [seg01],
|
||||
thickness = 3.14,
|
||||
)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot_no_auth(code, UnitLength::Mm, None).await;
|
||||
|
Reference in New Issue
Block a user