-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathHopscotchWebIDE.ns
More file actions
1062 lines (1008 loc) · 46.2 KB
/
Copy pathHopscotchWebIDE.ns
File metadata and controls
1062 lines (1008 loc) · 46.2 KB
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
'Newspeak'
class HopscotchWebIDE packageUsing: manifest = Object new (
(* The Newspeak IDE in the web browser. *)
|
private Browsing = manifest Browsing.
private BuildInfo = manifest BuildInfo.
private CombinatorialParsing = manifest CombinatorialParsing.
private Debugging = manifest Debugging.
private DeploymentManager = manifest DeploymentManager.
private MetadataParsing = manifest MetadataParsing.
private Minitest = manifest Minitest.
private MinitestUI = manifest MinitestUI.
private Namespacing = manifest Namespacing.
private NewspeakColorization = manifest NewspeakColorization.
private NewspeakGrammar = manifest NewspeakGrammar.
private NewspeakASTs = manifest NewspeakASTs.
private NewspeakParsing = manifest NewspeakParsing.
private NewspeakTypechecker = manifest NewspeakTypechecker.
private NewspeakPrettyPrinter = manifest NewspeakPrettyPrinter.
private Documents = manifest Documents.
private DocumentHolder = manifest DocumentHolder.
private WorkspaceHolder = manifest WorkspaceHolder.
private WorkspaceManager = manifest WorkspaceManager.
private RuntimeForPrimordialSoup = manifest RuntimeForPrimordialSoup.
private RuntimeWithMirrorsForPrimordialSoup = manifest RuntimeWithMirrorsForPrimordialSoup.
private WebCompiler = manifest WebCompiler.
private AIAccess = manifest AIAccess.
private AI_IDE_Support = manifest AI_IDE_Support.
private Repositories = manifest Repositories.
(* MemoryHole — version control abstraction. Phase 1 ships the
abstraction core (VCSLib + four sub-modules); no backend, no
UI yet. See VCSLib.ns for the rationale. *)
private VCSLib = manifest VCSLib.
private VCSCore = manifest VCSCore.
private VCSDiffing = manifest VCSDiffing.
private VCSSourceMirrors = manifest VCSSourceMirrors.
private VCSIsomorphicGitBackendProvider = manifest VCSIsomorphicGitBackendProvider.
(* Web stuff *)
private WebFiles = manifest WebFiles.
private JSON = manifest JSON.
(* JS stuff *)
private NewspeakCompilation = manifest NewspeakCompilation.
private JavascriptGeneration = manifest JavascriptGeneration.
private Newspeak2JSCompilation = manifest Newspeak2JSCompilation.
private ActorsForJS = manifest ActorsForJS.
private AliensForJS = manifest AliensForJS.
private MirrorsForJS = manifest MirrorsForJS.
private MirrorGroups = manifest MirrorGroups.
private KernelForJS = manifest KernelForJS.
private Collections = manifest Collections.
private Streams = manifest Streams.
private RuntimeForHopscotchForHTML = manifest RuntimeForHopscotchForHTML.
private RuntimeForJS = manifest RuntimeForJS.
private RuntimeForJSWithMirrorBuilders = manifest RuntimeForJSWithMirrorBuilders.
private testModules = {manifest AccessModifierTesting. manifest AccessModifierTestingConfiguration. manifest KernelTests. manifest KernelTestsConfiguration. manifest MinitestTests. manifest MinitestTestsConfiguration. manifest MirrorTesting. manifest MirrorTestingConfiguration. manifest MirrorTestingModel. manifest MirrorBuilderTesting. manifest MirrorBuilderTestingConfiguration. manifest ActivationMirrorTesting. manifest ActivationMirrorTestingConfiguration. manifest JSTesting. manifest JSTestingConfiguration. manifest NewspeakTypecheckerTesting. manifest NewspeakTypecheckerTestingConfiguration. manifest NewspeakPrettyPrinterTesting. manifest NewspeakPrettyPrinterTestingConfiguration. manifest MemoryHoleTesting. manifest MemoryHoleTestingConfiguration. }.
(* private imagePaths = HopscotchImagePaths packageUsing: manifest. *)
private standardNames <Set[String]>
private standardIconNames <Set[String]>
|
) (
(* manifest codemirror. *)
class HopscotchImagePaths packageUsing: manifest = Object new (
(* We expect the manifest to store paths that can be converted into usable obejcts at runtime. Eventually these should become Resource objects with more general properties. *)
|
private addImage_resource = manifest addImage.
private ampleforthDocument_resource = manifest ampleforthDocument.
private classImage_resource = manifest classImage.
private classPresenterImage_resource = manifest classPresenterImage.
private classUnknownImage_resource = manifest classUnknownImage.
private collapseImage_resource = manifest collapseImage.
private expandImage_resource = manifest expandImage.
private privateAccessImage_resource = manifest privateImage.
private protectedAccessImage_resource = manifest protectedImage.
private publicAccessImage_resource = manifest publicImage.
private saveImage_resource = manifest saveImage.
private sectionImage_resource = manifest sectionImage.
|
) (
) : ()
public class HopscotchImages usingPlatform: p = Object new (
(* This class stores the actual image objects provided by the UI; The images are lazily computed based on their paths. *)
|
private JsImage = platform js global at: 'Image'.
|
) (
lazy public addImage = resolveImage: imagePaths addImage_resource.
lazy public ampleforthDocument = resolveImage: imagePaths ampleforthDocument_resource.
lazy public classImage = resolveImage: imagePaths classImage_resource.
lazy public classPresenterImage = resolveImage: imagePaths classPresenterImage_resource.
lazy public classUnknownImage = resolveImage: imagePaths classUnknownImage_resource.
lazy public collapseImage = resolveImage: imagePaths collapseImage_resource.
lazy public expandImage = resolveImage: imagePaths expandImage_resource.
lazy public privateAccessImage = resolveImage: imagePaths privateImage_resource.
lazy public protectedAccessImage = resolveImage: imagePaths protectedImage_resource.
lazy public publicAccessImage = resolveImage: imagePaths publicImage_resource.
lazy public saveImage = resolveImage: imagePaths saveImage_resource.
lazy public sectionImage = resolveImage: imagePaths sectionImage_resource.
resolveImage: path <String> ^<Alien[Image]> = (
^JsImage new at: 'src' put: path;
yourself
)
) : ()
class RestoreDialog usingPlatform: p = Object new (
|
private List = p collections List.
private Presenter = p hopscotch Presenter.
private Subject = p hopscotch Subject.
window = p hopscotch HopscotchWindow openSubject: (RestoreDialogSubject onModel: p).
|
) (
public class RestoreDialogSubject onModel: p = Subject onModel: p (
) (
public isKindOfRestoreDialogSubject ^<Boolean> = (
^true
)
isMyKind: other <Subject> ^<Boolean> = (
^other isKindOfRestoreDialogSubject
)
public createPresenter = (
^RestoreDialogPresenter onSubject: self
)
public loadSaved = (
window exit.
setupIDEWith: (loadFrom: #lastSaved usingPlatform: model) using: model
)
public restoreBackup = (
window exit.
setupIDEWith: (loadFrom: #backup usingPlatform: model) using: model
)
public useCurrent = (
window exit.
setupIDEWith: List new using: model
)
public title ^<String> = (
^'Newspeak IDE'
)
) : ()
class RestoreDialogPresenter onSubject: s = Presenter onSubject: s (
) (
public isKindOfRestoreDialogPresenter ^<Boolean> = (
^true
)
isMyKind: other <Fragment> ^<Boolean> = (
^other isKindOfRestoreDialogPresenter
)
definition = (
^column: {label: 'You have backup changes that are newer than your last save. Do you want to restore these changes, or load from the last save?'. row: {button: 'Restore from backup'
action: [ subject restoreBackup ]. button: 'Load older saved version'
action: [ subject loadSaved ]. button: 'Use current version, ignoring both saved and backup versions'
action: [ subject useCurrent ]. }. }
)
) : ()
) : ()
class HopscotchWebIDE usingPlatform: p = Object new (
|
public Map = p collections Map.
private List = p collections List.
private StringBuilder = p kernel StringBuilder.
private Promise = p js global at: 'Promise'.
public images = p hopscotch images.
public buildVersion = BuildInfo version.
(* HopscotchImages usingPlatform: p *)
public browsing = Browsing usingPlatform: p ide: self.
public debugging = Debugging usingPlatform: p ide: self.
public namespacing = Namespacing usingPlatform: p.
public workspaceHolder = WorkspaceHolder usingPlatform: p ide: self.
public theWorkspaceManager = WorkspaceManager usingPlatform: p ide: self.
public documents = Documents usingPlatform: p ide: self.
public documentHolder = DocumentHolder usingDocumentClass: documents Document
ide: self.
(* AIAccess now lives on the platform; the chat UI classes are
folded into Hopscotch itself. AI_IDE_Support reaches both through
`platform hopscotch` directly. *)
public aiSupport = AI_IDE_Support usingPlatform: p ide: self.
public repositories = Repositories usingPlatform: p ide: self.
public minitest = Minitest usingPlatform: p.
public minitestUI = MinitestUI usingPlatform: p minitest: minitest ide: self.
public parserLib = CombinatorialParsing usingPlatform: p.
public grammar = NewspeakGrammar usingPlatform: p parsers: parserLib.
public colorizer = (NewspeakColorization usingPlatform: p grammar: grammar) NS3BrowserColorizer new.
public webFiles = WebFiles usingPlatform: p.
public json = JSON usingPlatform: p.
public deployment
public psoupDeploymentRuntime = RuntimeForPrimordialSoup.
public psoupWithMirrorsDeploymentRuntime = RuntimeWithMirrorsForPrimordialSoup.
public psoupWithHopscotchDeploymentRuntime = RuntimeForHopscotchForHTML.
public localStorage = p js localStorage.
public atomicInstaller = p mirrors installer.
(* Captured for the lazy drafts slot below, which constructs a
VCSIsomorphicGitBackendProvider on first access. Factory params
aren't in scope of lazy-slot initializers (they run at first read,
not at instance construction). *)
private platformHolder = p.
Date = p js global at: 'Date'.
version_slot ::= maxStoredVersion.
|
populateNamespaceUsingPlatform: p.
deployment:: DeploymentManager usingPlatform: p ide: self.
(* Restore the user's persisted Repositories AFTER seeding so the
bootstrap namespaces (Newspeak, PrimordialSoup) are populated by
the time any repo's namespaceKey points at one. Restoration was
previously called from inside the Repositories module's slot
init, which ran before seeding -- bound repos would race-create
empty placeholder namespaces and the seeding would then skip
them. *)
repositories restorePersistedRepositories.
) (
lazy public drafts = (VCSIsomorphicGitBackendProvider usingPlatform: platformHolder) DraftsRepo storeNamed: 'newspeak-ide-drafts'
dir: '/drafts'.
lazy public typechecker = makeTypechecker.
(* Construct a NewspeakTypechecker using a snapshot of the IDE Root
namespace, filtered to behaviors (the typechecker only ever
reflects on classes; Root also holds documents, forms, etc.). *)
(* Returns a freshly-constructed typechecker. Menu actions call this
per click; the lazy typechecker slot is reserved for the eventual
incremental-invalidation flow. *)
lazy public prettyPrinter = makePrettyPrinter.
makeTypechecker = (
| asts filteredNs |
asts:: NewspeakASTs usingPlatform: platformHolder.
filteredNs:: Map new.
namespacing Root keysAndValuesDo: [:k :v |
v isKindOfBehavior ifTrue: [ filteredNs at: k put: v ]
].
^NewspeakTypechecker usingPlatform: platformHolder
ast: asts
namespace: filteredNs
)
public freshTypechecker
(* Build the shared NewspeakPrettyPrinter instance used by the
IDE's 'Pretty Print' / 'Pretty Print Selection' menu options.
Reuses the IDE's existing grammar and constructs fresh AST,
parsing, and metadata-parsing instances. *)
= (
^makeTypechecker
)
makePrettyPrinter = (
| asts parsing md cp |
asts:: NewspeakASTs usingPlatform: platformHolder.
parsing:: NewspeakParsing usingPlatform: platformHolder
grammar: grammar
asts: asts.
cp:: parsing CommonParser new.
md:: MetadataParsing usingPlatform: platformHolder.
^NewspeakPrettyPrinter usingPlatform: platformHolder
ast: asts
parser: cp
metadata: md
)
public prettyPrintMethodOr: src <String> ^<String> = (
^[ prettyPrinter prettyPrintMethod: src ] on: Error do: [:e | src ]
)
public prettyPrintLazySlotOr: src <String> ^<String> = (
^[ prettyPrinter prettyPrintLazySlot: src ] on: Error do: [:e | src ]
)
public prettyPrintClassHeaderOr: src <String> ^<String> = (
^[ prettyPrinter prettyPrintClassHeader: src ] on: Error do: [:e | src ]
)
public launch: s <Subject> inWindow: w <HopscotchShell class> = (
browsing launch: s inWindow: w
)
public launch: s <Subject> = (
browsing launch: s inWindow: browsing IDEWindow
)
backup ^<Map[Symbol, String]> = (
^[ json decode: (localStorage getItem: #backup) ] on: Error
do: [:e | Map new ]
)
topMostBuilderOf: b <ClassDeclarationBuilder> ^<ClassDeclarationBuilder> = (
| outermost <ClassDeclarationBuilder> ::= b. |
[ nil = outermost enclosingClass ] whileFalse: [
outermost:: outermost enclosingClass
].
^outermost
)
public incrementedVersion
(* A centralized method for installing new code from the IDE *)
= (
^version_slot:: version_slot + 1
)
public installFromBuilders: bs <Array[ClassDeclarationBuilder]> ^<List[MixinMirror]>
(* A centralized method for installing new code from the IDE. Captures
per-class baselines from the LIVE pre-install state BEFORE the install
so the drafts hook can record them; the live mirrors will reflect the
new state once atomicInstaller runs. *)
= (
^installFromBuilders: bs into: namespacing Root
)
public installFromBuilders: bs <Array[ClassDeclarationBuilder]> into: namespace <Map[Symbol, Object]> ^<List[MixinMirror]>
(* Make sure all builders are top level *)
= (
| lastBackup <Map[Symbol, String]> = backup. builders <Array[ClassDeclarationBuilder]> = bs collect: [:b <ClassDeclartionBuilder> |
topMostBuilderOf: b
]. baselines =
(* Snapshot the live per-class state BEFORE installing so the drafts
hook can compare against drafts' latest commit and emit a Baseline
or Resync commit when needed. Synchronous walk; cheap. *)
computeBaselinesFor: builders inNamespace: namespace. mixins =
(* Install the code *)
atomicInstaller install: builders into: namespace. |
(* Backup the changes *)
builders do: [:b <ClassDeclarationBuilder> |
(* Add each changed module to the backup *)
lastBackup at: b name put: (browsing compilationUnitFromSource: b source)
].
(* Save new backup in local storage *)
localStorage setItem: #backup to: (json encode: lastBackup).
(* Timestamp latest backup *)
localStorage setItem: #lastBackupTime to: incrementedVersion.
(* Drafts hook (git-as-infinite-undo): record per-member commits in the
hidden drafts repo. Fire-and-forget; failures are logged to the console
but don't fail the install. *)
recordAcceptForBuilders: builders baselines: baselines.
^mixins
)
public encodeForFilename: s <String> ^<String> = (
^replaceIn: (replaceIn: s all: '%' with: '%25') all: '/' with: '%2F'
)
public decodeFromFilename: s <String> ^<String> = (
(* Inverse of encodeForFilename:. Decode '/' first so that an encoded
'%2F' doesn't get partially undone by the '%25' -> '%' pass. *)
^replaceIn: (replaceIn: s all: '%2F' with: '/') all: '%25' with: '%'
)
draftPathPrefixForClassDeclaration: cdm ^<String> = (
(* Outermost-to-innermost slash-terminated class chain. For top-level Foo
returns 'Foo/'; for D nested in Foo returns 'Foo/D/'. Shared by all
draftPathFor*: helpers. *)
| classes path c |
classes:: List new.
c:: cdm.
[ c isNil ] whileFalse: [
classes add: c.
c:: c enclosingClass
].
path:: ''.
classes size to: 1
by: -1
do: [:i | path:: path , (classes at: i) simpleName asString , '/' ].
^path
)
public draftPathForMethodMirror: aMirror <MethodMirror> ^<String> = (
(* <TopLevel>/.../<Enclosing>/method.<encoded selector>.ns (instance side)
<TopLevel>/.../<Enclosing>/class-method.<encoded selector>.ns (class side) *)
| sideKind |
sideKind:: aMirror definingMixin isMeta ifTrue: [ 'class-method.' ]
ifFalse: [ 'method.' ].
^(draftPathPrefixForClassDeclaration: aMirror definingMixin declaration) , sideKind , (encodeForFilename: aMirror name asString) , '.ns'
)
public draftPathForLazySlotMirror: aMirror ^<String> = (
(* <TopLevel>/.../<Enclosing>/lazy-slot.<encoded name>.ns -- class side
never has lazy slots in Newspeak so there's no class-side variant. *)
^(draftPathPrefixForClassDeclaration: aMirror definingMixin declaration) , 'lazy-slot.' , (encodeForFilename: aMirror name asString) , '.ns'
)
public draftPathForClassDeclaration: cdm ^<String> = (
(* <TopLevel>/.../<This class>/header.ns -- the class header covers the
factory params, slot block, superclass clause, and all regular
(non-lazy) slots. *)
^(draftPathPrefixForClassDeclaration: cdm) , 'header.ns'
)
replaceIn: s <String> all: oldSub <String> with: newSub <String> ^<String> = (
(* String replace helper. Primordialsoup's kernel String doesn't carry
replaceAll:with: (that one lives on KernelForJS), so we build the
result by scanning oldSub via indexOf:startingAt: and accumulating
into a StringBuilder. *)
| result idx start |
oldSub isEmpty ifTrue: [ ^s ].
result:: StringBuilder new.
start:: 1.
idx:: s indexOf: oldSub startingAt: start.
[ idx > 0 ] whileTrue: [
result add: (s copyFrom: start to: idx - 1).
result add: newSub.
start:: idx + oldSub size.
idx:: s indexOf: oldSub startingAt: start
].
result add: (s copyFrom: start to: s size).
^result asString
)
walkClassDecl: cd intoPath: prefix <String> files: outMap <Map[String, String]> = (
(* Polymorphic over ClassDeclarationBuilder and ClassDeclarationMirror --
both expose name, header source, instanceSide/classSide each with
methods/lazySlots/nestedClasses iterable via do:, yielding mirrors or
builders with name + source. Writes every member of cd's subtree into
outMap at <prefix><name>/<kind>.<id>.ns. *)
| className thisDir |
className:: cd name asString.
thisDir:: prefix , className , '/'.
outMap at: thisDir , 'header.ns' put: cd header source.
cd instanceSide methods do: [:m |
outMap at: thisDir , 'method.' , (encodeForFilename: m name asString) , '.ns'
put: m source
].
cd instanceSide lazySlots do: [:ls |
outMap at: thisDir , 'lazy-slot.' , (encodeForFilename: ls name asString) , '.ns'
put: ls source
].
cd classSide methods do: [:m |
outMap at: thisDir , 'class-method.' , (encodeForFilename: m name asString) , '.ns'
put: m source
].
cd instanceSide nestedClasses do: [:nc |
walkClassDecl: nc intoPath: thisDir files: outMap
].
cd classSide nestedClasses do: [:nc |
(* Class-side nested classes are rare but grammatically legal. *)
walkClassDecl: nc intoPath: thisDir files: outMap
]
)
computeBaselinesFor: builders <Array[ClassDeclarationBuilder]> inNamespace: namespace ^<Map[String, Map[String, String]]> = (
(* For each top-level builder, look up the LIVE class in namespace.
If present, walk the live ClassDeclarationMirror into a per-class
{path -> source} Map and store it under the class's simple name in
the result. Brand-new classes (not in namespace) get no entry; the
Accept commit will record them as additions without a Baseline.
The walk is wrapped in on:Error do: -- some live classes have partial
mirror state (e.g. nested classes with nil _classMixin) that crash the
walker on classSide methods/nestedClasses iteration. When that happens
we skip the baseline for that class and let the Accept record the new
state without a Baseline commit. *)
| result |
result:: Map new.
builders do: [:b <ClassDeclarationBuilder> |
| className liveClass perClass |
className:: b name asString.
liveClass:: namespace at: b name
ifAbsent: [ namespace at: className ifAbsent: [ nil ] ].
nil = liveClass ifFalse: [
[
perClass:: Map new.
walkClassDecl: (platformHolder mirrors ClassMirror reflecting: liveClass) mixin declaration
intoPath: ''
files: perClass.
result at: className put: perClass
] on: Exception
do: [:ex |
(* Catch Exception, not Error: MessageNotUnderstood extends
Exception directly, not Error, so on:Error do: lets DNU
propagate. The walk hits DNU when nested-class mirrors have
nil _classMixin or similar partial state. *)
('Drafts baseline walk failed for ' , className , ': ' , ex printString) out
]
]
].
^result
)
recordAcceptForBuilders: builders <Array[ClassDeclarationBuilder]> baselines: baselineMap <Map[String, Map[String, String]]> = (
(* Per-member drafts hook. Builds the Accept files map by walking every
touched top-level builder, then chains:
1. For each touched class with a baseline: check whether drafts'
latest tree under '<C>/' differs from the live baseline. If yes
(or drafts has no '<C>/' yet), emit a 'Baseline: C' / 'Resync from
vfuel: C' commit recording the baseline.
2. Then emit a single 'Accept: <names>' commit with per-member
change list built from the diff returned by stageSubtreeReplacements.
Fire-and-forget at the top level; failures log to console. *)
| acceptFiles touchedPrefixes touchedNames classNamesInOrder chain |
acceptFiles:: Map new.
touchedPrefixes:: List new.
touchedNames:: List new.
classNamesInOrder:: List new.
builders do: [:b <ClassDeclarationBuilder> |
| name |
name:: b name asString.
walkClassDecl: b intoPath: '' files: acceptFiles.
touchedPrefixes add: name , '/'.
touchedNames add: name.
classNamesInOrder add: name
].
(* Start the chain with a resolved Promise rather than calling
drafts ensureInitialized directly: that's a protected method
(default access) so an external send DNUs. The public DraftsRepo
methods we ultimately call (hasSubtree:, divergesFromHEAD:newFiles:,
stageSubtreeReplacements:newFiles:) each invoke ensureInitialized
internally, so the init runs exactly once anyway. *)
chain:: Promise resolve: nil.
classNamesInOrder do: [:cn |
| baselineFiles |
baselineFiles:: baselineMap at: cn ifAbsent: [ nil ].
(nil = baselineFiles or: [ baselineFiles isEmpty ]) ifFalse: [
chain:: chain then: [:r |
maybeCommitBaselineFor: cn files: baselineFiles
]
]
].
chain:: chain then: [:r |
| prefixesArr |
prefixesArr:: List new.
touchedPrefixes do: [:pp | prefixesArr add: pp ].
(drafts stageSubtreeReplacements: prefixesArr asArray newFiles: acceptFiles) then: [:diff |
| msg |
msg:: acceptMessageFromDiff: diff classNames: touchedNames.
drafts commit: msg
]
].
chain then: [:sha | nil ]
onRejected: [:err |
('Drafts commit failed: ' , err printString) out.
nil
]
)
maybeCommitBaselineFor: className <String> files: baselineFiles <Map[String, String]> ^<Alien[Promise]> = (
(* Inspect drafts: if its latest tree under '<className>/' matches the
live baseline, do nothing. Otherwise stage the baseline and commit it
with either 'Baseline: ' (drafts had no prior <className>/) or
'Resync from vfuel: ' (drafts had it but contents diverged). *)
| prefix |
prefix:: className , '/'.
^(drafts divergesFromHEAD: prefix newFiles: baselineFiles) then: [:diverged |
diverged ifFalse: [ Promise resolve: nil ]
ifTrue: [
(drafts hasSubtree: className) then: [:hasExisting |
| label prefixesArr |
label:: hasExisting ifTrue: [ 'Resync from vfuel: ' ]
ifFalse: [ 'Baseline: ' ].
prefixesArr:: List new.
prefixesArr add: prefix.
(drafts stageSubtreeReplacements: prefixesArr asArray
newFiles: baselineFiles) then: [:diff |
drafts commit: label , className
]
]
]
]
)
acceptMessageFromDiff: diff classNames: classNames <List[String]> ^<String> = (
(* Build a multi-line commit message:
Subject: 'Accept: <class names joined by comma>'
Body: per-class blocks listing + (added), ~ (modified), - (removed)
members, with members labeled by their kind. *)
| added modified removed sb subject pathsByClass |
added:: diff at: 'added'.
modified:: diff at: 'modified'.
removed:: diff at: 'removed'.
subject:: ''.
classNames do: [:n |
subject:: subject isEmpty ifTrue: [ n ] ifFalse: [ subject , ', ' , n ]
].
pathsByClass:: Map new.
classNames do: [:n |
| classBlock |
classBlock:: Map new.
classBlock at: 'added' put: List new.
classBlock at: 'modified' put: List new.
classBlock at: 'removed' put: List new.
pathsByClass at: n put: classBlock
].
partitionDiffPaths: added marker: 'added' into: pathsByClass.
partitionDiffPaths: modified marker: 'modified' into: pathsByClass.
partitionDiffPaths: removed marker: 'removed' into: pathsByClass.
sb:: StringBuilder new.
(* Subject line + LF *)
sb writeln: 'Accept: ' , subject.
classNames do: [:n |
| block hasAny |
block:: pathsByClass at: n.
hasAny:: (block at: 'added') isEmpty not or: [
(block at: 'modified') isEmpty not or: [
(block at: 'removed') isEmpty not
]
].
hasAny ifTrue: [
(* Blank line between subject/prev block and this block, then the
class header. *)
sb writeln: ''.
sb writeln: n.
(block at: 'added') do: [:p |
sb writeln: ' + ' , (pathToMemberLabel: p forClass: n)
].
(block at: 'modified') do: [:p |
sb writeln: ' ~ ' , (pathToMemberLabel: p forClass: n)
].
(block at: 'removed') do: [:p |
sb writeln: ' - ' , (pathToMemberLabel: p forClass: n)
]
]
].
^sb asString
)
partitionDiffPaths: jsArray marker: key into: pathsByClass <Map[String, Map[String, List[String]]]> = (
(* jsArray is a JS array of paths like 'Foo/method.bar.ns' or
'Foo/D/method.qux.ns'. Drop each path into pathsByClass[<topLevel>][key]. *)
0 to: (jsArray at: 'length') - 1
do: [:i |
| p slashIdx topLevel block bucket |
p:: jsArray at: i.
slashIdx:: p indexOf: '/' startingAt: 1.
slashIdx = 0 ifFalse: [
topLevel:: p copyFrom: 1 to: slashIdx - 1.
block:: pathsByClass at: topLevel ifAbsent: [ nil ].
nil = block ifFalse: [
bucket:: block at: key.
bucket add: p
]
]
]
)
pathToMemberLabel: path <String> forClass: className <String> ^<String> = (
(* Turn a path like 'Foo/method.bar.ns' / 'Foo/D/method.qux.ns' into a
human-readable member label like 'method bar' / 'D method qux'.
className is the top-level class -- we strip the leading '<className>/'
then split the rest on '/' to surface nested-class qualifiers. *)
| remainder segments leafKind leafName i prefixLen qualifier |
prefixLen:: className size + 2.
(* '<className>/' *)
remainder:: path copyFrom: prefixLen to: path size.
(* Strip trailing '.ns'. *)
(remainder endsWith: '.ns') ifTrue: [
remainder:: remainder copyFrom: 1 to: remainder size - 3
].
(* Split remainder on '/' -- everything but the last segment is a
nested-class qualifier; the last segment is '<kind>.<id>' or 'header'. *)
segments:: List new.
i:: 1.
[ i <= remainder size ] whileTrue: [
| nextSlash |
nextSlash:: remainder indexOf: '/' startingAt: i.
nextSlash = 0 ifTrue: [
segments add: (remainder copyFrom: i to: remainder size).
i:: remainder size + 1
]
ifFalse: [
segments add: (remainder copyFrom: i to: nextSlash - 1).
i:: nextSlash + 1
]
].
qualifier:: ''.
1 to: segments size - 1
do: [:k |
qualifier:: qualifier isEmpty ifTrue: [ segments at: k ]
ifFalse: [ qualifier , '.' , (segments at: k) ]
].
^qualifier isEmpty ifTrue: [ memberKindOf: segments last ]
ifFalse: [ qualifier , ' ' , (memberKindOf: segments last) ]
)
memberKindOf: leaf <String> ^<String> = (
(* leaf is one of 'header', 'method.<encoded sel>', 'lazy-slot.<name>',
or 'class-method.<encoded sel>'. Recognize the prefix, decode the
remainder, return a human label. *)
leaf = 'header' ifTrue: [ ^'header' ].
(leaf startsWith: 'method.') ifTrue: [
^'method ' , (decodeFromFilename: (leaf copyFrom: 8 to: leaf size))
].
(leaf startsWith: 'lazy-slot.') ifTrue: [
^'lazy slot ' , (decodeFromFilename: (leaf copyFrom: 11 to: leaf size))
].
(leaf startsWith: 'class-method.') ifTrue: [
^'class-side method ' , (decodeFromFilename: (leaf copyFrom: 14
to: leaf size))
].
^leaf
)
lastBackupTime ^<Integer> = (
| backupString <String> = [ localStorage getItem: #lastBackupTime ] on: Error
do: [:e | '0' ]. |
^Integer parse: (backupString isNil ifFalse: [ backupString ] ifTrue: [ '0' ])
radix: 10
)
lastSavedTime ^<Integer> = (
| savedString <String> = [ localStorage getItem: #lastSavedTime ] on: Error
do: [:e | '0' ]. |
^Integer parse: (savedString isNil ifFalse: [ savedString ] ifTrue: [ '0' ])
radix: 10
)
maxStoredVersion ^<Integer> = (
^lastSavedTime max: lastBackupTime
)
public standardPreludeIconNames ^<List[String]> = (
^standardIconNames
)
public standardPreludeMessages ^<List[String]> = (
^standardNames
)
public setupNames = (
(* Record standard namespace names *)
standardNames:: namespacing Root keys.
(* Record standard icon names *)
standardIconNames:: (namespacing Root at: #Icons) keys
)
populateNamespaceUsingPlatform: p <Platform> ^<Namespace> = (
| platformMirror <ObjectMirror> = p mirrors ObjectMirror reflecting: p. runtimeClass <ClassMirror> = topLevelClassOf: platformMirror. namespace <Namespace> = namespacing Root. |
namespace at: 'Icons'
put: (populateIconNamespace: namespacing freshNamespace);
at: runtimeClass mixin name put: runtimeClass reflectee;
at: 'Browsing' put: Browsing;
at: 'Minitest' put: Minitest;
at: 'MinitestUI' put: MinitestUI;
at: 'Namespacing' put: Namespacing;
at: 'NewspeakColorization' put: NewspeakColorization;
at: 'HopscotchWebIDE'
put: (topLevelClassOf: (p mirrors ObjectMirror reflecting: self)) reflectee;
at: 'CombinatorialParsing' put: CombinatorialParsing;
at: 'NewspeakGrammar' put: NewspeakGrammar;
at: 'NewspeakASTs' put: NewspeakASTs;
at: 'NewspeakParsing' put: NewspeakParsing;
at: 'NewspeakTypechecker' put: NewspeakTypechecker;
at: 'NewspeakPrettyPrinter' put: NewspeakPrettyPrinter;
at: 'MetadataParsing' put: MetadataParsing;
at: 'Debugging' put: Debugging;
at: 'Documents' put: Documents;
at: 'DocumentHolder' put: DocumentHolder;
at: 'WorkspaceManager' put: WorkspaceManager;
at: 'WorkspaceHolder' put: WorkspaceHolder;
at: 'DeploymentManager' put: DeploymentManager;
at: 'RuntimeForPrimordialSoup' put: RuntimeForPrimordialSoup;
at: 'RuntimeWithMirrorsForPrimordialSoup'
put: RuntimeWithMirrorsForPrimordialSoup;
at: 'RuntimeForHopscotchForHTML' put: RuntimeForHopscotchForHTML;
at: 'RuntimeForJS' put: RuntimeForJS;
at: 'RuntimeForJSWithMirrorBuilders' put: RuntimeForJSWithMirrorBuilders;
at: 'NewspeakCompilation' put: NewspeakCompilation;
at: 'JavascriptGeneration' put: JavascriptGeneration;
at: 'JSON' put: JSON;
at: 'Newspeak2JSCompilation' put: Newspeak2JSCompilation;
at: 'KernelForJS' put: KernelForJS;
at: 'ActorsForJS' put: ActorsForJS;
at: 'AliensForJS' put: AliensForJS;
at: 'MirrorsForJS' put: MirrorsForJS;
at: 'MirrorGroups' put: MirrorGroups;
at: 'Collections' put: Collections;
at: 'Streams' put: Streams;
at: 'WebCompiler' put: WebCompiler;
at: 'WebFiles' put: WebFiles;
at: 'AIAccess' put: AIAccess;
at: 'AI_IDE_Support' put: AI_IDE_Support;
at: 'VCSLib' put: VCSLib;
at: 'VCSCore' put: VCSCore;
at: 'VCSDiffing' put: VCSDiffing;
at: 'VCSSourceMirrors' put: VCSSourceMirrors;
at: 'VCSIsomorphicGitBackendProvider' put: VCSIsomorphicGitBackendProvider;
at: 'Repositories' put: Repositories.
testModules do: [:testModule | namespace at: testModule name put: testModule ].
augmentNamespace: namespace withPlatform: p.
seedBootstrapNamespacesInto: namespace.
^namespace
)
seedBootstrapNamespacesInto: namespace <Namespace> = (
(* Pre-populate two sub-namespaces in Root reflecting which top-
level classes live in which source repo. Newspeak = classes
shipped from the newspeak repo (the IDE itself + Newspeak
language tooling). PrimordialSoup = classes shipped from
primordialsoup/newspeak (the runtime + low-level support).
Classes that live in both repos appear in both namespaces —
multi-namespace membership is supported by the language.
Idempotent: skip if a namespace with that name already exists,
so user customizations / prior-session state survives.
Defensive: only copy entries actually present in `namespace`,
so a stale entry in the hand-curated lists is silently
skipped rather than installing nil. *)
addBootstrapNamespaceNamed: 'Newspeak'
into: namespace
from: newspeakBootstrapClassNames.
addBootstrapNamespaceNamed: 'PrimordialSoup'
into: namespace
from: primordialSoupBootstrapClassNames
)
addBootstrapNamespaceNamed: nsName <String> into: namespace <Namespace> from: classNames <Array[String]> = (
| sub |
(namespace includesKey: nsName asSymbol) ifTrue: [ ^self ].
sub:: namespacing freshNamespace.
classNames do: [:name |
| entry |
entry:: namespace at: name asSymbol ifAbsent: [ nil ].
entry isNil ifFalse: [ sub at: name asSymbol put: entry ]
].
namespace at: nsName asSymbol put: sub
)
newspeakBootstrapClassNames ^<Array[String]> = (
(* Classes registered in Root above that also live as top-level
.ns files in the newspeak repo. Hand-maintained; sync with
the at:put: cascade in populateNamespaceUsingPlatform: when
that list changes. *)
^{'AccessModifierTesting'. 'AccessModifierTestingConfiguration'. 'AI_IDE_Support'. 'AIAccess'. 'ActivationMirrorTesting'. 'ActivationMirrorTestingConfiguration'. 'ActorsForJS'. 'AliensForJS'. 'Browsing'. 'Collections'. 'CombinatorialParsing'. 'Debugging'. 'DeploymentManager'. 'DocumentHolder'. 'Documents'. 'HopscotchWebIDE'. 'JSTesting'. 'JSTestingConfiguration'. 'JavascriptGeneration'. 'KernelForJS'. 'KernelTests'. 'KernelTestsConfiguration'. 'MemoryHoleTesting'. 'MemoryHoleTestingConfiguration'. 'MetadataParsing'. 'Minitest'. 'MinitestTests'. 'MinitestTestsConfiguration'. 'MinitestUI'. 'MirrorBuilderTesting'. 'MirrorBuilderTestingConfiguration'. 'MirrorGroups'. 'MirrorTesting'. 'MirrorTestingConfiguration'. 'MirrorTestingModel'. 'MirrorsForJS'. 'Namespacing'. 'NewspeakASTs'. 'NewspeakColorization'. 'NewspeakCompilation'. 'NewspeakGrammar'. 'NewspeakParsing'. 'NewspeakPrettyPrinter'. 'NewspeakPrettyPrinterTesting'. 'NewspeakPrettyPrinterTestingConfiguration'. 'NewspeakTypechecker'. 'NewspeakTypecheckerTesting'. 'NewspeakTypecheckerTestingConfiguration'. 'Repositories'. 'RuntimeForHopscotchForHTML'. 'RuntimeForJS'. 'RuntimeForJSWithMirrorBuilders'. 'Streams'. 'VCSCore'. 'VCSDiffing'. 'VCSIsomorphicGitBackendProvider'. 'VCSLib'. 'VCSSourceMirrors'. 'WebFiles'. 'WorkspaceHolder'. 'WorkspaceManager'. }
)
primordialSoupBootstrapClassNames ^<Array[String]> = (
(* Classes registered in Root above that also live as top-level
.ns files in primordialsoup/newspeak. *)
^{'AccessModifierTesting'. 'AccessModifierTestingConfiguration'. 'ActivationMirrorTesting'. 'ActivationMirrorTestingConfiguration'. 'JSON'. 'JSTesting'. 'JSTestingConfiguration'. 'JavascriptGeneration'. 'KernelTests'. 'KernelTestsConfiguration'. 'MetadataParsing'. 'Minitest'. 'MinitestTests'. 'MinitestTestsConfiguration'. 'MirrorBuilderTesting'. 'MirrorBuilderTestingConfiguration'. 'MirrorTesting'. 'MirrorTestingConfiguration'. 'MirrorTestingModel'. 'NewspeakASTs'. 'NewspeakCompilation'. 'RuntimeForPrimordialSoup'. 'RuntimeWithMirrorsForPrimordialSoup'. 'WebCompiler'. }
)
populateIconNamespace: ns <Namespace> ^<Namespace> = (
^ns at: 'accept16px' put: images accept16px;
at: 'ampleforthDocument' put: images ampleforthDocument;
at: 'cancel16px' put: images cancel16px;
at: 'clearImage' put: images clearImage;
at: 'disclosureClosedImage' put: images disclosureClosedImage;
at: 'disclosureOpenImage' put: images disclosureOpenImage;
at: 'downloadImage' put: images downloadImage;
at: 'helpImage' put: images helpImage;
at: 'publicAccessImage' put: images publicAccessImage;
at: 'protectedAccessImage' put: images protectedAccessImage;
at: 'privateAccessImage' put: images privateAccessImage;
at: 'addImage' put: images addImage;
at: 'backImage' put: images backImage;
at: 'brain' put: images brainImage;
at: 'dropDownImage' put: images dropDownImage;
at: 'expandImage' put: images expandImage;
at: 'collapseImage' put: images collapseImage;
at: 'classPresenterImage' put: images classPresenterImage;
at: 'classUnknownImage' put: images classUnknownImage;
at: 'forwardImage' put: images forwardImage;
at: 'classImage' put: images classImage;
at: 'itemReferencesImage' put: images itemReferencesImage;
at: 'historyImage' put: images historyImage;
at: 'homeImage' put: images homeImage;
at: 'mikeImage' put: images mikeImage;
at: 'newImage' put: images newImage;
at: 'refreshImage' put: images refreshImage;
at: 'findImage' put: images findImage;
at: 'peekingeye1610' put: images peekingeye1610;
at: 'saveImage' put: images saveImage;
at: 'sectionImage' put: images sectionImage;
yourself
)
) : ()
topLevelClassOf: om <ObjectMirror> ^<ClassMirror> = (
| klass <ClassMirror> ::= om getClass. |
[ klass enclosingObject reflectee isNil ] whileFalse: [
klass:: klass enclosingObject getClass
].
^klass
)
public augmentNamespace: namespace withPlatform: p = (
| platformMirror <ObjectMirror> = p mirrors ObjectMirror reflecting: p. platformClass <ClassMirror> = platformMirror getClass. runtimeMirror <ObjectMirror> = platformClass enclosingObject. runtimeClass <ClassMirror> = topLevelClassOf: platformMirror. |
runtimeClass slots do: [:s <SlotMirror> |
| klass <ClassMirror> o <Object> |
o:: (runtimeMirror getSlot: s name) reflectee.
o isKindOfBehavior ifTrue: [ namespace at: o name put: o ]
]
)
loadFrom: lsKey <Symbol> usingPlatform: p ^<List[MixinMirror]> = (
[
| json = JSON usingPlatform: p. localStorage = p js localStorage. recoveredMap <Map[String] | Nil> = json decode: ([
localStorage getItem: lsKey
] on: Error do: [:e | nil ]). recoveredCode = recoveredMap isNil ifFalse: [
recoveredMap values
]
ifTrue: [ p collections List new ]. bs <List[ClassDeclarationBuilder]> = recoveredCode collect: [:s <String> |
p mirrors ClassDeclarationBuilder fromUnitSource: s
]. forbidden <Set[Symbol]> = p collections Set withAll: {#HopscotchWebIDE. #KernelForPrimordialSoup. }. filtered = bs reject: [:b |
forbidden includes: b name
]. mixins <List[MixinMirror]> = p mirrors installer install: filtered
into: (namespaceGivenPlatform: p). |
^mixins
] on: Error
do: [:msg |
msg out.
nil
].
^p collections List new
)
public ideUsingPlatform: p = (
(* The call to ensureLocalStorage: is usually redundant, except when other tools embed the IDE using
this method as the entry point. *)
ensureLocalStorage: p js localStorage.
^HopscotchWebIDE usingPlatform: p
)
setupIDEWith: mixins using: platform = (
| ide = ideUsingPlatform: platform. namespace = ide namespacing Root. |
augmentNamespace: namespace withPlatform: platform local.
ide setupNames.
mixins do: [:m <MixinMirror> |
namespace at: m name put: m declaration applyToObject reflectee
].
ide launch: ide browsing HomeSubject new.
refreshProviderModelsInBackgroundFor: ide platform: platform
)
loadOrRestoreUsingPlatform: p = (
| localStorage <Alien[LocalStorage]> = p js localStorage. lastBackupTime = Integer parse: ([
localStorage getItem: #lastBackupTime
] on: Error do: [:e | 0 ])
radix: 10. lastSavedTime = Integer parse: ([
localStorage getItem: #lastSavedTime
] on: Error do: [:e | 0 ])
radix: 10. |
lastBackupTime > lastSavedTime ifTrue: [ RestoreDialog usingPlatform: p ]
ifFalse: [ setupIDEWith: (loadFrom: #lastSaved usingPlatform: p) using: p ]
)
public main: platform <Platform> args: args <{String}> = (
| ide |
ensureLocalStorage:: platform js localStorage.
(platform js global at: 'document') at: 'title' put: 'Newspeak IDE'.
loadOrRestoreUsingPlatform: platform
)
ensureLocalStorage: localStorage = (
(localStorage getItem: #lastBackupTime) isNil ifTrue: [
localStorage setItem: #lastBackupTime to: 0
].
(localStorage getItem: #backup) isNil ifTrue: [
localStorage setItem: #backup to: '{}'
].
(localStorage getItem: #lastSavedTime) isNil ifTrue: [
localStorage setItem: #lastSavedTime to: 0
].
(localStorage getItem: #lastSaved) isNil ifTrue: [
localStorage setItem: #lastSaved to: '{}'
]
)
namespaceGivenPlatform: p ^<Map[Symbol, Object]> = (
| platformMirror <ObjectMirror> = p mirrors ObjectMirror reflecting: p. runtimeClass <ClassMirror> = topLevelClassOf: platformMirror. ns = p collections Map new. |
ns at: runtimeClass mixin name put: runtimeClass reflectee;
at: 'Browsing' put: Browsing;
at: 'Minitest' put: Minitest;
at: 'MinitestUI' put: MinitestUI;
at: 'Namespacing' put: Namespacing;
at: 'NewspeakColorization' put: NewspeakColorization;
at: 'CombinatorialParsing' put: CombinatorialParsing;
at: 'NewspeakGrammar' put: NewspeakGrammar;
at: 'NewspeakASTs' put: NewspeakASTs;
at: 'NewspeakParsing' put: NewspeakParsing;
at: 'NewspeakTypechecker' put: NewspeakTypechecker;
at: 'NewspeakPrettyPrinter' put: NewspeakPrettyPrinter;
at: 'MetadataParsing' put: MetadataParsing;
at: 'Debugging' put: Debugging;
at: 'Documents' put: Documents;
at: 'DocumentHolder' put: DocumentHolder;
at: 'WorkspaceManager' put: WorkspaceManager;
at: 'WorkspaceHolder' put: WorkspaceHolder;
at: 'DeploymentManager' put: DeploymentManager;
at: 'RuntimeForPrimordialSoup' put: RuntimeForPrimordialSoup;
at: 'RuntimeWithMirrorsForPrimordialSoup'
put: RuntimeWithMirrorsForPrimordialSoup;
at: 'RuntimeForHopscotchForHTML' put: RuntimeForHopscotchForHTML;
at: 'RuntimeForJS' put: RuntimeForJS;
at: 'RuntimeForJSWithMirrorBuilders' put: RuntimeForJSWithMirrorBuilders;
at: 'NewspeakCompilation' put: NewspeakCompilation;
at: 'JavascriptGeneration' put: JavascriptGeneration;
at: 'JSON' put: JSON;
at: 'Newspeak2JSCompilation' put: Newspeak2JSCompilation;
at: 'KernelForJS' put: KernelForJS;
at: 'ActorsForJS' put: ActorsForJS;
at: 'AliensForJS' put: AliensForJS;
at: 'MirrorsForJS' put: MirrorsForJS;
at: 'MirrorGroups' put: MirrorGroups;
at: 'Collections' put: Collections;
at: 'Streams' put: Streams;
at: 'WebCompiler' put: WebCompiler;
at: 'WebFiles' put: WebFiles;
at: 'AIAccess' put: AIAccess;
at: 'AI_IDE_Support' put: AI_IDE_Support;
at: 'VCSLib' put: VCSLib;
at: 'VCSCore' put: VCSCore;
at: 'VCSDiffing' put: VCSDiffing;
at: 'VCSSourceMirrors' put: VCSSourceMirrors;
at: 'VCSIsomorphicGitBackendProvider' put: VCSIsomorphicGitBackendProvider;
at: 'Repositories' put: Repositories.
testModules do: [:testModule | ns at: testModule name put: testModule ].
augmentNamespace: ns withPlatform: p.
^ns
)
refreshProviderModelsInBackgroundFor: ide platform: platform = (
(* For each known AI provider class, check localStorage for a stored