Skip to content

Commit 945af61

Browse files
committed
Fix false warning for calling methods on components in mechanisms
1 parent 0d3334a commit 945af61

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/blocks/mrc_call_python_function.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,25 @@ const CALL_PYTHON_FUNCTION = {
547547
let foundComponent = false;
548548
const componentsInScope: storageModuleContent.Component[] = [];
549549
componentsInScope.push(...this.getComponentsFromRobot());
550+
551+
// If we're in a robot context, also include components from mechanisms
552+
if (editor.getCurrentModuleType() === storageModule.ModuleType.ROBOT) {
553+
editor.getMechanismsFromRobot().forEach(mechanismInRobot => {
554+
const mechanism = editor.getMechanism(mechanismInRobot);
555+
if (mechanism) {
556+
const mechanismComponents = editor.getComponentsFromMechanism(mechanism);
557+
mechanismComponents.forEach(component => {
558+
// Create a copy of the component with the mechanism-prefixed name
559+
const prefixedComponent = {
560+
...component,
561+
name: mechanismInRobot.name + '.' + component.name
562+
};
563+
componentsInScope.push(prefixedComponent);
564+
});
565+
}
566+
});
567+
}
568+
550569
if (editor.getCurrentModuleType() === storageModule.ModuleType.MECHANISM) {
551570
componentsInScope.push(...editor.getComponentsFromWorkspace());
552571
}

0 commit comments

Comments
 (0)