-
Notifications
You must be signed in to change notification settings - Fork 11
/
Browsing.ns
5816 lines (5753 loc) · 193 KB
/
Browsing.ns
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
Newspeak3
'Root'
class Browsing usingPlatform: p ide: webIde
(* :exemplar: ide browsing *)
= (
(* An IDE for Newspeak on the web.
Copyright 2016-2017 Google Inc.
Copyright 2018-2022 Gilad Bracha.
*)
| (* imports *)
private StringBuilder = p kernel StringBuilder.
private Subject = p hopscotch Subject.
private Presenter = p hopscotch Presenter.
private SearchFieldFragment = p hopscotch fragments SearchFieldFragment.
private Window = p hopscotch Window.
private DOMParser = p hopscotch DOMParser.
private Color = p graphics Color.
private Gradient = p hopscotch Gradient.
private List = p collections List.
private Map = p collections Map.
private Set = p collections Set.
(* private OrderedMap = [p collections OrderedMap] on: Error do: [:e | Map].*)
private Exception = p kernel Exception.
private Proxy = p kernel Proxy.
private ActivationMirror = p mirrors ActivationMirror.
private ClassMirror = p mirrors ClassMirror.
private ObjectMirror = p mirrors ObjectMirror.
private ClosureMirror = p mirrors ClosureMirror.
private Message = p kernel Message.
private ClassDeclarationBuilder = p mirrors ClassDeclarationBuilder.
private Snapshotter = p operatingSystem = 'emscripten' ifTrue: [p victoryFuel Snapshotter].
private JSObject = p js global at: 'Object'.
private JSArray = p js global at: 'Array'.
private JSMath = p js global at: 'Math'.
private JSPromise = p js global at: 'Promise'.
private JSZip = p js global at: 'JSZip'.
private Date = p js global at: 'Date'.
(* module variables *)
body = (p js global at: 'document') at: 'body'.
localStorage = (p js global at: 'window') at: 'localStorage'.
atomicInstaller = p mirrors installer.
compiler = p mirrors compiler.
cachedPlatform = p.
ide = webIde.
detailAreaRatio = 3 asFloat.
captionColor = Color h: 240 s: 0.05 asFloat v: 0.9 asFloat.
cssConverter = cssConversionTable.
objectViews <Map[Symbol, List[Presenter class]]> = Map new.
currentWindow<IDEWindow>
nonExemplarClasses <Set[Symbol]> = Set withAll: {#Number. #Class}.
(* Style *)
styleHeaderPadRight <Float> = 0.0.
styleButtonSize <Float> = 30.
|
p hopscotch homeSubjectClass: HomeSubject.
initializeObjectViews.
) (
public class AssortedMethodsPresenter onSubject: s = DefinitionListPresenter onSubject: s (
(* The subject is a collection of MethodSubjects that can come from diverse sources (in the sense that they do not have to belong to the same class). The presenter displays them as a column of expandable method presenters and takes care of reasonably handling the various creation and deletion requests coming from them. *)
|
public title ::= 'Assorted Methods'. (* The title to use for the presenter *)
methodPresenters <List[ExpandableMethodPresenter]> ::= List new.
|) (
addButton = (
^nothing
)
public addNewItemTemplate = (
(* Handle a user's request to create a new method by displaying a new method template. *)
shouldNotImplement
)
definitionListMenu = (
^menuWithLabelsAndActions: {
{'Inspect Presenter' . [respondToInspectPresenter]}
}
)
public isKindOfAssortedMethodsPresenter ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfAssortedMethodsPresenter
)
listDescription ^ <String> = (
^'assorted methods'
)
contentPresenters ^ <List[MethodPresenter]> = (
|
methods <List[MethodSubject]> = subject elements sort: [
:m1 <MethodSubject> :m2 <MethodSubject> |
lexicallyLessOrEqual: m1 name than: m2 name
].
|
^methods collect: [:each | (each presenter) showClassName: true]
)
elementDescription ^ <String> = (
^'methods grouped by some criteria'
)
) : (
)
public class AssortedMethodsSubject onModel: m <Collection[MethodSubject]> = ProgrammingSubject onModel: m (
|
public title ::= 'Assorted Methods'.
elements_slot <Collection[MethodSubject | LazySlotSubject ]>
|
) (
public createPresenter = (
^(AssortedMethodsPresenter onSubject: self) title: title
)
public isKindOfAssortedMethodsSubject ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfAssortedMethodsSubject
)
public methodTemplateText ^ <String> = (
^
'messageSelector = (
)'
)
public methodSubjects ^ <Collection[MethodSubject]> = (
^model
)
public elements ^<Collection[MethodSubject]> = (
(* Answer a collection of subjects on individual elements of the collection which is our subject. *)
elements_slot isNil ifTrue: [
elements_slot:: methodSubjects.
^elements_slot
].
updateElements.
^elements_slot
)
updateElements = (
|
obsoleteSubjects <List[MethodSubject]> = List new.
|
elements_slot do: [:s <MethodSubject> |
(methodSubjects includes: s) ifFalse: [obsoleteSubjects add: s].
].
obsoleteSubjects do: [:s <MethodSubject> | elements_slot remove: s].
methodSubjects do: [:m <MethodSubject> |
(elements_slot includes: m) ifFalse: [
elements_slot add: m
].
].
)
) : (
)
class BasicView onSubject: s = ProgrammingPresenter onSubject: s (
) (
public isKindOfBasicView ^ <Boolean> = (
^true
)
isMyKind: other <Fragment> ^ <Boolean> = (
^other isKindOfBasicView
)
public title = (
^'Basic'
)
slots = (
| ss = subject slots. |
ss isEmpty ifTrue: [^nothing].
^minorHeadingBlock: (column: {
(label: #Slots) bold.
taggedColumn:
(ss collect:
[:slot <SlotSubject> | slot presenter])
}
)
)
lazySlots = (
| lss = subject lazySlots. |
lss isEmpty ifTrue: [^nothing].
^minorHeadingBlock: (column: {
(label: 'Lazy Slots') bold.
taggedColumn:
(lss collect:
[:slot <SlotSubject> | slot presenter])
}
)
)
public definition = (
^column: {slots. lazySlots}
)
) : (
)
public class BitOfWisdom text: s <String> actionLabel: l <String> actionBlock: b <[]> image: i = (|
public text <String> = s.
public image <Image> = i.
public actionLabel <String> = l.
public actionBlock <[]> = b.
|) (
) : (
public text: s <String> ^ <BitOfWisdom> = (
^text: s actionLabel: nil actionBlock: nil image: nil
)
public text: s <String> actionLabel: l <String> actionBlock: b <[]> ^ <BitOfWisdom> = (
^self
text: s
actionLabel: l
actionBlock: b
image: nil
)
public text: s image: i ^ <BitOfWisdom> = (
^text: s
actionLabel: nil
actionBlock: nil
image: i
)
)
class ClassActionsPresenter onSubject: s = ProgrammingPresenter onSubject: s () (
public isKindOfClassActionsPresenter ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfClassActionsPresenter
)
deployAsWebPageWithMirrorBuilders = (
#BOGUS yourself.
(ide deployment jsPackagerForPlatform: cachedPlatform)
packageApplicationConfiguration: (ide namespacing Root at: subject name)
withRuntimeConfiguration: ide deployment RuntimeWithMirrorBuilders
usingNamespace: ide namespacing Root.
)
deployAsWebPage = (
#BOGUS yourself.
(ide deployment jsPackagerForPlatform: cachedPlatform)
packageApplicationConfiguration: (ide namespacing Root at: subject name)
withRuntimeConfiguration: ide deployment Runtime
usingNamespace: ide namespacing Root.
)
definition = (
^(row: {
testActions.
mediumBlank.
deployAction.
mediumBlank.
editDeploymentsAction.
mediumBlank.
runAppAction.
})
mainAxisAlignToEnd.
)
deployAsVictoryFuel = (
| bytes = subject bytesForVictoryFuel. |
ide webFiles downloadFileName: subject name, '.vfuel' fromBytes: bytes.
)
deployAsVictoryFuelWithMirrors = (
| bytes = subject bytesForVictoryFuelWithMirrors. |
ide webFiles downloadFileName: subject name, '.vfuel' fromBytes: bytes.
)
future_deployAction = (
(* Eventually, we'll use the deployment manager for deployment.
At that point, this method will replace the current #deployAction
implementation. Alas, this will take a while, as we need to implement
a general strategy for reconstituting serialized aliens for this to work.
*)
subject isApplicationConfiguration ifFalse: [^nothing].
^link: '[deploy]' action: [
openMenu:: menuWithLabelsAndActions: (
ide deployment configurations collect: [:dc <DeploymentConfiguration> |
{'to ', dc name.
[ide deployment deploy: (ide namespacing Root at: subject name) on: dc]}]
)
]
)
respondToRunApp: paused = (
(* bogus: The subject might not be in the root namespace. *)
| appConfig manifest platform args thread |
appConfig:: ide namespacing Root at: subject name.
manifest:: ide namespacing manifest.
platform:: cachedPlatform.
args:: {}.
thread:: platform mirrors ActivationMirror invokeSuspended:
[(appConfig packageUsing: manifest) main: AppPlatform new args: args].
paused ifFalse: [thread resume].
thread isFulfilled ifFalse:
[enterSubject:: ide debugging ThreadSubject onModel: thread].
)
respondToRunTests = (
| thread |
thread:: cachedPlatform mirrors ActivationMirror invokeSuspended:
[enterSubject:: subject testingSubject].
thread resume.
thread isFulfilled
ifFalse:
[enterSubject:: ide debugging ThreadSubject onModel: thread].
)
respondToShowTests = (
| thread |
thread:: cachedPlatform mirrors ActivationMirror invokeSuspended:
[enterSubject:: subject inactiveTestingSubject].
thread resume.
thread isFulfilled
ifFalse:
[enterSubject:: ide debugging ThreadSubject onModel: thread].
)
public testActions = (
subject isTestConfiguration ifFalse: [^nothing].
^row: {
link: '[run tests]' action: [respondToRunTests].
link: '[show tests]' action: [respondToShowTests]}.
)
public runAppAction = (
subject isApplicationConfiguration ifFalse: [^nothing].
^row: {
link: '[run]' action: [respondToRunApp: false].
link: '[debug]' action: [respondToRunApp: true].
}
)
public editDeploymentsAction = (
| DeploymentConfigurationSubject = ide deployment DeploymentConfigurationSubject. |
subject isApplicationConfiguration ifFalse: [^nothing].
^link: '[configurations]' action: [
openMenu:: menuWithLabelsAndActions:
((ide deployment configurations) collect: [:dc <DeploymentConfiguration> |
{dc name. [enterSubject:: DeploymentConfigurationSubject onModel: dc]}]),
{{'Create New Deployment'. [enterSubject:: DeploymentConfigurationSubject onModel: ide deployment defaultConfiguration]}}
]
)
deployAsVictoryFuelWithHopscotch = (
| bytes = subject bytesForVictoryFuelWithHopscotch. |
ide webFiles downloadFileName: subject name, '.vfuel' fromBytes: bytes.
)
public deployAction = (
subject isApplicationConfiguration ifFalse: [^nothing].
^(link: '[deploy]' action: [
openMenu:: menuWithLabelsAndActions: {
{'as VictoryFuel'. [deployAsVictoryFuel]}.
{'as VictoryFuel with Mirrors'. [deployAsVictoryFuelWithMirrors]}.
{'as VictoryFuel with Hopscotch'. [deployAsVictoryFuelWithHopscotch]}.
{'as Web Page'. [deployAsWebPage]}.
{'as Web Page with Mirror Builders'. [deployAsWebPageWithMirrorBuilders]}.
}
]).
)
) : (
)
class ClassEntryPresenter onSubject: s <ClassSubject> = EntryPresenter onSubject: s () (
classCommentSummary ^ <String> = (
|
fullComment <String> = subject classCommentText.
endOfFirstSentence <Integer> = fullComment indexOf: '.'.
firstSentence <String> = fullComment copyFrom: 1 to: endOfFirstSentence.
|
^firstSentence
)
entryActionsMenu = (
^nothing
)
expandedDefinition = (
^subject presenter
)
public tag ^ <String> = (
^subject name
)
public isKindOfClassEntryPresenter ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfClassEntryPresenter
)
collapsedDefinition = (
^row1: {
defaultBlank.
(image: ide images classIcon)
height: styleButtonSize.
defaultBlank.
accessIndicator.
defaultBlank.
link: tag action: [enterSubject:: ClassSubject onDeclaration: subject classMirror].
} row2: {
(row: {deferred: [(label: subject classCommentSummary)
smallFont;
color: secondaryTextColor]})
compressibility: 1.
filler
compressibility: 0.
(ClassActionsPresenter onSubject: subject) elasticity: 1.
mediumBlank.
entryActionsMenu.
}
)
) : (
)
class ClassFactoryPresenter onSubject: s <ClassFactorySubject> = MethodPresenter onSubject: s (
(* Present the factory method, colorized. *)
| toggle <ToggleComposer> public showClassName <Boolean> ::= false. |
) (
changeResponse ^ <[:CodeMirrorFragment :Event]> = (
^[:ed <CodeMirrorFragment> :event <Event> |
colorizeHeaderSource: (crToLf: ed textBeingAccepted) withEditor: ed.
]
)
colorizeHeaderSource: s <String> withEditor: cm <CodeMirrorFragment> = (
ide colorizer colorizeHeader: s fromClass: subject classMirror via: (colorizingBlockFor: cm)
)
definition = (
toggle:: collapsed: [collapsedDefinition]
expanded: [expandedDefinition].
^toggle
)
public isKindOfClassFactoryPresenter ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfClassFactoryPresenter
)
nestingInformationLine ^ <Fragment> = (
| enclosingClasses rowElements |
enclosingClasses:: subject enclosingClasses.
rowElements:: List new.
enclosingClasses do:
[:each |
rowElements add: ((label: ' in ') color: tertiaryTextColor).
rowElements add: (linkToBrowseEnclosingClass: each)].
^row: rowElements asArray
)
editorDefinition = (
|
src = crToLf: subject classHeaderSource.
editor = codeMirror: src.
|
editor
changeResponse: changeResponse;
cancelResponse: cancelResponse;
acceptResponse: acceptResponse.
colorizeHeaderSource: src withEditor: editor.
^editor
)
cancelResponse ^ <[:CodeMirrorFragment]> = (
^[:ed <CodeMirrorFragment> |
ed text: subject classHeaderSource.
colorizeHeaderSource: (crToLf: subject classHeaderSource) withEditor: ed.
ed leaveEditState.
]
)
acceptResponse ^ <[:CodeMirrorFragment :Event]> = (
^[:ed <CodeMirrorFragment> :event <Event> |
| b <ClassDeclarationBuilder> = subject classMirror asBuilder. |
updateGUI: [
[b header source: ed textBeingAccepted.
ide installFromBuilders: {b}.
colorizeHeaderSource: (crToLf: ed textBeingAccepted) withEditor: ed.
ed leaveEditState] on: Error do: [:ex <Exception> | ed showMessage: ex printString] .
].
ed editor focus.
]
)
slotList ^ <Fragment> = (
| sl |
^column: {
(sl:: subject classMirror instanceSide slots) size > 0
ifTrue: [
column: {
(label: 'Slots')
bold.
smallBlank.
row: {
(column: (sl collect: [:ea <SlotDeclarationMirror> |
row: {
defaultBlank.
accessIndicator: ea accessModifier.
defaultBlank.
label: ea name.
}
])) elasticity: 1.
}
}.
] ifFalse: [nothing].
}
)
collapsedDefinition ^ <Fragment> = (
^column: {
helpSection.
headerDefinition.
label: subject classCommentSummary.
mediumBlank.
slotList.
}
)
expandedDefinition = (
^column: {
helpSection.
headerDefinition.
editorDefinition.
}
)
headerDefinition ^ <Fragment> = (
^row: {
defaultBlank.
accessIndicator.
defaultBlank.
(link: subject name action: [toggle toggle]) color: actionLinkColor.
showClassName
ifTrue: [nestingInformationLine]
ifFalse: [nothing].
filler.
(* Disabled for now. The story is a bit more complex for factory debugging.
deferred: [debugButton].
smallBlank.*)
dropDownMenu: [messagesMenu] image: ide images itemReferencesImage.
smallBlank.
helpButton.
smallBlank.
dropDownMenu: [methodMenuFor: subject name]
}.
)
helpText = (
|
mapping = Map new.
menuImage = Utilities uriForIconNamed: #hsDropdownImage.
referenceImage = Utilities uriForIconNamed: #itemReferencesImage.
exemplarHeaderDescription =
hasExemplars
ifTrue: ['<li><div class="hopscotchDebugMethodButton"> </div> Opens a debugger on an invocation of the method, with the arguments given by the method exemplar.</li>'] ifFalse: [''].
menuDescription =
hasExemplars
ifTrue: ['deleting the method, inspecting this presenter or opening an evaluator.'] ifFalse: ['deleting the method or inspecting this presenter.'].
editorEvaluatorDescription =
hasExemplars
ifTrue: ['<br>The editor is also an evaluator. See it''s help section for more details.'] ifFalse: [''].
|
mapping
at: #hopscotchAccessIndicator put: accessIndicator;
at: #hopscotchMethodMenuButton put: (dropDownMenu: [methodMenu]);
at: #hopscotchDebugMethodButton put: debugButton;
at: #hopscotchMethodReferencesButton put: (dropDownMenu: [messagesMenu] image: ide images itemReferencesImage);
at: #hopscotchHelpButton put: helpButton.
^ampleforth: 'This is a class factory method presenter. It can be either expanded or collapsed. In the collapsed state, the factory header is shown.
<br><br>From left to right, the factory header displays:
<ul>
<li><div class="hopscotchAccessIndicator"></div> The factory''s access modifier. It is always green, as Newspeak primary factories are public by definition.</li>
<li>The factory method selector.</li>', exemplarHeaderDescription,
'<li><div class="hopscotchMethodReferencesButton"> </div> Allows you to find senders and implementors of the factory method''s selector and of its slot accessors.</li>
<li><div class="hopscotchHelpButton"> </div> Shows this help message.</li>
<li><div class="hopscotchMethodMenuButton"> </div> Opens a menu of additional operations, such as ', menuDescription, '</li>
</ul>
Below the header we see the first sentence of the class comment, and below that a list of the classes'' slots. Each slot is prefixed by its access modifier. The color of the access modifier indicates whether the slot is public (green), protected (yellow) or private (red).
<br><br>
When the factory method presenter is expanded, an editor pane containing the factory source is displayed underneath the header. You can edit the source, allowing you change the factory name, the superclass clauses, and to add, remove or modify slot declarations and any other factory code. Once the code is changed, indicators appear at the top right corner of the editor pane. You can accept the changes by pressing, or revert back to the original by pressing . You can also accept changes by pressing Cmd-return (on mac) or Ctl-return (on Linux or Windows).
', editorEvaluatorDescription
mapping: mapping
)
) : (
)
class ClassFactorySubject onClassModel: m <ClassModel> = MethodSubject onMethodModel: m (
) (
public accessModifier ^ <Symbol> = (
^#public
)
public classCommentSummary ^ <String> = (
|
fullComment <String> = classCommentText.
endOfFirstSentence <Integer> = fullComment indexOf: '.'.
firstSentence <String> = fullComment copyFrom: 1 to: endOfFirstSentence.
|
^firstSentence
)
classCommentText ^<String> = (
| comment = classMirror header classComment. |
nil = comment ifTrue: [^''].
^comment
)
public classDeclaration ^ <ClassDeclarationMirror> = (
^classMirror
)
public classHeaderSource = (
^classMirror header source
)
public classMirror ^ <ClassDeclarationMirror> = (
^model klass
)
public createPresenter ^ <ClassFactoryPresenter> = (
^ClassFactoryPresenter onSubject: self
)
public delete = (
Error signal: 'cannot delete primary class factory'
)
isMyKind: s <Subject> ^ <Boolean> = (
^s isKindOfClassFactorySubject
)
public name ^ <Symbol> = (
^classMirror primaryFactorySelector
)
public isKindOfClassFactorySubject ^ <Boolean> = (
^true
)
public metadata ^ <Map[String, String]> = (
^classMirror header metadata
)
public primaryFactorySelector ^ <Symbol> = (
^classMirror primaryFactorySelector
)
public source ^ <String> = (
^classHeaderSource
)
public enclosingClassScope ^ <ObjectMirror | Nil> = (
(* Produce an object that will serve as the enclosing scope when debugging the factory live *)
| enclosing <ObjectMirror> = enclosingScope. |
#BOGUS.
enclosing isNil ifTrue: [^nil].
enclosing getClass enclosingObject reflectee isNil ifTrue: [(* return ide scope *) ^hiddenWorkspace].
^enclosing getClass enclosingObject
)
public enclosingScope ^ <ObjectMirror> = (
#BOGUS.
)
public messages ^ <List[Symbol]> = (
| result <List[Symbol]> = List new. |
classMirror instanceSide slots do: [:slot <SlotDeclarationMirror> |
result add: slot name.
slot isMutable ifTrue: [result add: slot name, ':']
].
classMirror header selectors do: [:message |
(result indexOf: message) = 0 ifTrue: [result add: message]
].
^result
)
) : (
public onModel: m <ClassDeclarationMirror> = (
^onClassModel: (ClassModel declaration: m exemplar: nil)
)
)
class ClassPresenter onSubject: s = ProgrammingPresenter onSubject: s (
|
public lazySlotsPresenter <LazySlotGroupPresenter>
public nestedClassesPresenter <NestedClassGroupPresenter>
public instanceMethodsPresenter <MethodGroupPresenter>
public classMethodsPresenter <MethodGroupPresenter>
classActionsPresenter <ClassActionsPresenter> ::= (ClassActionsPresenter onSubject: subject) elasticity: 1.
|
) (
changeResponse ^ <[:CodeMirrorFragment :Event]> = (
^[:ed <CodeMirrorFragment> :event <Event> |
colorizeHeaderSource: (crToLf: ed textBeingAccepted) withEditor: ed.
]
)
classActionsMenu = (
^menuWithLabelsAndActions: {
{'Save to File'. [respondToSave]}.
#separator.
{'Inspect Mirror'. [inspectObject: subject classMirror]}.
{'Inspect Presenter'. [respondToInspectPresenter]}.
#separator.
{'Delete'. [respondToDelete]}.
}
)
classCommentSummary ^ <String> = (
|
fullComment <String> = subject classCommentText.
endOfFirstSentence <Integer> = fullComment indexOf: '.'.
firstSentence <String> = fullComment copyFrom: 1 to: endOfFirstSentence.
|
^firstSentence
)
classNameAndContainmentDefinition ^ <Fragment> = (
^column: {
classNameAndHierarchySummary.
preambleLine.
label: subject classCommentSummary.
}
)
classSourceDefinition = (
| src = crToLf: subject classHeaderSource. editor = codeMirror: src. |
editor
changeResponse: changeResponse;
acceptResponse: acceptResponse.
colorizeHeaderSource: src withEditor: editor.
^editor
)
colorizeHeaderSource: s <String> withEditor: cm <CodeMirrorFragment> = (
ide colorizer colorizeHeader: s fromClass: subject classMirror via: (colorizingBlockFor: cm)
)
expandedHeadingDefinition ^ <Fragment> = (
^column: {
classNameAndHierarchySummary.
(ClassFactorySubject onModel: subject classMirror) presenter
}
)
headingDefinition ^ <Fragment> = (
^(column: {
expanded: [expandedHeadingDefinition]
collapsed: [classNameAndHierarchySummary].
}) color: (Color h: 240 s: 0.05 v: 0.9).
)
initializerDefinition ^ <Fragment> = (
^nothing
)
inspectSelf ^ <Fragment> = (
^row: {
filler.
link: 'Inspect Presenter' action: [enterSubject:: ObjectSubject onModel: (ObjectMirror reflecting: self)]
}
)
public isKindOfClassPresenter ^ <Boolean> = (
^true
)
isMyKind: f <Fragment> ^ <Boolean> = (
^f isKindOfClassPresenter
)
minorClassHeadingBlock: body = (
^(padded: body with: {10. 5. styleHeaderPadRight. 5.})
color: minorClassHeadingColor
)
minorClassHeadingColor = (
^Gradient
from: (Color h: 240 s: 0.02 v: 0.94)
to: (Color h: 240 s: 0.02 v: 0.9)
)
preambleLine = (
(* The line showing the class constructor syntax, e.g. 'Foo foo: x = Bar'. The superclass clause, if present, becomes a link to browse the superclass. *)
| preamble <String> equalIndex <Integer> prefix <String> suffix <String> |
preamble:: subject classMirror header preamble.
equalIndex:: preamble indexOf: "=".
equalIndex = 0
ifTrue:
[prefix:: preamble.
suffix:: '']
ifFalse:
[prefix:: (preamble copyFrom: 1 to: equalIndex - 1).
suffix:: (preamble copyFrom: equalIndex + 1 to: preamble size)].
^suffix isEmpty
ifTrue:
[label: prefix]
ifFalse:
[row: {
label: prefix, ' = '.
link: suffix action: [respondToBrowseSuperclass]
}]
)
respondToDelete = (
| enclosing = subject enclosingClassSubject. |
updateGUI: [
subject deleteClass.
enclosing isNil
ifFalse: [enterSubject: enclosing]
ifTrue: [enterSubject: NamespaceSubject new]
]
)
respondToSave = (
ide webFiles downloadFileName: subject name, '.ns' fromString: subject compilationUnitSource.
)
acceptResponse ^ <[:CodeMirrorFragment :Event]> = (
^[:ed <CodeMirrorFragment> :event <Event> |
| b <ClassDeclarationBuilder> = subject classMirror asBuilder. |
(*('ed text:', ed textBeingAccepted) out.*)
b header source: ed textBeingAccepted.
ide installFromBuilders: {b}.
colorizeHeaderSource: (crToLf: ed textBeingAccepted) withEditor: ed.
ed leaveEditState.
]
)
nestedClass: cdm <ClassDeclarationMirror> = (
^collapsed: [row: {
defaultBlank.
accessIndicator.
defaultBlank.
link: cdm simpleName action: [enterSubject:: ClassSubject onDeclaration: cdm]
}
]
expanded: [(ClassSubject onModel: cdm) presenter]
)
classNameAndHierarchySummary = (
| parts <List[Fragment]> |
parts:: List new.
subject enclosingClassSubjects
do: [:ecs | parts add: (link: ecs name action: [enterSubject:: ecs])]
separatedBy: [parts add: ( label: ' in ')].
^column: {
row: {
smallBlank.
(image: ide images classIcon)
height: styleButtonSize.
smallBlank.
row: parts.
filler.
classActionsPresenter.
smallBlank.
itemReferencesButtonWithAction: [browseSelector: subject name].
smallBlank.
saveButtonWithAction: [respondToSave].
smallBlank.
refreshButton.
smallBlank.
helpButton.
smallBlank.
dropDownMenu: [classActionsMenu].
}
}
)
helpText ^ <Fragment> = (
|
mapping = Map new.
menuImage = Utilities uriForIconNamed: #hsDropdownImage.
referenceImage = Utilities uriForIconNamed: #itemReferencesImage.
classActions <ClassActionsPresenter> = classActionsPresenter.
appActionsHelp <String> =
subject isApplicationConfiguration ifTrue: [
mapping
at: #classDeployAction put: classActions deployAction;
at: #classEditDeploymentsAction put: classActions editDeploymentsAction;
at: #classRunAppAction put: classActions runAppAction.
'Next, because this is a application configuration class, come links for managing application configurations
<ul>
<li><div class = "classDeployAction"></div>Bring up a menu of options for deploying this application configuration</li>
<li><div class = "classEditDeploymentsAction"></div>Add or modify deployment options.</li>
<li><div class = "classRunAppAction"></div>Run or debug the app.</li>
</ul>'
] ifFalse: [''].
testActionsHelp <String> =
subject isTestConfiguration ifTrue: [
mapping
at: #classTestActions put: classActions testActions.
' Next, because this is a test configuration class, come links <div class = "classTestActions"></div>for running or displaying the tests for this test configuration.'
] ifFalse: [''].
|
subject isApplicationConfiguration ifTrue: [
] ifFalse: [].
mapping
at: #classTestActions put: classActions testActions;
at: #classDeployAction put: classActions deployAction;
at: #classEditDeploymentsAction put: classActions editDeploymentsAction;
at: #classRunAppAction put: classActions runAppAction;
at: #hopscotchClassActionsMenuButton put: (dropDownMenu: [classActionsMenu]);
at: #hopscotchClassReferencesButton put: (itemReferencesButtonWithAction: [browseSelector: subject name]);
at: #hopscotchHelpButton put: helpButton;
at: #hopscotchRefreshButton put: refreshButton;
at: #hopscotchSaveButton put: (saveButtonWithAction: [respondToSave]).
^ampleforth: 'A class presenter provides a structured view of a class. The first line tells you the class name and what classes, if any, it is nested in. ', appActionsHelp, testActionsHelp, ' The class presenter also provides the following buttons:
<ul>
<li> <div class="hopscotchClassReferencesButton"> </div>Allows you to find references to it. </li>
<li><div class="hopscotchSaveButton"> </div> Downloads it (i.e., saves it to a file)
.</li>
<li><div class="hopscotchRefreshButton"> </div> Refreshes the display</li>
<li><div class="hopscotchHelpButton"> </div> Shows this help message.</li>
<li> <div class="hopscotchClassActionsMenuButton"> </div> Opens a menu of additional operations, such as deleting the class or inspecting this presenter or a mirror on this class declaration.</ul> <br>
The line below provides access to the class'' primary factory. You can access senders and implementers of the factory and the slots it defines via <img src="', referenceImage , '" alt="" width="30" height="30">, or access the menu via <img src="', menuImage, '" alt="" width="30" height="30">. <br>
The following three sections manage nested classes, instance and class methods respectively. ' mapping: mapping
)
public definition ^ <Fragment> = (
^column: {
helpSection.
headingDefinition.
lazySlotsPresenter:: subject lazySlotsSubject presenter.
nestedClassesPresenter:: subject nestedClassesSubject presenter.
instanceMethodsPresenter:: subject methodsSubject presenter.
classMethodsPresenter:: subject classMethodsSubject presenter.
}
)
) : (
)
public class ClassSubject onClassModel: m <ClassModel> = ProgrammingSubject onModel: m (
|
public exemplar <ObjectMirror> ::= classModel exemplar.
lazySlotsSubject_slot <LazySlotGroupSubject>
nestedClassesSubject_slot <NestedClassGroupSubject>
methodsSubject_slot <MethodGroupSubject>
classMethodsSubject_slot <MethodGroupSubject>
objectSubject_slot <ObjectSubject>
|
) (
public accessModifier = (
^classMirror accessModifier
)
public classCommentSummary ^ <String> = (
|
fullComment <String> = classCommentText.
endOfFirstSentence <Integer> = fullComment indexOf: '.'.
firstSentence <String> = fullComment copyFrom: 1 to: endOfFirstSentence.
|
^firstSentence
)
public classCommentText ^<String> = (
| comment = classMirror header classComment. |
nil = comment ifTrue: [^''].
^comment
)
public classHeaderSource = (
^classMirror header source
)
public isApplicationConfiguration ^ <Boolean> = (
^isTopLevel and: [
classMirror primaryFactorySelector = #packageUsing: or: [
classMirror classSide methods includesMirrorNamed: #packageUsing:
]
]
)
public isKindOfClassSubject ^ <Boolean> = (
^true
)
isMyKind: s <Subject> ^ <Boolean> = (
^s isKindOfClassSubject
)
public testingSubject = (
#NAMESPACEBOGUS.
^ide minitestUI TestingInProgressSubject
onConfiguration: (ide namespacing Root at: name)
platform: cachedPlatform
minitest: ide minitest
)
public title = (
^name
)
public runApp = (
| appDef <Class> app <Object> |
appDef:: ide namespacing Root at: name.
app:: appDef packageUsing: ide namespacing manifest.
app main: cachedPlatform args: {}
)
public bytesForVictoryFuel ^ <ByteArray> = (
^bytesForVictoryFuelWithRuntime: ide psoupDeploymentRuntime
)
public bytesForVictoryFuelWithMirrors ^ <ByteArray> = (
^bytesForVictoryFuelWithRuntime: ide psoupWithMirrorsDeploymentRuntime
)
public bytesForVictoryFuelWithRuntime: runtimeClass ^ <ByteArray> = (
| appDef <Class> = ide namespacing Root at: name. |
^ide deployment PSoupPackager packageApplicationConfiguration: appDef withRuntimeConfiguration: runtimeClass usingNamespace: ide namespacing Root
)
public compilationUnitSource ^ <String> = (
isTopLevel ifTrue: [
^compilationUnitFromSource: classMirror source
].
^classMirror source
)
public inactiveTestingSubject = (
#NAMESPACEBOGUS.
^ide minitestUI TestingOutcomeSubject
onConfiguration: (ide namespacing Root at: name)
platform: cachedPlatform
minitest: ide minitest
)
public isTestConfiguration = (
^isTopLevel and: [
classMirror primaryFactorySelector = #packageTestsUsing: or: [
classMirror classSide methods includesMirrorNamed: #packageTestsUsing:
]
]
)
public createPresenter = (
^chosenPresenter
)
objectSubject ^ <ObjectSubject> = (
objectSubject_slot isNil ifTrue: [
objectSubject_slot:: ObjectSubject onModel: exemplar.
].
^objectSubject_slot
)
public isTopLevel = (
^nil = classMirror enclosingClass
)
public name = (
^classMirror name
)
public classMethodsSubject ^ <MethodGroupSubject> = (
classMethodsSubject_slot isNil ifTrue: [
| methodsModel <MirrorGroupModel> =
MirrorGroupModel mirrorGroup: classMirror classSide methods ofMixin: classMirror classSide exemplar: exemplar.
|
classMethodsSubject_slot:: MethodGroupSubject onModel: methodsModel
].
^classMethodsSubject_slot
)
public methodsSubject ^ <MethodGroupSubject> = (
methodsSubject_slot isNil ifTrue: [
| methodsModel <MirrorGroupModel> =
MirrorGroupModel mirrorGroup: classMirror instanceSide methods ofMixin: classMirror instanceSide exemplar: exemplar.
|
methodsSubject_slot:: MethodGroupSubject onModel: methodsModel
].
^methodsSubject_slot
)
public nestedClassesSubject ^ <NestedClassGroupSubject> = (
nestedClassesSubject_slot isNil ifTrue: [
| nestedClassesModel <MirrorGroupModel> =
MirrorGroupModel mirrorGroup: classMirror instanceSide ofMixin: classMirror instanceSide exemplar: exemplar.
|
nestedClassesSubject_slot:: NestedClassGroupSubject onModel: nestedClassesModel
].
^nestedClassesSubject_slot
)
public classModel ^ <ClassModel> = (
^model
)
public classMirror ^ <ClassDeclarationMirror> = (
^classModel klass
)
public enclosingClassSubject ^ <ClassSubject> = (
^isTopLevel ifFalse: [ClassSubject onDeclaration: classMirror enclosingClass]
)