public boolean isInstanceNew() { for (Object command : CommandUtil.getAllContainedCommands(this)) { if (!(command instanceof InstanceCreateCommand)) continue; return declaration.getInstanceModel().equals(((InstanceCreateCommand) command).getChild()); } return false; }
private static void addMethodModelsAndConns( NodeModel addedNode, Resource resToAdd, NodeModel mostRecentNavigation, int mostRecentLineNumber, DiagramModel diagram, CompoundCommand command) { MethodBoxModel srcMethod = (MethodBoxModel) mostRecentNavigation; for (Invocation invocation : srcMethod.getCallsMade(null)) { Resource invocationRes = RJCore.jdtElementToResource( StoreUtil.getDefaultStoreRepository(), invocation.getMethodElement()); int invocationLineNum = InstanceUtil.getLineNumber(srcMethod.getInstanceModel(), invocation.getStartPosition()); if (resToAdd.equals(invocationRes) && invocationLineNum == mostRecentLineNumber) { // test whether call doesn't need to // be added because already in diagram for (MethodBoxModel child : srcMethod.getMethodChildren()) { if (invocation.getInvocation().equals(child.getASTNode())) { addedNode = child.getPartner(); return; } } Resource classOfInstance = MethodUtil.getClassOfInstanceCalledOn(invocation, srcMethod.getInstanceModel()); MethodBoxModel invocationModel = MethodUtil.createModelsForMethodRes( invocation, srcMethod, diagram, classOfInstance, null, false, command, null, false); addedNode = invocationModel.getPartner(); return; } } }
private static void addFieldModelsAndConns( NodeModel addedNode, Resource resToAdd, NodeModel mostRecentNavigation, int mostRecentLineNumber, DiagramModel diagram, CompoundCommand command) { MethodBoxModel methodAccessingField = (MethodBoxModel) mostRecentNavigation; for (FieldRead fieldRead : methodAccessingField.getFieldReadsMade()) { Resource fieldReadRes = RJCore.jdtElementToResource( StoreUtil.getDefaultStoreRepository(), fieldRead.resolveFieldBinding().getJavaElement()); int fieldReadLineNum = InstanceUtil.getLineNumber( methodAccessingField.getInstanceModel(), fieldRead.getStartPosition()); if (resToAdd.equals(fieldReadRes) && fieldReadLineNum == mostRecentLineNumber) { // test whether field read doesn't need to // be added because already in diagram for (FieldModel child : methodAccessingField.getFieldChildren()) { if (fieldRead.getFieldRead().equals(child.getASTNode())) { addedNode = child.getPartner(); return; } } FieldModel fieldAccessModel = FieldUtil.createModelsForField( methodAccessingField, fieldRead, -1, FieldUtil.getFieldAccessType(fieldRead), diagram, command, null); addedNode = fieldAccessModel.getPartner(); return; } } }
public InstanceFigure getInstanceOfDeclFigure() { return declaration.getInstanceModel().getFigure(); }