Compare commits
1 Commits
jtran/pars
...
remove-ext
Author | SHA1 | Date | |
---|---|---|---|
448403d4fa |
@ -256720,7 +256720,7 @@
|
||||
false
|
||||
],
|
||||
[
|
||||
"// Create a spring by sweeping around a helix path.\n\n// Create a helix around the Z axis.\nhelixPath = helix(\n angleStart = 0,\n ccw = true,\n revolutions = 4,\n length = 10,\n radius = 5,\n axis = Z,\n)\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn(XZ)\n |> circle(center = [5, 0], radius = 1)\n |> sweep(path = helixPath)",
|
||||
"// Create a spring by sweeping around a helix path.\n\n// Create a helix around the Z axis.\nhelixPath = helix(\n angleStart = 0,\n ccw = true,\n revolutions = 4,\n length = 10,\n radius = 5,\n axis = Z,\n)\n\n// Create a spring by sweeping around the helix path.\nspringSketch = startSketchOn(YZ)\n |> circle(center = [0, 0], radius = 1)\n |> sweep(path = helixPath, relativeTo = \"sketchPlane\")",
|
||||
false
|
||||
],
|
||||
[
|
||||
|
@ -267,75 +267,6 @@ test.describe('when using the file tree to', () => {
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'loading small file, then large, then back to small',
|
||||
{
|
||||
tag: '@electron',
|
||||
},
|
||||
async ({ page }, testInfo) => {
|
||||
const {
|
||||
panesOpen,
|
||||
pasteCodeInEditor,
|
||||
createNewFile,
|
||||
openDebugPanel,
|
||||
closeDebugPanel,
|
||||
expectCmdLog,
|
||||
} = await getUtils(page, test)
|
||||
|
||||
await page.setViewportSize({ width: 1200, height: 500 })
|
||||
page.on('console', console.log)
|
||||
|
||||
await panesOpen(['files', 'code'])
|
||||
await createProject({ name: 'project-000', page })
|
||||
|
||||
// Create a small file
|
||||
const kclCube = await fsp.readFile(
|
||||
'rust/kcl-lib/e2e/executor/inputs/cube.kcl',
|
||||
'utf-8'
|
||||
)
|
||||
// pasted into main.kcl
|
||||
await pasteCodeInEditor(kclCube)
|
||||
|
||||
// Create a large lego file
|
||||
await createNewFile('lego')
|
||||
const legoFile = page.getByRole('listitem').filter({
|
||||
has: page.getByRole('button', { name: 'lego.kcl' }),
|
||||
})
|
||||
await expect(legoFile).toBeVisible({ timeout: 60_000 })
|
||||
await legoFile.click()
|
||||
const kclLego = await fsp.readFile(
|
||||
'rust/kcl-lib/e2e/executor/inputs/lego.kcl',
|
||||
'utf-8'
|
||||
)
|
||||
await pasteCodeInEditor(kclLego)
|
||||
const mainFile = page.getByRole('listitem').filter({
|
||||
has: page.getByRole('button', { name: 'main.kcl' }),
|
||||
})
|
||||
|
||||
// Open settings and enable the debug panel
|
||||
await page
|
||||
.getByRole('link', {
|
||||
name: 'settings Settings',
|
||||
})
|
||||
.click()
|
||||
await page.locator('#showDebugPanel').getByText('OffOn').click()
|
||||
await page.getByTestId('settings-close-button').click()
|
||||
|
||||
await test.step('swap between small and large files', async () => {
|
||||
await openDebugPanel()
|
||||
// Previously created a file so we need to start back at main.kcl
|
||||
await mainFile.click()
|
||||
await expectCmdLog('[data-message-type="execution-done"]', 60_000)
|
||||
// Click the large file
|
||||
await legoFile.click()
|
||||
// Once it is building, click back to the smaller file
|
||||
await mainFile.click()
|
||||
await expectCmdLog('[data-message-type="execution-done"]', 60_000)
|
||||
await closeDebugPanel()
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test.describe('Renaming in the file tree', () => {
|
||||
|
@ -6,6 +6,7 @@ test.describe('Onboarding tests', () => {
|
||||
homePage,
|
||||
toolbar,
|
||||
editor,
|
||||
scene,
|
||||
tronApp,
|
||||
}) => {
|
||||
if (!tronApp) {
|
||||
@ -61,6 +62,7 @@ test.describe('Onboarding tests', () => {
|
||||
await editor.expectEditor.toContain('@settings(defaultLengthUnit = in)', {
|
||||
shouldNormalise: true,
|
||||
})
|
||||
await scene.connectionEstablished()
|
||||
})
|
||||
|
||||
await test.step('Go home and verify we still see the tutorial button, then begin it.', async () => {
|
||||
@ -130,7 +132,9 @@ test.describe('Onboarding tests', () => {
|
||||
})
|
||||
|
||||
await test.step('Dismiss the onboarding', async () => {
|
||||
await postDismissToast.waitFor({ state: 'hidden' })
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(postDismissToast).toBeVisible()
|
||||
await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
|
||||
await expect.poll(() => page.url()).not.toContain('/onboarding')
|
||||
})
|
||||
@ -158,10 +162,13 @@ test.describe('Onboarding tests', () => {
|
||||
await test.step('Gets to the onboarding start', async () => {
|
||||
await expect(toolbar.projectName).toContainText('tutorial-project')
|
||||
await expect(tutorialWelcomeHeading).toBeVisible()
|
||||
await scene.connectionEstablished()
|
||||
})
|
||||
|
||||
await test.step('Dismiss the onboarding', async () => {
|
||||
await postDismissToast.waitFor({ state: 'hidden' })
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(postDismissToast).toBeVisible()
|
||||
await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
|
||||
await expect.poll(() => page.url()).not.toContain('/onboarding')
|
||||
})
|
||||
|
@ -1,22 +1,19 @@
|
||||
@precedence {
|
||||
annotation
|
||||
typeCall
|
||||
member
|
||||
call
|
||||
exp @left
|
||||
mult @left
|
||||
add @left
|
||||
ascription @left
|
||||
comp @left
|
||||
logic @left
|
||||
pipe @left
|
||||
range
|
||||
statement
|
||||
}
|
||||
|
||||
@top Program {
|
||||
Shebang?
|
||||
(statement !statement statement*)?
|
||||
statement*
|
||||
}
|
||||
|
||||
statement[@isGroup=Statement] {
|
||||
@ -55,15 +52,12 @@ expression[@isGroup=Expression] {
|
||||
UnaryExpression { UnaryOp expression } |
|
||||
ParenthesizedExpression { "(" expression ")" } |
|
||||
IfExpression { kw<"if"> expression Body kw<"else"> Body } |
|
||||
// We don't currently support arbitrary expressions as the callee part of a
|
||||
// function call.
|
||||
CallExpression { identifier !call ArgumentList } |
|
||||
CallExpression { expression !call ArgumentList } |
|
||||
ArrayExpression { "[" commaSep<expression | IntegerRange { expression !range ".." expression }> "]" } |
|
||||
ObjectExpression { "{" commaSep<ObjectProperty> "}" } |
|
||||
MemberExpression { expression !member "." PropertyName } |
|
||||
SubscriptExpression { expression !member "[" expression "]" } |
|
||||
PipeExpression { expression (!pipe PipeOperator expression)+ } |
|
||||
AscribedExpression { expression !ascription ":" type }
|
||||
PipeExpression { expression (!pipe PipeOperator expression)+ }
|
||||
}
|
||||
|
||||
UnaryOp { AddOp | BangOp }
|
||||
@ -81,7 +75,7 @@ LabeledArgument { ArgumentLabel Equals expression }
|
||||
ArgumentList { "(" commaSep<LabeledArgument | expression> ")" }
|
||||
|
||||
type[@isGroup=Type] {
|
||||
PrimitiveType { identifier !typeCall ("(" identifier ")")? } |
|
||||
PrimitiveType { identifier } |
|
||||
ArrayType { "[" type !member (";" Number "+"?)? "]" } |
|
||||
ObjectType { "{" commaSep<ObjectProperty { PropertyName ":" type }> "}" }
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
# primitive
|
||||
|
||||
true: bool
|
||||
|
||||
==>
|
||||
Program(ExpressionStatement(AscribedExpression(true, ":", PrimitiveType)))
|
||||
|
||||
# numeric units
|
||||
|
||||
3.5: number(mm)
|
||||
|
||||
==>
|
||||
Program(ExpressionStatement(AscribedExpression(3.5, ":", PrimitiveType)))
|
@ -129,7 +129,6 @@ impl From<KclErrorWithOutputs> for KclError {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KclErrorWithOutputs {
|
||||
pub error: KclError,
|
||||
pub non_fatal: Vec<CompilationError>,
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
pub operations: Vec<Operation>,
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
@ -142,10 +141,8 @@ pub struct KclErrorWithOutputs {
|
||||
}
|
||||
|
||||
impl KclErrorWithOutputs {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
error: KclError,
|
||||
non_fatal: Vec<CompilationError>,
|
||||
#[cfg(feature = "artifact-graph")] operations: Vec<Operation>,
|
||||
#[cfg(feature = "artifact-graph")] artifact_commands: Vec<ArtifactCommand>,
|
||||
#[cfg(feature = "artifact-graph")] artifact_graph: ArtifactGraph,
|
||||
@ -155,7 +152,6 @@ impl KclErrorWithOutputs {
|
||||
) -> Self {
|
||||
Self {
|
||||
error,
|
||||
non_fatal,
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
operations,
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
@ -170,7 +166,6 @@ impl KclErrorWithOutputs {
|
||||
pub fn no_outputs(error: KclError) -> Self {
|
||||
Self {
|
||||
error,
|
||||
non_fatal: Default::default(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
operations: Default::default(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
|
@ -1467,6 +1467,7 @@ impl Node<CallExpressionKw> {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
// Add the call expression to the source ranges.
|
||||
// TODO currently ignored by the frontend
|
||||
e.add_source_ranges(vec![callsite])
|
||||
})?;
|
||||
|
||||
|
@ -823,7 +823,6 @@ impl ExecutorContext {
|
||||
|
||||
KclErrorWithOutputs::new(
|
||||
err,
|
||||
exec_state.errors().to_vec(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.clone(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
@ -1000,7 +999,6 @@ impl ExecutorContext {
|
||||
|
||||
return Err(KclErrorWithOutputs::new(
|
||||
e,
|
||||
exec_state.errors().to_vec(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.clone(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
@ -1050,7 +1048,6 @@ impl ExecutorContext {
|
||||
|
||||
KclErrorWithOutputs::new(
|
||||
err,
|
||||
exec_state.errors().to_vec(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.clone(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
@ -1103,7 +1100,6 @@ impl ExecutorContext {
|
||||
|
||||
KclErrorWithOutputs::new(
|
||||
e,
|
||||
exec_state.errors().to_vec(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.clone(),
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
|
@ -1277,15 +1277,7 @@ impl KclValue {
|
||||
.satisfied(values.len(), allow_shrink)
|
||||
.ok_or(CoercionError::from(self))?;
|
||||
|
||||
if len > values.len() {
|
||||
let message = format!(
|
||||
"Internal: Expected coerced array length {len} to be less than or equal to original length {}",
|
||||
values.len()
|
||||
);
|
||||
exec_state.err(CompilationError::err(self.into(), message.clone()));
|
||||
#[cfg(debug_assertions)]
|
||||
panic!("{message}");
|
||||
}
|
||||
assert!(len <= values.len());
|
||||
values.truncate(len);
|
||||
|
||||
Ok(KclValue::HomArray {
|
||||
|
@ -110,9 +110,9 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
///
|
||||
///
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// springSketch = startSketchOn(XZ)
|
||||
/// |> circle( center = [5, 0], radius = 1)
|
||||
/// |> sweep(path = helixPath)
|
||||
/// springSketch = startSketchOn(YZ)
|
||||
/// |> circle( center = [0, 0], radius = 1)
|
||||
/// |> sweep(path = helixPath, relativeTo = "sketchPlane")
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
|
@ -82,9 +82,9 @@ export END = 'end'
|
||||
/// )
|
||||
///
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// springSketch = startSketchOn(XZ)
|
||||
/// |> circle( center = [5, 0], radius = 0.5)
|
||||
/// |> sweep(path = helixPath)
|
||||
/// springSketch = startSketchOn(YZ)
|
||||
/// |> circle( center = [0, 0], radius = 0.5)
|
||||
/// |> sweep(path = helixPath, relativeTo = sweep::SKETCH_PLANE)
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
@ -103,9 +103,9 @@ export END = 'end'
|
||||
/// )
|
||||
///
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// springSketch = startSketchOn(XZ)
|
||||
/// |> circle( center = [5, 0], radius = 0.5 )
|
||||
/// |> sweep(path = helixPath)
|
||||
/// springSketch = startSketchOn(XY)
|
||||
/// |> circle( center = [0, 0], radius = 0.5 )
|
||||
/// |> sweep(path = helixPath, relativeTo = sweep::SKETCH_PLANE)
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
@ -123,9 +123,9 @@ export END = 'end'
|
||||
/// )
|
||||
///
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// springSketch = startSketchOn(XZ)
|
||||
/// |> circle( center = [5, 0], radius = 1 )
|
||||
/// |> sweep(path = helixPath)
|
||||
/// springSketch = startSketchOn(XY)
|
||||
/// |> circle( center = [0, 0], radius = 1 )
|
||||
/// |> sweep(path = helixPath, relativeTo = sweep::SKETCH_PLANE)
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
@ -408,13 +408,13 @@ export fn offsetPlane(
|
||||
/// )
|
||||
///
|
||||
///
|
||||
/// springSketch = startSketchOn(XZ)
|
||||
/// springSketch = startSketchOn(YZ)
|
||||
/// |> circle( center = [0, 0], radius = 1)
|
||||
///
|
||||
/// // Create a spring by sweeping around the helix path.
|
||||
/// sweepedSpring = clone(springSketch)
|
||||
/// |> translate(x=5)
|
||||
/// |> sweep(path = helixPath)
|
||||
/// |> translate(x=100)
|
||||
/// |> sweep(path = helixPath, relativeTo = sweep::SKETCH_PLANE)
|
||||
/// ```
|
||||
///
|
||||
/// ```kcl
|
||||
|
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 194 KiB |
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 194 KiB |
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 174 KiB |
@ -83,7 +83,7 @@ function CommandBarHeader({ children }: React.PropsWithChildren<object>) {
|
||||
<div className="flex flex-1 flex-wrap gap-2">
|
||||
<p
|
||||
data-command-name={selectedCommand?.name}
|
||||
className="pr-2 flex gap-2 items-center"
|
||||
className="pr-4 flex gap-2 items-center"
|
||||
>
|
||||
{selectedCommand &&
|
||||
'icon' in selectedCommand &&
|
||||
@ -93,13 +93,6 @@ function CommandBarHeader({ children }: React.PropsWithChildren<object>) {
|
||||
<span data-testid="command-name">
|
||||
{selectedCommand.displayName || selectedCommand.name}
|
||||
</span>
|
||||
{selectedCommand.status === 'experimental' ? (
|
||||
<span className="text-ml-black text-xs bg-ml-green rounded-full ml-2 px-2 py-1">
|
||||
experimental
|
||||
</span>
|
||||
) : (
|
||||
<span className="pr-2" />
|
||||
)}
|
||||
</p>
|
||||
{Object.entries(nonHiddenArgs || {})
|
||||
.filter(([_, argConfig]) =>
|
||||
@ -131,9 +124,7 @@ function CommandBarHeader({ children }: React.PropsWithChildren<object>) {
|
||||
key={argName}
|
||||
className={`relative w-fit px-2 py-1 rounded-sm flex gap-2 items-center border ${
|
||||
argName === currentArgument?.name
|
||||
? selectedCommand.status === 'experimental'
|
||||
? 'disabled:bg-ml-green/10 dark:disabled:bg-ml-green/20 disabled:border-ml-green dark:disabled:border-ml-green disabled:text-chalkboard-100 dark:disabled:text-chalkboard-10'
|
||||
: 'disabled:bg-primary/10 dark:disabled:bg-primary/20 disabled:border-primary dark:disabled:border-primary disabled:text-chalkboard-100 dark:disabled:text-chalkboard-10'
|
||||
? 'disabled:bg-primary/10 dark:disabled:bg-primary/20 disabled:border-primary dark:disabled:border-primary disabled:text-chalkboard-100 dark:disabled:text-chalkboard-10'
|
||||
: 'bg-chalkboard-20/50 dark:bg-chalkboard-80/50 border-chalkboard-20 dark:border-chalkboard-80'
|
||||
}`}
|
||||
>
|
||||
@ -205,29 +196,7 @@ function CommandBarHeader({ children }: React.PropsWithChildren<object>) {
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{isReviewing ? (
|
||||
<ReviewingButton
|
||||
bgClassName={
|
||||
selectedCommand.status === 'experimental' ? '!bg-ml-green' : ''
|
||||
}
|
||||
iconClassName={
|
||||
selectedCommand.status === 'experimental'
|
||||
? '!text-ml-black'
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<GatheringArgsButton
|
||||
bgClassName={
|
||||
selectedCommand.status === 'experimental' ? '!bg-ml-green' : ''
|
||||
}
|
||||
iconClassName={
|
||||
selectedCommand.status === 'experimental'
|
||||
? '!text-ml-black'
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{isReviewing ? <ReviewingButton /> : <GatheringArgsButton />}
|
||||
</div>
|
||||
<div className="block w-full my-2 h-[1px] bg-chalkboard-20 dark:bg-chalkboard-80" />
|
||||
{children}
|
||||
@ -236,8 +205,7 @@ function CommandBarHeader({ children }: React.PropsWithChildren<object>) {
|
||||
)
|
||||
}
|
||||
|
||||
type ButtonProps = { bgClassName?: string; iconClassName?: string }
|
||||
function ReviewingButton({ bgClassName, iconClassName }: ButtonProps) {
|
||||
function ReviewingButton() {
|
||||
return (
|
||||
<ActionButton
|
||||
Element="button"
|
||||
@ -248,8 +216,8 @@ function ReviewingButton({ bgClassName, iconClassName }: ButtonProps) {
|
||||
data-testid="command-bar-submit"
|
||||
iconStart={{
|
||||
icon: 'checkmark',
|
||||
bgClassName: `p-1 rounded-sm !bg-primary hover:brightness-110 ${bgClassName}`,
|
||||
iconClassName: `!text-chalkboard-10 ${iconClassName}`,
|
||||
bgClassName: 'p-1 rounded-sm !bg-primary hover:brightness-110',
|
||||
iconClassName: '!text-chalkboard-10',
|
||||
}}
|
||||
>
|
||||
<span className="sr-only">Submit command</span>
|
||||
@ -257,7 +225,7 @@ function ReviewingButton({ bgClassName, iconClassName }: ButtonProps) {
|
||||
)
|
||||
}
|
||||
|
||||
function GatheringArgsButton({ bgClassName, iconClassName }: ButtonProps) {
|
||||
function GatheringArgsButton() {
|
||||
return (
|
||||
<ActionButton
|
||||
Element="button"
|
||||
@ -267,8 +235,8 @@ function GatheringArgsButton({ bgClassName, iconClassName }: ButtonProps) {
|
||||
data-testid="command-bar-continue"
|
||||
iconStart={{
|
||||
icon: 'arrowRight',
|
||||
bgClassName: `p-1 rounded-sm !bg-primary hover:brightness-110 ${bgClassName}`,
|
||||
iconClassName: `!text-chalkboard-10 ${iconClassName}`,
|
||||
bgClassName: 'p-1 rounded-sm !bg-primary hover:brightness-110',
|
||||
iconClassName: '!text-chalkboard-10',
|
||||
}}
|
||||
>
|
||||
<span className="sr-only">Continue</span>
|
||||
|
@ -12,7 +12,6 @@ describe('test kclErrToDiagnostic', () => {
|
||||
kind: 'semantic',
|
||||
msg: 'Semantic error',
|
||||
sourceRange: topLevelRange(0, 1),
|
||||
nonFatal: [],
|
||||
operations: [],
|
||||
artifactCommands: [],
|
||||
artifactGraph: defaultArtifactGraph(),
|
||||
@ -25,7 +24,6 @@ describe('test kclErrToDiagnostic', () => {
|
||||
kind: 'type',
|
||||
msg: 'Type error',
|
||||
sourceRange: topLevelRange(4, 5),
|
||||
nonFatal: [],
|
||||
operations: [],
|
||||
artifactCommands: [],
|
||||
artifactGraph: defaultArtifactGraph(),
|
||||
|
@ -24,7 +24,6 @@ export class KCLError extends Error {
|
||||
kind: ExtractKind<RustKclError> | 'name'
|
||||
sourceRange: SourceRange
|
||||
msg: string
|
||||
nonFatal: CompilationError[]
|
||||
operations: Operation[]
|
||||
artifactCommands: ArtifactCommand[]
|
||||
artifactGraph: ArtifactGraph
|
||||
@ -35,7 +34,6 @@ export class KCLError extends Error {
|
||||
kind: ExtractKind<RustKclError> | 'name',
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[] = [],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -46,7 +44,6 @@ export class KCLError extends Error {
|
||||
this.kind = kind
|
||||
this.msg = msg
|
||||
this.sourceRange = sourceRange
|
||||
this.nonFatal = nonFatal
|
||||
this.operations = operations
|
||||
this.artifactCommands = artifactCommands
|
||||
this.artifactGraph = artifactGraph
|
||||
@ -60,7 +57,6 @@ export class KCLLexicalError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -71,7 +67,6 @@ export class KCLLexicalError extends KCLError {
|
||||
'lexical',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -86,7 +81,6 @@ export class KCLInternalError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -97,7 +91,6 @@ export class KCLInternalError extends KCLError {
|
||||
'internal',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -112,7 +105,6 @@ export class KCLSyntaxError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -123,7 +115,6 @@ export class KCLSyntaxError extends KCLError {
|
||||
'syntax',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -138,7 +129,6 @@ export class KCLSemanticError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -149,7 +139,6 @@ export class KCLSemanticError extends KCLError {
|
||||
'semantic',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -164,7 +153,6 @@ export class KCLTypeError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -175,7 +163,6 @@ export class KCLTypeError extends KCLError {
|
||||
'type',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -190,7 +177,6 @@ export class KCLIoError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -201,7 +187,6 @@ export class KCLIoError extends KCLError {
|
||||
'io',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -216,7 +201,6 @@ export class KCLUnexpectedError extends KCLError {
|
||||
constructor(
|
||||
msg: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -227,7 +211,6 @@ export class KCLUnexpectedError extends KCLError {
|
||||
'unexpected',
|
||||
msg,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -242,7 +225,6 @@ export class KCLValueAlreadyDefined extends KCLError {
|
||||
constructor(
|
||||
key: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -253,7 +235,6 @@ export class KCLValueAlreadyDefined extends KCLError {
|
||||
'name',
|
||||
`Key ${key} was already defined elsewhere`,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -268,7 +249,6 @@ export class KCLUndefinedValueError extends KCLError {
|
||||
constructor(
|
||||
key: string,
|
||||
sourceRange: SourceRange,
|
||||
nonFatal: CompilationError[],
|
||||
operations: Operation[],
|
||||
artifactCommands: ArtifactCommand[],
|
||||
artifactGraph: ArtifactGraph,
|
||||
@ -279,7 +259,6 @@ export class KCLUndefinedValueError extends KCLError {
|
||||
'name',
|
||||
`Key ${key} has not been defined`,
|
||||
sourceRange,
|
||||
nonFatal,
|
||||
operations,
|
||||
artifactCommands,
|
||||
artifactGraph,
|
||||
@ -307,7 +286,6 @@ export function lspDiagnosticsToKclErrors(
|
||||
[posToOffset(doc, range.start)!, posToOffset(doc, range.end)!, 0],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
defaultArtifactGraph(),
|
||||
{},
|
||||
null
|
||||
@ -333,13 +311,9 @@ export function lspDiagnosticsToKclErrors(
|
||||
export function kclErrorsToDiagnostics(
|
||||
errors: KCLError[]
|
||||
): CodeMirrorDiagnostic[] {
|
||||
let nonFatal: CodeMirrorDiagnostic[] = []
|
||||
const errs = errors
|
||||
return errors
|
||||
?.filter((err) => isTopLevelModule(err.sourceRange))
|
||||
.map((err): CodeMirrorDiagnostic => {
|
||||
if (err.nonFatal.length > 0) {
|
||||
nonFatal = nonFatal.concat(compilationErrorsToDiagnostics(err.nonFatal))
|
||||
}
|
||||
.map((err) => {
|
||||
return {
|
||||
from: err.sourceRange[0],
|
||||
to: err.sourceRange[1],
|
||||
@ -347,7 +321,6 @@ export function kclErrorsToDiagnostics(
|
||||
severity: 'error',
|
||||
}
|
||||
})
|
||||
return errs.concat(nonFatal)
|
||||
}
|
||||
|
||||
export function compilationErrorsToDiagnostics(
|
||||
|
@ -463,7 +463,6 @@ theExtrude = startSketchOn(XY)
|
||||
expect.any(Object),
|
||||
expect.any(Object),
|
||||
expect.any(Object),
|
||||
expect.any(Object),
|
||||
null
|
||||
)
|
||||
)
|
||||
|
@ -47,11 +47,11 @@ it('formats numbers with units', () => {
|
||||
describe('test errFromErrWithOutputs', () => {
|
||||
it('converts KclErrorWithOutputs to KclError', () => {
|
||||
const blob =
|
||||
'{"error":{"kind":"internal","sourceRanges":[],"msg":"Cache busted"},"nonFatal":[],"operations":[],"artifactCommands":[],"artifactGraph":{"map":{}},"filenames":{},"sourceFiles":{},"defaultPlanes":null}'
|
||||
'{"error":{"kind":"internal","sourceRanges":[],"msg":"Cache busted"},"operations":[],"artifactCommands":[],"artifactGraph":{"map":{}},"filenames":{},"sourceFiles":{},"defaultPlanes":null}'
|
||||
const error = errFromErrWithOutputs(blob)
|
||||
const errorStr = JSON.stringify(error)
|
||||
expect(errorStr).toEqual(
|
||||
'{"kind":"internal","sourceRange":[0,0,0],"msg":"Cache busted","nonFatal":[],"operations":[],"artifactCommands":[],"artifactGraph":{},"filenames":{},"defaultPlanes":null}'
|
||||
'{"kind":"internal","sourceRange":[0,0,0],"msg":"Cache busted","operations":[],"artifactCommands":[],"artifactGraph":{},"filenames":{},"defaultPlanes":null}'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
@ -69,7 +69,6 @@ import {
|
||||
UNLABELED_ARG,
|
||||
} from '@src/lang/queryAstConstants'
|
||||
import type { NumericType } from '@rust/kcl-lib/bindings/NumericType'
|
||||
import { isTopLevelModule } from '@src/lang/util'
|
||||
|
||||
export type { ArrayExpression } from '@rust/kcl-lib/bindings/ArrayExpression'
|
||||
export type {
|
||||
@ -158,23 +157,10 @@ export function defaultSourceRange(): SourceRange {
|
||||
return [0, 0, 0]
|
||||
}
|
||||
|
||||
function bestSourceRange(error: RustKclError): SourceRange {
|
||||
if (error.sourceRanges.length === 0) {
|
||||
return defaultSourceRange()
|
||||
}
|
||||
|
||||
// When there's an error, the call stack is unwound, and the locations are
|
||||
// built up from deepest location to shallowest. So the shallowest call is
|
||||
// last. That's the most useful to the user.
|
||||
for (let i = error.sourceRanges.length - 1; i >= 0; i--) {
|
||||
const range = error.sourceRanges[i]
|
||||
// Skip ranges pointing into files that aren't the top-level module.
|
||||
if (isTopLevelModule(range)) {
|
||||
return sourceRangeFromRust(range)
|
||||
}
|
||||
}
|
||||
// We didn't find a top-level module range, so just use the last one.
|
||||
return sourceRangeFromRust(error.sourceRanges[error.sourceRanges.length - 1])
|
||||
function firstSourceRange(error: RustKclError): SourceRange {
|
||||
return error.sourceRanges.length > 0
|
||||
? sourceRangeFromRust(error.sourceRanges[0])
|
||||
: defaultSourceRange()
|
||||
}
|
||||
|
||||
const splitErrors = (
|
||||
@ -244,8 +230,7 @@ export const parse = (code: string | Error): ParseResult | Error => {
|
||||
return new KCLError(
|
||||
parsed.kind,
|
||||
parsed.msg,
|
||||
bestSourceRange(parsed),
|
||||
[],
|
||||
firstSourceRange(parsed),
|
||||
[],
|
||||
[],
|
||||
defaultArtifactGraph(),
|
||||
@ -401,8 +386,7 @@ export const errFromErrWithOutputs = (e: any): KCLError => {
|
||||
return new KCLError(
|
||||
parsed.error.kind,
|
||||
parsed.error.msg,
|
||||
bestSourceRange(parsed.error),
|
||||
parsed.nonFatal,
|
||||
firstSourceRange(parsed.error),
|
||||
parsed.operations,
|
||||
parsed.artifactCommands,
|
||||
rustArtifactGraphToMap(parsed.artifactGraph),
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
kclSamplesManifestWithNoMultipleFiles,
|
||||
} from '@src/lib/kclSamples'
|
||||
import { getUniqueProjectName } from '@src/lib/desktopFS'
|
||||
import { IS_ML_EXPERIMENTAL } from '@src/lib/constants'
|
||||
import { IS_ML_EXPERIMENTAL, ML_EXPERIMENTAL_MESSAGE } from '@src/lib/constants'
|
||||
import toast from 'react-hot-toast'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import { relevantFileExtensions } from '@src/lang/wasmUtils'
|
||||
@ -168,6 +168,7 @@ export function createApplicationCommands({
|
||||
prompt: {
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
warningMessage: ML_EXPERIMENTAL_MESSAGE,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import {
|
||||
KCL_DEFAULT_DEGREE,
|
||||
KCL_DEFAULT_LENGTH,
|
||||
KCL_DEFAULT_TRANSFORM,
|
||||
ML_EXPERIMENTAL_MESSAGE,
|
||||
} from '@src/lib/constants'
|
||||
import type { components } from '@src/lib/machine-api'
|
||||
import type { Selections } from '@src/lib/selections'
|
||||
@ -963,10 +964,12 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
allowCodeSelection: true,
|
||||
},
|
||||
skip: true,
|
||||
warningMessage: ML_EXPERIMENTAL_MESSAGE,
|
||||
},
|
||||
prompt: {
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
warningMessage: ML_EXPERIMENTAL_MESSAGE,
|
||||
},
|
||||
},
|
||||
},
|
||||
|