Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9fde4d1e852b1190742b0e0dd6b7996b1bb5902b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
/*******************************************************************************
 * Copyright (c) 2015 Willink Transformations and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   E.D.Willink - Initial API and implementation
 *******************************************************************************/
package org.eclipse.qvtd.compiler.internal.qvtp2qvts;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.CallExp;
import org.eclipse.ocl.pivot.DataType;
import org.eclipse.ocl.pivot.NavigationCallExp;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.OperationCallExp;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.TypedElement;
import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.VariableDeclaration;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtcorebase.NavigationAssignment;
import org.eclipse.qvtd.pivot.qvtcorebase.analysis.DomainUsage;
import org.eclipse.qvtd.pivot.qvtcorebase.utilities.QVTcoreBaseUtil;
import org.eclipse.qvtd.pivot.schedule.ClassDatum;

/**
 * Nodes provides factory instances for creating the various forms of nodes.
 */
public class Nodes
{	
	public static abstract class AbstractSimpleNodeRole extends AbstractNodeRole
	{
		protected AbstractSimpleNodeRole(@NonNull Phase phase) {
			super(phase);
		}

		@Override
		public @NonNull Node createNode(@NonNull Region region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
			throw new UnsupportedOperationException();
		}

		@Override
		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
			return new SimpleTypedNode(this, region, name, classDatumAnalysis);
		}

		@Override
		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull TypedElement typedElement) {
			return new SimpleTypedNode(this, region, name, typedElement);
		}
	}
	
	public static abstract class AbstractVariableNodeRole extends AbstractSimpleNodeRole
	{
		protected final boolean isClassNode;
		
		protected AbstractVariableNodeRole(@NonNull Phase phase, boolean isClassNode) {
			super(phase);
			this.isClassNode = isClassNode;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull VariableDeclaration variable) {
			assert isClassNode == !(variable.getType() instanceof DataType);
			return new SimpleVariableNode(this, region, variable);
		}

		@Override
		public boolean isClassNode() {
//			return !(classDatumAnalysis.getClassDatum().getType() instanceof DataType);
			return isClassNode;
		}
	}
	
	public static final class AttributeNodeRoleFactory
	{
		private static abstract class AbstractAttributeNodeRole extends AbstractSimpleNodeRole
		{
			private final boolean isNavigable;

			protected AbstractAttributeNodeRole(@NonNull Phase phase, boolean isNavigable) {
				super(phase);
				this.isNavigable = isNavigable;
			}
			
			@Override
			public boolean isAttributeNode() {
				return true;
			}

			@Override
			public boolean isNavigable() {
				return isNavigable;
			}

			@Override
			public String toString() {
				return phase + (isNavigable ? "-NAVIGABLE-" : "-UNNAVIGABLE-") + getClass().getSimpleName();
			}
		}

		public static class AttributeNodeRole extends AbstractAttributeNodeRole
		{
			private boolean isAttribute;
			
			protected AttributeNodeRole(@NonNull Phase phase, boolean isAttribute, boolean isNavigable) {
				super(phase, isNavigable);
				this.isAttribute = isAttribute;
			}

			public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull Node parentNode, @NonNull NavigationCallExp navigationCallExp) {
				assert parentNode.isClassNode();
//				SchedulerConstants schedulerConstants = region.getSchedulerConstants();
				Property referredProperty = PivotUtil.getReferredProperty(navigationCallExp);
				assert referredProperty != null;
//				Type type = navigationCallExp.getType();
//				assert type != null;
//				ClassDatum classDatum = schedulerConstants.getClassDatum(type);
//				DomainUsage domainUsage = parentNode.getClassDatumAnalysis().getDomainUsage();
//				ClassDatumAnalysis classDatumAnalysis = schedulerConstants.getClassDatumAnalysis(classDatum, domainUsage);
				String name = referredProperty.getName();
				assert name != null;
				return createSimpleNode(region, name, navigationCallExp);
			}

			@Override
			public boolean isMatchable() {
				return true;
			}
			
			@Override
			public @Nullable String getStyle() {
				return isAttribute ? "rounded" : null;
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole == REALIZED_ATTRIBUTE) {
					return nodeRole;
				}
				if (getClass() != nodeRole.getClass()) {
					throw new IllegalStateException(this + " cannot be merged");
				}
				return this.compareTo(nodeRole) < 0 ? this : nodeRole;
			}
		}

		public static class ExtraGuardNodeRole extends AbstractAttributeNodeRole
		{
			protected ExtraGuardNodeRole() {
				super(Role.Phase.PREDICATED, false);
			}

			@Override
			public boolean isExtraGuardVariable() {
				return true;
			}

			@Override
			public boolean isGuardVariable() {
				return true;
			}

			@Override
			public boolean isHead() {
				return true;
			}
		}
			
		public static final class RealizedAttributeNodeRole extends AbstractAttributeNodeRole
		{
			protected RealizedAttributeNodeRole() {
				super(Role.Phase.REALIZED, false);
			}

			public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull SimpleNode parentNode, @NonNull Property property) {
				assert parentNode.isClassNode();
				SchedulerConstants schedulerConstants = region.getSchedulerConstants();
				org.eclipse.ocl.pivot.Class type = (org.eclipse.ocl.pivot.Class)property.getType();
				assert type != null;
				Type elementType = QVTbaseUtil.getElementalType(type);
				TypedModel typedModel = elementType instanceof DataType ? region.getSchedulerConstants().getDomainAnalysis().getPrimitiveTypeModel() : parentNode.getClassDatumAnalysis().getTypedModel();
//				DomainUsage usage = region.getSchedulerConstants().getDomainAnalysis().getUsage(type);
//				assert usage != null;
//				TypedModel typedModel = usage.getTypedModel();
				assert typedModel != null;
				ClassDatum classDatum = schedulerConstants.getClassDatum(type, typedModel);
//				DomainUsage domainUsage = parentNode.getClassDatumAnalysis().getDomainUsage();
				ClassDatumAnalysis classDatumAnalysis = schedulerConstants.getClassDatumAnalysis(classDatum);
				String name = property.getName();
				assert name != null;
				return createSimpleNode(region, name, classDatumAnalysis);
			}
			
			@Override
			public @Nullable String getStyle() {
				return "rounded";
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.getPhase() == Phase.PREDICATED) {
					return this;
				}
				return super.merge(nodeRole);
			}

			@Override
			public String toString() {
				return getClass().getSimpleName();
			}
		}
		
		public static final class PredicatedInternalNodeRole extends AbstractAttributeNodeRole
		{
			protected PredicatedInternalNodeRole() {
				super(Role.Phase.PREDICATED, false);
			}

			public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull SimpleNode parentNode, @NonNull NavigationAssignment navigationAssignment) {
				assert parentNode.isClassNode();
				SchedulerConstants schedulerConstants = region.getSchedulerConstants();
				Property property = QVTcoreBaseUtil.getTargetProperty(navigationAssignment);
				assert property != null;
				org.eclipse.ocl.pivot.Class type = (org.eclipse.ocl.pivot.Class)property.getType();
				assert type != null;
				TypedModel typedModel = parentNode.getClassDatumAnalysis().getTypedModel();
				ClassDatum classDatum = schedulerConstants.getClassDatum(type, typedModel);
//				DomainUsage domainUsage = parentNode.getClassDatumAnalysis().getDomainUsage();
				ClassDatumAnalysis classDatumAnalysis = schedulerConstants.getClassDatumAnalysis(classDatum);
				String name = property.getName();
				assert name != null;
				return createSimpleNode(region, name, classDatumAnalysis);
			}
			
			@Override
			public boolean isInternal() {
				return true;
			}

/*			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.getPhase() == Phase.PREDICATED) {
					return this;
				}
				return super.merge(nodeRole);
			} */

			@Override
			public String toString() {
				return getClass().getSimpleName();
			}
		}
		
		private static final @NonNull AttributeNodeRole LOADED_NAVIGABLE_ATTRIBUTE = new AttributeNodeRole(Role.Phase.LOADED, true, true);
		private static final @NonNull AttributeNodeRole LOADED_UNNAVIGABLE_ATTRIBUTE = new AttributeNodeRole(Role.Phase.LOADED, true, false);
		private static final @NonNull AttributeNodeRole PREDICATED_NAVIGABLE_ATTRIBUTE = new AttributeNodeRole(Role.Phase.PREDICATED, true, true);
		private static final @NonNull AttributeNodeRole PREDICATED_UNNAVIGABLE_ATTRIBUTE = new AttributeNodeRole(Role.Phase.PREDICATED, true, false);
		public static final @NonNull PredicatedInternalNodeRole PREDICATED_CLASS = new PredicatedInternalNodeRole();

		private final @Nullable Boolean isNavigable;

		public AttributeNodeRoleFactory(@Nullable Boolean isNavigable) {
			this.isNavigable = isNavigable;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull Region region, @NonNull SimpleNode parentNode, @NonNull NavigationCallExp navigationCallExp) {
			boolean resolvedNavigable = isNavigable != null ? isNavigable.booleanValue() : parentNode.isNavigable();
			if (parentNode.isLoaded()) {
				Property referredProperty = PivotUtil.getReferredProperty(navigationCallExp);
				assert referredProperty != null;
				boolean isDirty = region.getSchedulerConstants().isDirty(referredProperty);
				if (!isDirty) {
					return (resolvedNavigable ? LOADED_NAVIGABLE_ATTRIBUTE : LOADED_UNNAVIGABLE_ATTRIBUTE).createSimpleNode(parentNode.getRegion(), parentNode, navigationCallExp);
				}
				else {
					return (resolvedNavigable ? PREDICATED_NAVIGABLE_ATTRIBUTE : PREDICATED_UNNAVIGABLE_ATTRIBUTE).createSimpleNode(parentNode.getRegion(), parentNode, navigationCallExp);
				}
			}
			else if (parentNode.isPredicated()) {
				return (resolvedNavigable ? PREDICATED_NAVIGABLE_ATTRIBUTE : PREDICATED_UNNAVIGABLE_ATTRIBUTE).createSimpleNode(parentNode.getRegion(), parentNode, navigationCallExp);
			}
			else if (parentNode.isRealized()) {
				Property referredProperty = PivotUtil.getReferredProperty(navigationCallExp);	// ??never happens
				assert referredProperty != null;
				return REALIZED_ATTRIBUTE.createSimpleNode(parentNode.getRegion(), parentNode, referredProperty);
			}
			else {
				throw new UnsupportedOperationException();
			}
		}
	}

	private static final class ComposingNodeRole extends AbstractSimpleNodeRole
	{
		protected ComposingNodeRole() {
			super(Role.Phase.LOADED);
		}

		@Override
		public boolean isClassNode() {
			return true;
		}

		@Override
		public boolean isNavigable() {
			return true;
		}
	}
	
	public static final class ElementNodeRoleFactory
	{
		private static abstract class AbstractElementNodeRole extends AbstractSimpleNodeRole
		{
			protected AbstractElementNodeRole(@NonNull Phase phase) {
				super(phase);
			}

			@Override
			public boolean isClassNode() {
				return true;
			}

			@Override
			public boolean isMatchable() {
				return true;
			}

			@Override
			public boolean isNavigable() {
				return true;
			}

			@Override
			public String toString() {
				return getClass().getSimpleName();
			}
		}

		private static final class LoadedElementNodeRole extends AbstractElementNodeRole
		{
			protected LoadedElementNodeRole() {
				super(Role.Phase.LOADED);
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.isHead()) {
					return this;
				}
				return super.merge(nodeRole);
			}
		}

		public static final class PredicatedElementNodeRole extends AbstractElementNodeRole
		{
			protected PredicatedElementNodeRole() {
				super(Role.Phase.PREDICATED);
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.isHead()) {
					return this;
				}
				if (nodeRole instanceof RealizedVariableNodeRole) {
					return nodeRole;
				}
				return super.merge(nodeRole);
			}
		}

		private static final @NonNull LoadedElementNodeRole LOADED_ELEMENT = new LoadedElementNodeRole();
		public static final @NonNull PredicatedElementNodeRole PREDICATED_ELEMENT = new PredicatedElementNodeRole();
		
		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis, @NonNull SimpleNode sourceNode) {
			if (sourceNode.isPredicated()) {
				return PREDICATED_ELEMENT.createSimpleNode(region, name, classDatumAnalysis);
			}
			else {
				return LOADED_ELEMENT.createSimpleNode(region, name, classDatumAnalysis);
			}
		}
	}

	private static final class ErrorNodeRole extends AbstractSimpleNodeRole
	{
		protected ErrorNodeRole() {
			super(Role.Phase.OTHER);
		}

		@Override
		public @NonNull String getColor() {
			return ERROR_COLOR;
		}

		@Override
		public @NonNull Integer getPenwidth() {
			return GUARD_WIDTH;
		}

		@Override
		public @NonNull String getShape() {
			return "circle";
		}
	}
	
	public static final class GuardNodeRoleFactory
	{
		private static abstract class AbstractGuardNodeRole extends AbstractVariableNodeRole
		{
			protected AbstractGuardNodeRole(@NonNull Phase phase, boolean isClassNode) {
				super(phase, isClassNode);
			}

			@Override
			public boolean isGuardVariable() {
				return true;
			}

			@Override
			public boolean isMatchable() {
				return true;
			}

			@Override
			public boolean isNavigable() {
				return true;
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if ((phase == Phase.PREDICATED) && (nodeRole == REALIZED_VARIABLE)) {
					return nodeRole;
				}
				return super.merge(nodeRole);
			}
		}

		private static final class GuardNodeRole extends AbstractGuardNodeRole
		{
			private final @NonNull HeadNodeRole headNode;
			
			protected GuardNodeRole(@NonNull Phase phase, @NonNull HeadNodeRole headNode, boolean isClassNode) {
				super(phase, isClassNode);
				this.headNode = headNode;
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.isConstant()) {
					return nodeRole;
				}
//				if ((phase == Phase.PREDICATED) && (nodeRole.getPhase() == Phase.PREDICATED) && nodeRole.isHead()) {
//					return this;
//				}
				return super.merge(nodeRole);
			}

			@Override
			public @NonNull NodeRole setHead() {
				return headNode;
			}
		}

		private static final class HeadNodeRole extends AbstractGuardNodeRole
		{		
			protected HeadNodeRole(@NonNull Phase phase) {
				super(phase, true);
			}

			@Override
			public boolean isHead() {
				return true;
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if ((phase == Phase.LOADED) && (nodeRole.getPhase() == Phase.LOADED) && (nodeRole instanceof GuardNodeRole)) {
					return nodeRole;
				}
//				if ((phase == Phase.PREDICATED) && (nodeRole.getPhase() == Phase.PREDICATED) && (nodeRole instanceof GuardNodeRole)) {
//					return nodeRole;
//				}
				return super.merge(nodeRole);
			}
		}
		
		private static final @NonNull HeadNodeRole LOADED_HEAD = new HeadNodeRole(Role.Phase.LOADED);
		private static final @NonNull GuardNodeRole LOADED_ATTRIBUTE_GUARD = new GuardNodeRole(Role.Phase.LOADED, LOADED_HEAD,false);
		private static final @NonNull GuardNodeRole LOADED_CLASS_GUARD = new GuardNodeRole(Role.Phase.LOADED, LOADED_HEAD, true);
		private static final @NonNull HeadNodeRole PREDICATED_HEAD = new HeadNodeRole(Role.Phase.PREDICATED);
		private static final @NonNull GuardNodeRole PREDICATED_ATTRIBUTE_GUARD = new GuardNodeRole(Role.Phase.PREDICATED, PREDICATED_HEAD, false);
		private static final @NonNull GuardNodeRole PREDICATED_CLASS_GUARD = new GuardNodeRole(Role.Phase.PREDICATED, PREDICATED_HEAD, true);
		
		private final @Nullable Boolean isClassNode;

		public GuardNodeRoleFactory(@Nullable Boolean isClassNode) {
			this.isClassNode = isClassNode;
		}
		
		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull VariableDeclaration guardVariable) {
			DomainUsage domainUsage = region.getSchedulerConstants().getDomainUsage(guardVariable);
			boolean isEnforceable = domainUsage.isOutput();
			Boolean resolvedIsClassNode = isClassNode;
			if (resolvedIsClassNode == null) {
				resolvedIsClassNode = !(guardVariable.getType() instanceof DataType);
			}
			if (!isEnforceable) {
				return (resolvedIsClassNode ? LOADED_CLASS_GUARD : LOADED_ATTRIBUTE_GUARD).createSimpleNode(region, guardVariable);
			}
			else {
				return (resolvedIsClassNode ? PREDICATED_CLASS_GUARD : PREDICATED_ATTRIBUTE_GUARD).createSimpleNode(region, guardVariable);
			}
		}
	}

	public static final class IteratorNodeRoleFactory
	{
		private static final class IteratorNodeRole extends AbstractVariableNodeRole
		{
			protected IteratorNodeRole(@NonNull Phase phase, boolean isClassNode) {
				super(phase, isClassNode);
			}

//			@Override
//			public boolean isHead() {
//				return true;
//			}
			
			@Override
			public boolean isInternal() {
				return true;
			}
			
			@Override
			public boolean isIterator() {
				return true;
			}
			
			@Override
			public boolean isMatchable() {
				return true;
			}

//			@Override
//			public boolean isNavigable() {
//				return true;
//			}
		}
		
		private static final @NonNull AbstractVariableNodeRole CONSTANT_ATTRIBUTE_ITERATOR = new IteratorNodeRole(Role.Phase.CONSTANT, false);
		private static final @NonNull AbstractVariableNodeRole CONSTANT_CLASS_ITERATOR = new IteratorNodeRole(Role.Phase.CONSTANT, true);
		private static final @NonNull AbstractVariableNodeRole LOADED_ATTRIBUTE_ITERATOR = new IteratorNodeRole(Role.Phase.LOADED, false);
		private static final @NonNull AbstractVariableNodeRole LOADED_CLASS_ITERATOR = new IteratorNodeRole(Role.Phase.LOADED, true);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_ATTRIBUTE_ITERATOR = new IteratorNodeRole(Role.Phase.PREDICATED, false);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_CLASS_ITERATOR = new IteratorNodeRole(Role.Phase.PREDICATED, true);
		
		private final @Nullable Boolean isClassNode;

		public IteratorNodeRoleFactory(@Nullable Boolean isClassNode) {
			this.isClassNode = isClassNode;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull Variable iterator, @NonNull SimpleNode sourceNode) {
			Boolean resolvedIsClassNode = isClassNode;
			if (resolvedIsClassNode == null) {
				resolvedIsClassNode = !(iterator.getType() instanceof DataType);
			}
			if (sourceNode.isConstant()) {
				return (resolvedIsClassNode ? CONSTANT_CLASS_ITERATOR : CONSTANT_ATTRIBUTE_ITERATOR).createSimpleNode(region, iterator);
			}
			else if (sourceNode.isLoaded()) {
				return (resolvedIsClassNode ? LOADED_CLASS_ITERATOR : LOADED_ATTRIBUTE_ITERATOR).createSimpleNode(region, iterator);
			}
			else {
				return (resolvedIsClassNode ? PREDICATED_CLASS_ITERATOR : PREDICATED_ATTRIBUTE_ITERATOR).createSimpleNode(region, iterator);
			}
		}
	}
	
	public static final class LetNodeRoleFactory
	{		
		private static final class LetVariableNodeRole extends AbstractVariableNodeRole
		{
			private boolean isNavigable;
			
			protected LetVariableNodeRole(@NonNull Phase phase, boolean isNavigable, boolean isClassNode) {
				super(phase, isClassNode);
				this.isNavigable = isNavigable;
			}

			@Override
			public boolean isMatchable() {
				return true;
			}

			@Override
			public boolean isNavigable() {
				return isNavigable;
			}

			@Override
			public String toString() {
				return phase + (isNavigable ? "-Navigable-" : "-Unnavigable-") + getClass().getSimpleName();
			}
		}
		
		private static final @NonNull AbstractVariableNodeRole CONSTANT_NAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.CONSTANT, true, false);
		private static final @NonNull AbstractVariableNodeRole CONSTANT_NAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.CONSTANT, true, true);
		private static final @NonNull AbstractVariableNodeRole CONSTANT_UNNAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.CONSTANT, false, false);
		private static final @NonNull AbstractVariableNodeRole CONSTANT_UNNAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.CONSTANT, false, true);
		private static final @NonNull AbstractVariableNodeRole LOADED_NAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.LOADED, true, false);
		private static final @NonNull AbstractVariableNodeRole LOADED_NAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.LOADED, true, true);
		private static final @NonNull AbstractVariableNodeRole LOADED_UNNAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.LOADED, false, false);
		private static final @NonNull AbstractVariableNodeRole LOADED_UNNAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.LOADED, false, true);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_NAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.PREDICATED, true, false);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_NAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.PREDICATED, true, true);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_UNNAVIGABLE_ATTRIBUTE_LET = new LetVariableNodeRole(Role.Phase.PREDICATED, false, false);
		private static final @NonNull AbstractVariableNodeRole PREDICATED_UNNAVIGABLE_CLASS_LET = new LetVariableNodeRole(Role.Phase.PREDICATED, false, true);
		
		private final @Nullable Boolean isClassNode;

		public LetNodeRoleFactory(@Nullable Boolean isClassNode) {
			this.isClassNode = isClassNode;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull Variable letVariable, @NonNull SimpleNode inNode) {
			Boolean resolvedIsClassNode = isClassNode;
			if (resolvedIsClassNode == null) {
				resolvedIsClassNode = !(letVariable.getType() instanceof DataType);
			}
			if (inNode.isNavigable()) {
				if (inNode.isConstant()) {
					return (resolvedIsClassNode ? CONSTANT_NAVIGABLE_CLASS_LET : CONSTANT_NAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
				else if (inNode.isLoaded()) {
					return (resolvedIsClassNode ? LOADED_NAVIGABLE_CLASS_LET : LOADED_NAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
				else {
					return (resolvedIsClassNode ? PREDICATED_NAVIGABLE_CLASS_LET : PREDICATED_NAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
			}
			else {
				if (inNode.isConstant()) {
					return (resolvedIsClassNode ? CONSTANT_UNNAVIGABLE_CLASS_LET : CONSTANT_UNNAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
				else if (inNode.isLoaded()) {
					return (resolvedIsClassNode ? LOADED_UNNAVIGABLE_CLASS_LET : LOADED_UNNAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
				else {
					return (resolvedIsClassNode ? PREDICATED_UNNAVIGABLE_CLASS_LET : PREDICATED_UNNAVIGABLE_ATTRIBUTE_LET).createSimpleNode(region, letVariable);
				}
			}
		}
	}
	
	public static class NullNodeRole extends AbstractSimpleNodeRole
	{
		protected NullNodeRole() {
			super(Role.Phase.CONSTANT);
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region) {
			return createSimpleNode(region, "«null»", region.getSchedulerConstants().getOclVoidClassDatumAnalysis());
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull TypedElement typedElement) {
			return createSimpleNode(region, "«null»", typedElement);
		}
		
		@Override
		public @Nullable String getStyle() {
			return "rounded";
		}

		@Override
		public boolean isMatchable() {
			return true;
		}

		@Override
		public boolean isNull() {
			return true;
		}
	}
	
	public static final class OperationNodeRoleFactory
	{
		private static class OperationNodeRole extends AbstractSimpleNodeRole
		{
			protected OperationNodeRole(@NonNull Phase phase) {
				super(phase);
			}

			@Override
			public @NonNull Integer getPenwidth() {
				return LINE_WIDTH;
			}

			@Override
			public @NonNull String getShape() {
				return "ellipse";
			}

			@Override
			public boolean isExpression() {
				return true;
			}

			@Override
			public boolean isMatchable() {
				return phase != Role.Phase.REALIZED;
			}

			@Override
			public boolean isOperation() {
				return true;
			}
		}
		
		private static final @NonNull OperationNodeRole CONSTANT_OPERATION = new OperationNodeRole(Role.Phase.CONSTANT);
		private static final @NonNull OperationNodeRole LOADED_OPERATION = new OperationNodeRole(Role.Phase.LOADED);
		private static final @NonNull OperationNodeRole PREDICATED_OPERATION = new OperationNodeRole(Role.Phase.PREDICATED);
		private static final @NonNull OperationNodeRole REALIZED_OPERATION = new OperationNodeRole(Role.Phase.REALIZED);

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull TypedElement typedElement, SimpleNode... argNodes) {
			boolean isLoaded = false;
			boolean isPredicated = false;
			boolean isRealized = false;
			if (argNodes != null) {
				for (SimpleNode argNode : argNodes) {
					if (argNode.isRealized()) {
						isRealized = true;
					}
					else if (argNode.isPredicated()) {
						isPredicated = true;
					}
					else if (argNode.isLoaded()) {
						isLoaded = true;
					}
				}
			}
			if (typedElement instanceof OperationCallExp) {
				Operation asOperation = ((OperationCallExp)typedElement).getReferredOperation();
				if (QVTbaseUtil.isIdentification(asOperation)) {
					DomainUsage usage = region.getSchedulerConstants().getDomainUsage(typedElement);
					if (!usage.isInput()) {
						isRealized = true;
					}
				}
			}
			if (isRealized) {
				return REALIZED_OPERATION.createSimpleNode(region, name, typedElement);
			}
			else if (isPredicated) {
				return PREDICATED_OPERATION.createSimpleNode(region, name, typedElement);
			}
			else if (isLoaded) {
				return LOADED_OPERATION.createSimpleNode(region, name, typedElement);
			}
			else {
				return CONSTANT_OPERATION.createSimpleNode(region, name, typedElement);
			}
		}
	}
	
	public static final class ParameterNodeRoleFactory
	{		
		private static final class ParameterNodeRole extends AbstractVariableNodeRole
		{
			protected ParameterNodeRole(boolean isClassNode) {
				super(Role.Phase.PREDICATED, isClassNode);
			}

			@Override
			public boolean isHead() {
				return true;
			}
		}

		
		private static final @NonNull ParameterNodeRole ATTRIBUTE_PARAMETER = new ParameterNodeRole(false);
		private static final @NonNull ParameterNodeRole CLASS_PARAMETER = new ParameterNodeRole(true);
		
		private final @Nullable Boolean isClassNode;

		public ParameterNodeRoleFactory(@Nullable Boolean isClassNode) {
			this.isClassNode = isClassNode;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
			Boolean resolvedIsClassNode = isClassNode;
			if (resolvedIsClassNode == null) {
				resolvedIsClassNode = !(classDatumAnalysis.getClassDatum().getType() instanceof DataType);
			}
			return (resolvedIsClassNode ? CLASS_PARAMETER : ATTRIBUTE_PARAMETER).createSimpleNode(region, name, classDatumAnalysis);
		}
	}
	
	public static final class PortNodeRoleFactory
	{
		private static final class PortNodeRole extends AbstractNodeRole
		{
//			private final boolean isHead;

			protected PortNodeRole(@NonNull Phase phase) { //, boolean isHead) {
				super(phase);
//				this.isHead = isHead;
			}

			@Override
			public @NonNull Node createNode(@NonNull Region region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
				return new ComplexTypedNode(this, region, name, classDatumAnalysis);
			}

			@Override
			public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
				throw new UnsupportedOperationException();
			}

			@Override
			
			public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name, @NonNull TypedElement typedElement) {
				throw new UnsupportedOperationException();
			}

			@Override
			public @NonNull Integer getPenwidth() {
				return Role.HEAD_WIDTH; //isHead ? Role.HEAD_WIDTH : Role.GUARD_WIDTH;
			}

			@Override
			public boolean isHead() {
				return true; //isHead;
			}

//			@Override
//			public boolean isInput() {
//				return isHead;
//			}

//			@Override
//			public boolean isNavigable() {
//				return true;
//			}

//			@Override
//			public boolean isOutput() {
//				return !isHead;
//			}
		}
		
		private static final @NonNull PortNodeRole CONSTANT_INPUT = new PortNodeRole(Role.Phase.CONSTANT); //, true);
//		private static final @NonNull PortNodeRole CONSTANT_OUTPUT = new PortNodeRole(Role.Phase.CONSTANT, false);
		private static final @NonNull PortNodeRole LOADED_INPUT = new PortNodeRole(Role.Phase.LOADED); //, true);
//		private static final @NonNull PortNodeRole LOADED_OUTPUT = new PortNodeRole(Role.Phase.LOADED, false);
		private static final @NonNull PortNodeRole PREDICATED_INPUT = new PortNodeRole(Role.Phase.PREDICATED); //, true);
//		private static final @NonNull PortNodeRole PREDICATED_OUTPUT = new PortNodeRole(Role.Phase.PREDICATED, false);
		private static final @NonNull PortNodeRole REALIZED_INPUT = new PortNodeRole(Role.Phase.REALIZED); //, true);
//		private static final @NonNull PortNodeRole REALIZED_OUTPUT = new PortNodeRole(Role.Phase.REALIZED, false);
		
//		private final boolean isHead;

		public PortNodeRoleFactory(/*boolean isHead*/) {
//			this.isHead = isHead;
		}

		public @NonNull Node createNode(@NonNull Region region, NodeRole.@NonNull Phase nodeRolePhase, @NonNull String name, @NonNull ClassDatumAnalysis classDatumAnalysis) {
			switch (nodeRolePhase) {
				case CONSTANT: return CONSTANT_INPUT.createNode(region, name, classDatumAnalysis);
				case LOADED: return LOADED_INPUT.createNode(region, name, classDatumAnalysis);
				case PREDICATED: return PREDICATED_INPUT.createNode(region, name, classDatumAnalysis);
				case REALIZED: return REALIZED_INPUT.createNode(region, name, classDatumAnalysis);
//				case CONSTANT: return (isHead ? CONSTANT_INPUT : CONSTANT_OUTPUT).createNode(region, name, classDatumAnalysis);
//				case LOADED: return (isHead ? LOADED_INPUT : LOADED_OUTPUT).createNode(region, name, classDatumAnalysis);
//				case PREDICATED: return (isHead ? PREDICATED_INPUT : PREDICATED_OUTPUT).createNode(region, name, classDatumAnalysis);
//				case REALIZED: return (isHead ? REALIZED_INPUT : REALIZED_OUTPUT).createNode(region, name, classDatumAnalysis);
				default: throw new UnsupportedOperationException();
			}
		}
	}

	private static final class RealizedVariableNodeRole extends AbstractVariableNodeRole
	{
		protected RealizedVariableNodeRole() {
			super(Role.Phase.REALIZED, true);
		}
		
		@Override
		public boolean isRealizedVariable() {
			return true;
		}
		
		@Override
		public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
			if (nodeRole instanceof GuardNodeRoleFactory.AbstractGuardNodeRole) {
				return this;
			}
			if (nodeRole instanceof StepNodeRoleFactory.AbstractStepNodeRole) {
				return this;
			}
			return super.merge(nodeRole);
		}

		@Override
		public String toString() {
			return getClass().getSimpleName();
		}
	}
	
/*	public static final class ResultNodeRoleFactory
	{
		private static final class ResultNodeRole extends AbstractSimpleNodeRole
		{
			protected ResultNodeRole(@NonNull Phase phase) {
				super(phase);
			}
			
			@Override
			public @Nullable String getStyle() {
				return("rounded");
			}

			@Override
			public boolean isMatchable() {
				return phase != Role.Phase.REALIZED;
			}
			
			@Override
			public boolean isResult() {
				return true;
			}
		}

		private static final @NonNull ResultNodeRole CONSTANT_RESULT = new ResultNodeRole(Role.Phase.CONSTANT);
		private static final @NonNull ResultNodeRole LOADED_RESULT = new ResultNodeRole(Role.Phase.LOADED);
		private static final @NonNull ResultNodeRole PREDICATED_RESULT = new ResultNodeRole(Role.Phase.PREDICATED);
		private static final @NonNull ResultNodeRole REALIZED_RESULT = new ResultNodeRole(Role.Phase.REALIZED);
		
		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name,
				@NonNull CallExp callExp, @NonNull SimpleNode sourceNode) {
			DomainUsage domainUsage = region.getSchedulerConstants().getDomainUsage(callExp);
			if (domainUsage.isEnforceable()) {
				return REALIZED_RESULT.createSimpleNode(region, name, callExp);
			}
			else if (sourceNode.isPredicated()) {
				return PREDICATED_RESULT.createSimpleNode(region, name, callExp);
			}
			else if (sourceNode.isLoaded()) {
				return LOADED_RESULT.createSimpleNode(region, name, callExp);
			}
			else {
				return CONSTANT_RESULT.createSimpleNode(region, name, callExp);
			}
		}
	} */
	
	public static final class StepNodeRoleFactory
	{
		private static abstract class AbstractStepNodeRole extends AbstractSimpleNodeRole
		{
			private final boolean isNavigable;
			
			protected AbstractStepNodeRole(@NonNull Phase phase, boolean isNavigable) {
				super(phase);
				this.isNavigable = isNavigable;
			}

			@Override
			public boolean isClassNode() {
				return true;
			}

			@Override
			public boolean isMatchable() {
				return true;
			}

			@Override
			public boolean isNavigable() {
				return isNavigable;
			}

			@Override
			public String toString() {
				return phase + (isNavigable ? "-NAVIGABLE-" : "-UNNAVIGABLE-") + getClass().getSimpleName();
			}
		}

		private static final class LoadedStepNodeRole extends AbstractStepNodeRole
		{
			protected LoadedStepNodeRole(boolean isNavigable) {
				super(Role.Phase.LOADED, isNavigable);
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.isHead()) {
					return this;
				}
				return super.merge(nodeRole);
			}
		}

		public static final class PredicatedStepNodeRole extends AbstractStepNodeRole
		{
			protected PredicatedStepNodeRole(boolean isNavigable) {
				super(Role.Phase.PREDICATED, isNavigable);
			}

			@Override
			public @NonNull NodeRole merge(@NonNull NodeRole nodeRole) {
				if (nodeRole.isHead()) {
					return this;
				}
				if (nodeRole instanceof RealizedVariableNodeRole) {
					return nodeRole;
				}
				return super.merge(nodeRole);
			}
		}

		private static final @NonNull LoadedStepNodeRole LOADED_NAVIGABLE_STEP = new LoadedStepNodeRole(true);
		private static final @NonNull LoadedStepNodeRole LOADED_UNNAVIGABLE_STEP = new LoadedStepNodeRole(false);
		private static final @NonNull PredicatedStepNodeRole PREDICATED_NAVIGABLE_STEP = new PredicatedStepNodeRole(true);
		private static final @NonNull PredicatedStepNodeRole PREDICATED_UNNAVIGABLE_STEP = new PredicatedStepNodeRole(false);
		
		private final @Nullable Boolean isNavigable;

		public StepNodeRoleFactory(@Nullable Boolean isNavigable) {
			this.isNavigable = isNavigable;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull String name,
				@NonNull CallExp callExp, @NonNull SimpleNode sourceNode) {
			boolean resolvedNavigable = isNavigable != null ? isNavigable.booleanValue() : sourceNode.isNavigable();
			boolean isDirty = false;
			if (callExp instanceof NavigationCallExp) {
				Property referredProperty = PivotUtil.getReferredProperty((NavigationCallExp)callExp);
				isDirty = region.getSchedulerConstants().isDirty(referredProperty);
			}
			if (!isDirty && sourceNode.isLoaded()) {
				return (resolvedNavigable ? LOADED_NAVIGABLE_STEP : LOADED_UNNAVIGABLE_STEP).createSimpleNode(region, name, callExp);
			}
			DomainUsage domainUsage = region.getSchedulerConstants().getDomainUsage(callExp);
			if (sourceNode.isPredicated() || domainUsage.isOutput() ) {
				return (resolvedNavigable ? PREDICATED_NAVIGABLE_STEP : PREDICATED_UNNAVIGABLE_STEP).createSimpleNode(region, name, callExp);
			}
			else {
				if (!isDirty) {
					return (resolvedNavigable ? LOADED_NAVIGABLE_STEP : LOADED_UNNAVIGABLE_STEP).createSimpleNode(region, name, callExp);
				}
				else {
					return (resolvedNavigable ? PREDICATED_NAVIGABLE_STEP : PREDICATED_UNNAVIGABLE_STEP).createSimpleNode(region, name, callExp);
				}
			}
		}
	}
	
	public static final class TrueNodeRole extends AbstractSimpleNodeRole
	{
		protected TrueNodeRole() {
			super(Role.Phase.CONSTANT);
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region) {
			SchedulerConstants schedulerConstants = region.getSchedulerConstants();
			org.eclipse.ocl.pivot.Class booleanType = schedulerConstants.getStandardLibrary().getBooleanType();
			DomainUsage primitiveUsage = schedulerConstants.getDomainAnalysis().getPrimitiveUsage();
			ClassDatumAnalysis classDatumAnalysis = schedulerConstants.getClassDatumAnalysis(booleanType, ClassUtil.nonNullState(primitiveUsage.getTypedModel(null)));
			return createSimpleNode(region, "«true»", classDatumAnalysis);
		}
		
		@Override
		public boolean isHead() {
			return true;
		}

		@Override
		public boolean isMatchable() {
			return true;
		}

		@Override
		public boolean isTrue() {
			return true;
		}
	}
	
	private static final class UnknownNodeRole extends AbstractSimpleNodeRole
	{
		protected UnknownNodeRole() {
			super(Role.Phase.OTHER);
		}

		@Override
		public @NonNull String getColor() {
			return ERROR_COLOR;
		}
	}

	public static final class UnrealizedVariableNodeRoleFactory
	{		
		private static final class UnrealizedVariableNodeRole extends AbstractVariableNodeRole
		{
			protected UnrealizedVariableNodeRole(boolean isClassNode) {
				super(Role.Phase.LOADED, isClassNode);
			}
		}
		
		private static final @NonNull UnrealizedVariableNodeRole UNREALIZED_ATTRIBUTE_VARIABLE = new UnrealizedVariableNodeRole(false);
		private static final @NonNull UnrealizedVariableNodeRole UNREALIZED_CLASS_VARIABLE = new UnrealizedVariableNodeRole(true);
		
		private final @Nullable Boolean isClassNode;

		public UnrealizedVariableNodeRoleFactory(@Nullable Boolean isClassNode) {
			this.isClassNode = isClassNode;
		}

		public @NonNull SimpleNode createSimpleNode(@NonNull SimpleRegion region, @NonNull Variable variable) {
			Boolean resolvedIsClassNode = isClassNode;
			if (resolvedIsClassNode == null) {
				resolvedIsClassNode = !(variable.getType() instanceof DataType);
			}
			return (resolvedIsClassNode ? UNREALIZED_CLASS_VARIABLE : UNREALIZED_ATTRIBUTE_VARIABLE).createSimpleNode(region, variable);
		}
	}
	
	public static final @NonNull AttributeNodeRoleFactory ATTRIBUTE = new AttributeNodeRoleFactory(null);
	public static final @NonNull NodeRole COMPOSING = new ComposingNodeRole();
	public static final @NonNull ElementNodeRoleFactory ELEMENT = new ElementNodeRoleFactory();
	public static final @NonNull NodeRole ERROR = new ErrorNodeRole();
	public static final @NonNull NodeRole EXTRA_GUARD = new AttributeNodeRoleFactory.ExtraGuardNodeRole();
	public static final @NonNull GuardNodeRoleFactory GUARD = new GuardNodeRoleFactory(null);
	public static final @NonNull PortNodeRoleFactory INPUT = new PortNodeRoleFactory(); //true);
	public static final @NonNull IteratorNodeRoleFactory ITERATOR = new IteratorNodeRoleFactory(null);
	public static final @NonNull LetNodeRoleFactory LET = new LetNodeRoleFactory(null);
	public static final @NonNull AttributeNodeRoleFactory NAVIGABLE_ATTRIBUTE = new AttributeNodeRoleFactory(true);
	public static final @NonNull StepNodeRoleFactory NAVIGABLE_STEP = new StepNodeRoleFactory(true);
	public static final @NonNull NullNodeRole NULL = new NullNodeRole();
	public static final @NonNull OperationNodeRoleFactory OPERATION = new OperationNodeRoleFactory();
//	public static final @NonNull PortNodeRoleFactory OUTPUT = new PortNodeRoleFactory(false);
	public static final @NonNull ParameterNodeRoleFactory PARAMETER = new ParameterNodeRoleFactory(null);
	public static final AttributeNodeRoleFactory.@NonNull RealizedAttributeNodeRole REALIZED_ATTRIBUTE = new AttributeNodeRoleFactory.RealizedAttributeNodeRole();
	public static final @NonNull AbstractVariableNodeRole REALIZED_VARIABLE = new RealizedVariableNodeRole();
	public static final @NonNull StepNodeRoleFactory STEP = new StepNodeRoleFactory(null);
	public static final @NonNull TrueNodeRole TRUE = new TrueNodeRole();
	public static final @NonNull NodeRole UNKNOWN = new UnknownNodeRole();
	public static final @NonNull AttributeNodeRoleFactory UNNAVIGABLE_ATTRIBUTE = new AttributeNodeRoleFactory(false);
	public static final @NonNull StepNodeRoleFactory UNNAVIGABLE_STEP = new StepNodeRoleFactory(false);
	public static final @NonNull UnrealizedVariableNodeRoleFactory UNREALIZED_VARIABLE = new UnrealizedVariableNodeRoleFactory(null);
}

Back to the top