Surface warnings to frontend and LSP (#4603)
* Send multiple errors and warnings to the frontend and LSP Signed-off-by: Nick Cameron <nrc@ncameron.org> * Refactor the parser to use CompilationError for parsing errors rather than KclError Signed-off-by: Nick Cameron <nrc@ncameron.org> * Refactoring: move CompilationError, etc. Signed-off-by: Nick Cameron <nrc@ncameron.org> * Integrate compilation errors with the frontend and CodeMirror Signed-off-by: Nick Cameron <nrc@ncameron.org> * Fix tests Signed-off-by: Nick Cameron <nrc@ncameron.org> * Review comments Signed-off-by: Nick Cameron <nrc@ncameron.org> * Fix module id/source range stuff Signed-off-by: Nick Cameron <nrc@ncameron.org> * More test fixups Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -4,6 +4,7 @@ import {
|
||||
VariableDeclarator,
|
||||
parse,
|
||||
recast,
|
||||
resultIsOk,
|
||||
} from 'lang/wasm'
|
||||
import {
|
||||
Axis,
|
||||
@ -542,8 +543,11 @@ export const modelingMachine = setup({
|
||||
if (event.type !== 'Convert to variable') return false
|
||||
if (!event.data) return false
|
||||
const ast = parse(recast(kclManager.ast))
|
||||
if (err(ast)) return false
|
||||
const isSafeRetVal = isNodeSafeToReplacePath(ast, event.data.pathToNode)
|
||||
if (err(ast) || !ast.program || ast.errors.length > 0) return false
|
||||
const isSafeRetVal = isNodeSafeToReplacePath(
|
||||
ast.program,
|
||||
event.data.pathToNode
|
||||
)
|
||||
if (err(isSafeRetVal)) return false
|
||||
return isSafeRetVal.isSafe
|
||||
},
|
||||
@ -1332,9 +1336,12 @@ export const modelingMachine = setup({
|
||||
return
|
||||
}
|
||||
|
||||
const recastAst = parse(recast(modifiedAst))
|
||||
if (err(recastAst) || !resultIsOk(recastAst)) return
|
||||
|
||||
const updatedAst = await sceneEntitiesManager.updateAstAndRejigSketch(
|
||||
sketchDetails?.sketchPathToNode || [],
|
||||
parse(recast(modifiedAst)),
|
||||
recastAst.program,
|
||||
sketchDetails.zAxis,
|
||||
sketchDetails.yAxis,
|
||||
sketchDetails.origin
|
||||
|
Reference in New Issue
Block a user