package jetbrains.mps.editor.runtime.cells; /*Generated by MPS */ import jetbrains.mps.openapi.editor.cells.EditorCell; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import java.util.Queue; import jetbrains.mps.internal.collections.runtime.QueueSequence; import java.util.LinkedList; import jetbrains.mps.openapi.editor.cells.EditorCell_Collection; import jetbrains.mps.internal.collections.runtime.Sequence; public class BigCellUtil { public static EditorCell findBigCell(EditorCell cell, SNode node) { SNode cellNode = cell.getSNode(); if (cellNode == node) { return cell; } if (!(SConceptOperations.isSubConceptOf(SNodeOperations.asSConcept(SNodeOperations.getConcept(cellNode)), MetaAdapterFactory.getConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da56L, "jetbrains.mps.lang.core.structure.PropertyAttribute"))) && !(SConceptOperations.isSubConceptOf(SNodeOperations.asSConcept(SNodeOperations.getConcept(cellNode)), MetaAdapterFactory.getConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da51L, "jetbrains.mps.lang.core.structure.LinkAttribute")))) { return cell; } Queue<EditorCell> cellQueue = QueueSequence.fromQueue(new LinkedList<EditorCell>()); QueueSequence.fromQueue(cellQueue).addLastElement(cell); while (QueueSequence.fromQueue(cellQueue).isNotEmpty()) { EditorCell nextCell = QueueSequence.fromQueue(cellQueue).removeFirstElement(); if (nextCell.getSNode() == node) { return nextCell; } if (nextCell instanceof EditorCell_Collection) { for (EditorCell childCell : Sequence.fromIterable(((EditorCell_Collection) nextCell))) { QueueSequence.fromQueue(cellQueue).addLastElement(childCell); } } } return null; } }