Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transition fork, decision is subclass #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/Flow-Core/CDBlockObjectVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,6 @@ CDBlockObjectVisitor >> visitAction: anAction [
self visit: anAction outgoing ]
]

{ #category : #visiting }
CDBlockObjectVisitor >> visitCondition: aCondition [
| condition yes no previous |
condition := self dimensionAt: aCondition.
yes := self dimensionAt: aCondition yes.
no := self dimensionAt: aCondition no.
previous := self dimensionAt: aCondition incoming.
self
position: yes rightOf: condition strength: ClStrength strong;
position: yes middleOf: condition strength: ClStrength strong;
position: no under: condition strength: ClStrength strong;
position: no centerOf: condition strength: ClStrength strong;
position: condition under: previous strength: ClStrength strong.

edges add: (aCondition -> (aCondition yes)).
edges add: (aCondition -> (aCondition no)).

self visit: aCondition yes.
self visit: aCondition no.
]

{ #category : #visiting }
CDBlockObjectVisitor >> visitEnd: anEndState [
| end previous |
Expand All @@ -162,6 +141,27 @@ CDBlockObjectVisitor >> visitEnd: anEndState [
"
]

{ #category : #visiting }
CDBlockObjectVisitor >> visitFork: aFork [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in the chat, a fork is a separation of control flow and decision a simple branch

| condition firstBranch secondBranch previous |
condition := self dimensionAt: aFork.
firstBranch := self dimensionAt: aFork firstBranch.
secondBranch := self dimensionAt: aFork secondBranch.
previous := self dimensionAt: aFork incoming.
self
position: firstBranch rightOf: condition strength: ClStrength strong;
position: firstBranch middleOf: condition strength: ClStrength strong;
position: secondBranch under: condition strength: ClStrength strong;
position: secondBranch centerOf: condition strength: ClStrength strong;
position: condition under: previous strength: ClStrength strong.

edges add: (aFork -> (aFork firstBranch)).
edges add: (aFork -> (aFork secondBranch)).

self visit: aFork firstBranch.
self visit: aFork secondBranch.
]

{ #category : #visiting }
CDBlockObjectVisitor >> visitStartState: aStartState [
| start next |
Expand Down
10 changes: 0 additions & 10 deletions src/Flow-Core/CDCodeModelBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ CDCodeModelBuilder >> model [
^ startState
]

{ #category : #'as yet unclassified' }
CDCodeModelBuilder >> resolve: flowName no: aCollection [
^ self resolve: flowName outgoing: aCollection
]

{ #category : #'as yet unclassified' }
CDCodeModelBuilder >> resolve: aString outgoing: aCollection [
| method pragma state |
Expand All @@ -31,11 +26,6 @@ CDCodeModelBuilder >> resolve: aString outgoing: aCollection [
builder: self
]

{ #category : #'as yet unclassified' }
CDCodeModelBuilder >> resolve: flowName yes: aCollection [
^ self resolve: flowName outgoing: aCollection
]

{ #category : #'as yet unclassified' }
CDCodeModelBuilder >> resolveMethod: aCollection [
| targetClass |
Expand Down
35 changes: 3 additions & 32 deletions src/Flow-Core/CDDecision.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Class {
#name : #CDDecision,
#superclass : #CDBlockObject,
#instVars : [
'yes',
'no'
],
#superclass : #CDTransitionFork,
#category : #'Flow-Core'
}

Expand All @@ -13,28 +9,9 @@ CDDecision class >> stateObjectName [
^ #decision
]

{ #category : #visiting }
CDDecision >> acceptStateVisitor: aStateObjectVisitor [
^ aStateObjectVisitor visitCondition: self
]

{ #category : #accessing }
CDDecision >> no [
^ no
]

{ #category : #accessing }
CDDecision >> no: anObject [
anObject incoming: self.
no := anObject
]

{ #category : #'as yet unclassified' }
CDDecision >> resolve: flowName in: aCollection builder: aBuilder [
yes := aBuilder resolve: flowName yes: (aCollection first: 2).
yes incoming: self.
no := aBuilder resolve: flowName no: (aCollection last: 2).
no incoming: self
^ secondBranch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No was easy to understand,now it is not

]

{ #category : #accessing }
Expand All @@ -57,11 +34,5 @@ CDDecision >> shape [

{ #category : #accessing }
CDDecision >> yes [
^ yes
]

{ #category : #accessing }
CDDecision >> yes: anObject [
anObject incoming: self.
yes := anObject
^ firstBranch
]
67 changes: 67 additions & 0 deletions src/Flow-Core/CDTransitionFork.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Class {
#name : #CDTransitionFork,
#superclass : #CDBlockObject,
#instVars : [
'firstBranch',
'secondBranch'
],
#category : #'Flow-Core'
}

{ #category : #'as yet unclassified' }
CDTransitionFork class >> stateObjectName [
^ #transitionFork
]

{ #category : #visiting }
CDTransitionFork >> acceptStateVisitor: aStateObjectVisitor [
^ aStateObjectVisitor visitFork: self
]

{ #category : #accessing }
CDTransitionFork >> firstBranch [
^ firstBranch
]

{ #category : #accessing }
CDTransitionFork >> firstBranch: anObject [
anObject incoming: self.
firstBranch := anObject
]

{ #category : #visiting }
CDTransitionFork >> resolveFrom: aPragma in: aCollection builder: aBuilder [
firstBranch := aBuilder resolveFrom: aPragma outgoing: (aCollection first: 2).
firstBranch incoming: self.
secondBranch := aBuilder resolveFrom: aPragma outgoing: (aCollection last: 2).
secondBranch incoming: self
]

{ #category : #accessing }
CDTransitionFork >> secondBranch [
^ secondBranch
]

{ #category : #accessing }
CDTransitionFork >> secondBranch: anObject [
anObject incoming: self.
secondBranch := anObject
]

{ #category : #'as yet unclassified' }
CDTransitionFork >> shape [
| shapeBuilder labelShape |
shapeBuilder := RSMultilineLabelBuilder new.
shapeBuilder labelShape
fontSize: self fontSize.
labelShape := (shapeBuilder shapeFor: label).

^ RSComposite new
model: self;
shapes: {
RSShapeFactory rectangle
extent: (Point x: labelShape width + 20 y: 150);
border: self border;
color: #lightYellow.
labelShape}
]