private void init() { BasicEList<EStructuralFeature> contains = new UniqueEList<EStructuralFeature>(this.size); BasicEList<EStructuralFeature> crossRefs = new UniqueEList<EStructuralFeature>(this.size); for (int i = 0; i < this.size; ++i) { EStructuralFeature eFeature = (EStructuralFeature) this.data[i]; if (eFeature instanceof EReference) { EReference eReference = (EReference) eFeature; if (eReference.isContainment()) { contains.add(eReference); } else if (!eReference.isContainer()) { crossRefs.add(eReference); } } } contains.shrink(); crossRefs.shrink(); this.containments = new EStructuralFeature[contains.size()]; this.crossReferences = new EStructuralFeature[crossRefs.size()]; int i = 0; for (EStructuralFeature feature : contains) { this.containments[i++] = feature; } i = 0; for (EStructuralFeature feature : crossRefs) { this.crossReferences[i++] = feature; } }
@Override public EList<XExpression> getExplicitArguments() { BasicEList<XExpression> result = new BasicEList<XExpression>(); if (getMemberCallTarget() != null) result.add(getMemberCallTarget()); result.addAll(getMemberCallArguments()); return result; }
private EList<Instance> connectorConfiguratiobInstanceList(final String... defIds) { final BasicEList<Instance> instances = new BasicEList<Instance>(); for (final String defId : defIds) { instances.add(aConnectorConfigurationInstance(defId, "1.0")); } return instances; }
private void initWorkLists( int originSize, BasicEList<Element> ancestorList, PerSide<BasicEList<Element>> listPerSide) { BasicEList<Element> sourceList = new BasicEList<Element>(originSize); BasicEList<Element> targetList = new BasicEList<Element>(originSize); for (int i = 0; i < originSize; i++) { Element element = new Element(i); ancestorList.add(element); sourceList.add(element); targetList.add(element); } listPerSide.set(Side.SOURCE, sourceList); listPerSide.set(Side.TARGET, targetList); }
/** Returns a default class path. This is the root of the project */ protected static EList<MindPathEntry> defaultMindpath(IProject p) { MindPathEntry ret = MindideFactory.eINSTANCE.createMindPathEntry(); ret.setName(p.getFolder("src").getFullPath().toPortableString()); ret.setEntryKind(MindPathKind.SOURCE); BasicEList<MindPathEntry> retL = new BasicEList<MindPathEntry>(); retL.add(ret); return retL; }
protected static EList<Transition> _privk3_getActiveTransitions( final RegionAspectRegionAspectProperties _self_, final Region _self, final AbstractState vertex, final EList<String> events) { final BasicEList<Transition> res = new BasicEList<Transition>(); EList<Transition> _outgoing = vertex.getOutgoing(); for (final Transition transition : _outgoing) { boolean _or = false; Trigger _trigger = transition.getTrigger(); boolean _equals = Objects.equal(_trigger, null); if (_equals) { _or = true; } else { boolean _or_1 = false; boolean _and = false; Trigger _trigger_1 = transition.getTrigger(); boolean _notEquals = (!Objects.equal(_trigger_1, null)); if (!_notEquals) { _and = false; } else { Trigger _trigger_2 = transition.getTrigger(); boolean _evalTrigger = TriggerAspect.evalTrigger(_trigger_2, events); _and = _evalTrigger; } if (_and) { _or_1 = true; } else { boolean _and_1 = false; AbstractState _target = transition.getTarget(); if (!(_target instanceof Pseudostate)) { _and_1 = false; } else { AbstractState _target_1 = transition.getTarget(); _and_1 = (_target_1 instanceof Junction); } _or_1 = _and_1; } _or = _or_1; } if (_or) { res.add(transition); } } return res; }
@Override public EList<MindLibOrProject> getUses() { BasicEList<MindLibOrProject> ret = new BasicEList<MindLibOrProject>(); for (MindPathEntry mpe : mindpathentries) { MindObject resolvedObject = mpe.getResolvedBy(); if (resolvedObject == null) continue; MindLibOrProject mp = null; if (resolvedObject instanceof MindRootSrc) { MindRootSrc s = (MindRootSrc) resolvedObject; mp = s.getProject(); } else if (resolvedObject instanceof MindPackage) { MindPackage mdPacakage = (MindPackage) resolvedObject; MindRootSrc s = mdPacakage.getRootsrc(); if (s == null) continue; mp = s.getProject(); } else if (resolvedObject instanceof MindProject) { mp = (MindProject) resolvedObject; } if (mp == null || ret.contains(mp)) continue; ret.add(mp); } return ret; }
/* * Reads and decode an XML classpath string */ public static EList<MindPathEntry> decodeMindpath(String xmlMindpath) throws IOException { BasicEList<MindPathEntry> paths = new BasicEList<MindPathEntry>(); StringReader reader = new StringReader(xmlMindpath); Element cpElement; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); cpElement = parser.parse(new InputSource(reader)).getDocumentElement(); } catch (SAXException e) { e.printStackTrace(); throw new IOException("Bad format"); } catch (ParserConfigurationException e) { throw new IOException("Bad format"); } finally { reader.close(); } if (!cpElement .getNodeName() .equalsIgnoreCase(MindPathEntryCustomImpl.TAG_MINDPATH)) { // $NON-NLS-1$ throw new IOException("Bad format"); } NodeList list = cpElement.getElementsByTagName(MindPathEntryCustomImpl.TAG_MINDPATHENTRY); // $NON-NLS-1$ int length = list.getLength(); for (int i = 0; i < length; ++i) { Node node = list.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { MindPathEntry entry = MindPathEntryCustomImpl.elementDecode((Element) node); if (entry != null) { paths.add(entry); } } } return paths; }
private void pickChangesIntoResult( Side side, EStructuralFeature feature, BasicEList<Element> ancestorList, PerSide<List<CDOFeatureDelta>> changesPerSide, Map<CDOFeatureDelta, Element> allElements, Map<Object, List<Element>> additions, List<CDOFeatureDelta> result) { List<CDOFeatureDelta> changes = changesPerSide.get(side); for (CDOFeatureDelta change : changes) { Type changeType = change.getType(); switch (changeType) { case ADD: { CDOAddFeatureDeltaImpl addChange = (CDOAddFeatureDeltaImpl) change; result.add(addChange); int sideIndex = addChange.getIndex(); int ancestorIndex = sideIndex; int ancestorEnd = ancestorList.size(); if (ancestorIndex > ancestorEnd) { // TODO Better way to adjust ancestor indexes? ancestorIndex = ancestorEnd; addChange.setIndex(ancestorIndex); } Element newElement = allElements.get(addChange); ancestorList.add(ancestorIndex, newElement); if (treatAsUnique(feature)) { // Detect and remove corresponding AddDeltas from the other side Object value = addChange.getValue(); List<Element> elementsToAdd = additions.get(value); if (elementsToAdd != null) { for (Element element : elementsToAdd) { CDOAddFeatureDelta otherAdd = (CDOAddFeatureDelta) element.get(other(side)); if (otherAdd != null) { element.set(other(side), null); // Not taking an AddDelta has the same effect on indexes as a removal of the // element List<CDOFeatureDelta> otherChanges = changesPerSide.get(other(side)); int otherIndex = otherAdd.getIndex(); adjustAfterRemoval(otherChanges, otherIndex, addChange); } } } } break; } case REMOVE: { CDORemoveFeatureDeltaImpl removeChange = (CDORemoveFeatureDeltaImpl) change; result.add(removeChange); Element removedElement = allElements.get(removeChange); int ancestorIndex = ancestorList.indexOf(removedElement); removeChange.setIndex(ancestorIndex); ancestorList.remove(ancestorIndex); // Detect and remove a potential duplicate RemoveDelta from the other side CDOFeatureDelta otherChange = removedElement.get(other(side)); if (otherChange != null) { Type otherChangeType = otherChange.getType(); switch (otherChangeType) { case REMOVE: { CDORemoveFeatureDelta otherRemove = (CDORemoveFeatureDelta) otherChange; removedElement.set(other(side), null); // Not taking a RemoveDelta has the same effect on indexes as an addition of // the element List<CDOFeatureDelta> otherChanges = changesPerSide.get(other(side)); int otherIndex = otherRemove.getIndex(); adjustAfterAddition(otherChanges, otherIndex, otherRemove); break; } case MOVE: { CDOMoveFeatureDelta otherMove = (CDOMoveFeatureDelta) otherChange; removedElement.set(other(side), null); // Not taking a MoveDelta has the same effect on indexes as a reverse move // of the element List<CDOFeatureDelta> otherChanges = changesPerSide.get(other(side)); int otherOldPosition = otherMove.getOldPosition(); int otherNewPosition = otherMove.getNewPosition(); adjustAfterMove( otherChanges, otherOldPosition, otherNewPosition, otherMove); break; } default: throw new IllegalStateException("Unexpected change type: " + otherChangeType); } } break; } case SET: { throw new IllegalStateException("Unhandled change type: " + changeType); // CDOSetFeatureDelta setChange = (CDOSetFeatureDelta)change; // break; } case MOVE: { CDOMoveFeatureDeltaImpl moveChange = (CDOMoveFeatureDeltaImpl) change; int sideOldPosition = moveChange.getOldPosition(); int sideNewPosition = moveChange.getNewPosition(); Element movedElement = allElements.get(moveChange); CDOFeatureDelta otherChange = movedElement.get(other(side)); if (otherChange != null) { Type otherChangeType = otherChange.getType(); switch (otherChangeType) { case REMOVE: { // Prioritize the RemoveDelta of the other side, delete the MoveDelta from // this side adjustAfterMove(changes, sideOldPosition, sideNewPosition, moveChange); movedElement.set(side, null); return; } case MOVE: { CDOMoveFeatureDelta otherMove = (CDOMoveFeatureDelta) otherChange; movedElement.set(other(side), null); // Not taking a MoveDelta has the same effect on indexes as a reverse move // of the element List<CDOFeatureDelta> otherChanges = changesPerSide.get(other(side)); int otherOldPosition = otherMove.getOldPosition(); int otherNewPosition = otherMove.getNewPosition(); adjustAfterMove( otherChanges, otherOldPosition, otherNewPosition, otherMove); movedElement.set(other(side), null); break; } default: throw new IllegalStateException("Unexpected change type: " + otherChangeType); } } int positionDelta = sideNewPosition - sideOldPosition; int ancestorOldPosition = ancestorList.indexOf(movedElement); int ancestorNewPosition = ancestorOldPosition + positionDelta; if (ancestorNewPosition < 0) { ancestorNewPosition = 0; } int ancestorEnd = ancestorList.size() - 1; if (ancestorNewPosition > ancestorEnd) { ancestorNewPosition = ancestorEnd; } moveChange.setOldPosition(ancestorOldPosition); moveChange.setNewPosition(ancestorNewPosition); result.add(moveChange); ancestorList.move(ancestorNewPosition, ancestorOldPosition); break; } case CLEAR: case UNSET: default: throw new IllegalStateException("Illegal change type: " + changeType); } } }
private void applyChangesToWorkList( Side side, PerSide<BasicEList<Element>> listPerSide, PerSide<List<CDOFeatureDelta>> changesPerSide, Map<CDOFeatureDelta, Element> allElements, Map<Object, List<Element>> additions) { BasicEList<Element> list = listPerSide.get(side); List<CDOFeatureDelta> changes = changesPerSide.get(side); for (CDOFeatureDelta change : changes) { Type changeType = change.getType(); switch (changeType) { case ADD: { CDOAddFeatureDelta addChange = (CDOAddFeatureDelta) change; Element element = new Element(-1); element.set(side, addChange); allElements.put(addChange, element); list.add(addChange.getIndex(), element); rememberAddition(addChange.getValue(), element, additions); break; } case REMOVE: { CDORemoveFeatureDelta removeChange = (CDORemoveFeatureDelta) change; Element element = list.remove(removeChange.getIndex()); element.set(side, removeChange); allElements.put(removeChange, element); break; } case SET: { CDOSetFeatureDelta setChange = (CDOSetFeatureDelta) change; Element newElement = new Element(-1); newElement.set(side, setChange); rememberAddition(setChange.getValue(), newElement, additions); Element oldElement = list.set(setChange.getIndex(), newElement); oldElement.set(side, setChange); allElements.put(setChange, oldElement); break; } case MOVE: { CDOMoveFeatureDelta moveChange = (CDOMoveFeatureDelta) change; Element element = list.move(moveChange.getNewPosition(), moveChange.getOldPosition()); element.set(side, moveChange); allElements.put(moveChange, element); break; } case CLEAR: case UNSET: // These deltas should have been replaced by multiple REMOVE deltas in // copyListChanges() throw new IllegalStateException("Unhandled change type: " + changeType); default: throw new IllegalStateException("Illegal change type: " + changeType); } } }
@Override public EList<XExpression> getExplicitArguments() { BasicEList<XExpression> result = new BasicEList<XExpression>(); if (getOperand() != null) result.add(getOperand()); return result; }
public EList<EObject> getContents() { BasicEList<EObject> contents = new BasicEList<EObject>(1); contents.add(contentRoot); return contents; }