Add grouping of module instances in Feature Tree (#6125)

* Rename operations to be more generic grouping

* Add group enum

* Add module instance groups

* Change to export all operation ts-rs types to the same file

* Fix Feature Tree display of modules to use name

* Ignore clippy warning

* Update output after operation changes

* Change module instances in Feature Tree use to import icon

* Fix error message when attempting to delete module instance
This commit is contained in:
Jonathan Tran
2025-04-03 22:10:39 -04:00
committed by GitHub
parent c7b348390e
commit d38dcb9ba2
65 changed files with 12299 additions and 9315 deletions

View File

@ -289,10 +289,7 @@ const OperationItem = (props: {
send: Prop<Actor<typeof featureTreeMachine>, 'send'>
}) => {
const kclContext = useKclContext()
const name =
'name' in props.item && props.item.name !== null
? getOperationLabel(props.item)
: 'anonymous'
const name = getOperationLabel(props.item)
const errors = useMemo(() => {
return kclContext.diagnostics.filter(
(diag) =>
@ -304,7 +301,7 @@ const OperationItem = (props: {
}, [kclContext.diagnostics.length])
function selectOperation() {
if (props.item.type === 'UserDefinedFunctionReturn') {
if (props.item.type === 'GroupEnd') {
return
}
props.send({
@ -352,7 +349,7 @@ const OperationItem = (props: {
function deleteOperation() {
if (
props.item.type === 'StdLibCall' ||
props.item.type === 'UserDefinedFunctionCall' ||
props.item.type === 'GroupBegin' ||
props.item.type === 'KclStdLibCall'
) {
props.send({
@ -368,7 +365,7 @@ const OperationItem = (props: {
() => [
<ContextMenuItem
onClick={() => {
if (props.item.type === 'UserDefinedFunctionReturn') {
if (props.item.type === 'GroupEnd') {
return
}
props.send({
@ -381,14 +378,19 @@ const OperationItem = (props: {
>
View KCL source code
</ContextMenuItem>,
...(props.item.type === 'UserDefinedFunctionCall'
...(props.item.type === 'GroupBegin' &&
props.item.group.type === 'FunctionCall'
? [
<ContextMenuItem
onClick={() => {
if (props.item.type !== 'UserDefinedFunctionCall') {
if (props.item.type !== 'GroupBegin') {
return
}
const functionRange = props.item.functionSourceRange
if (props.item.group.type !== 'FunctionCall') {
// TODO: Add module instance support.
return
}
const functionRange = props.item.group.functionSourceRange
// For some reason, the cursor goes to the end of the source
// range we select. So set the end equal to the beginning.
functionRange[1] = functionRange[0]