fun highlight()

in code/smv-debugger/src/main/kotlin/org/fbme/smvDebugger/visualization/SystemHighlighter.kt [16:63]


    fun highlight(itemValues: List<SystemItemValue?>?) {
        project.modelAccess.runReadAction {
            val networkInstance = createForCompositeFBType(compositeFb)
            val editor = navigate(project, networkInstance, false)
            val editorComponent = editor.currentEditorComponent
            val inspectionManager = getInstance(editorComponent)
            val networkInspector = inspectionManager!!.installInspector(networkInstance) {}
            networkInspector!!.clear()
            val fbNetwork = compositeFb.network
            val components: List<FunctionBlockDeclaration?> = fbNetwork.functionBlocks
            for (itemValue in itemValues!!) {
                val item = itemValue!!.item
                if (item.fbNames.isEmpty()) {
                    continue
                }
                var component: FunctionBlockDeclaration? = null
                var curComponents = components
                val i = Wrappers._int(0)
                while (i.value < item.fbNames.size) {
                    component = curComponents.stream()
                        .filter { it: FunctionBlockDeclaration? -> it!!.name == item.fbNames[i.value] }
                        .findFirst()
                        .orElse(null)
                    curComponents =
                        if (component != null && component.typeReference.getTarget() is CompositeFBTypeDeclaration) {
                            val compositeDeclaration =
                                component.typeReference.getTarget() as CompositeFBTypeDeclaration?
                            compositeDeclaration!!.network.functionBlocks
                        } else {
                            break
                        }
                    i.value++
                }
                if (component != null) {
                    val inspection = Inspection(itemValue.value!!, HIGHLIGHT_COLOR)
                    if (item.type == SystemItemType.ECC) {
                        networkInspector.setInspectionForComponent(component, inspection)
                    } else {
                        val ports = component.ports
                        val port = ports.firstOrNull { it.portTarget.name == item.itemName }
                        if (port != null) {
                            networkInspector.setInspectionForPort(port, inspection)
                        }
                    }
                }
            }
        }
    }