-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvscode_dev.magik
3019 lines (2570 loc) · 66.1 KB
/
vscode_dev.magik
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
#% text_encoding = iso8859_1
_package sw
$
# Contains the minimal set of Magik development procs to support working with Magik in VS Code.
# Note: Please reload open_file() below if the dev procs are loaded from magik_tools (e.g. if the Dev Application is loaded)
!global_auto_declare?! << _true
$
# Redefined for use with VS Code
_pragma(classify_level=debug)
## Open a file in VS Code
_global _constant open_file <<
_proc (file_path, _optional line_number, a_class, a_method)
command << write_string("cmd /c code -r ", file_path)
_if line_number _isnt _unset
_then
command << write_string("cmd /c code -r --goto ", file_path, ":", line_number)
_elif a_method _isnt _unset
_then
# Find the method declaration in the file to get the line number
class_name << a_method.owner.meta_at(:class_name)
method_name << a_method.name
last << method_name.subseq(method_name.size - 1, 2)
test << _if a_method.slot_accessor?
_then
>> write_string("*", class_name, "*.*define_slot_access*(*:", method_name, "*")
_elif last = "()"
_then
>> write_string("*_method *", class_name, "*.*", method_name.subseq(1, method_name.size - 2), "*(*")
_elif last = "<<"
_then
>> write_string("*_method *", class_name, "*.*", method_name.subseq(1, method_name.size - 2), "*<<*")
_else
>> write_string("*_method *", class_name, "*.*", method_name, "*")
_endif
_protect
input << external_text_input_stream.new( file_path )
line << 1
_loop
_if ( a_line << input.get_line() ) _is _unset
_then
_leave
_endif
_if a_line.matches?(test)
_then
col << a_line.size + 1
command << write_string("cmd /c code -r --goto ", file_path, ":", line, ":", col)
_leave
_endif
line +<< 1
_endloop
_protection
input.close()
_endprotect
_endif
system.do_command( command )
_endproc
$
_pragma(classify_level=debug)
##
## Save session info for the VS Class Browser.
## Calling this procedure will connect the Class Browser in VS Code.
##
_global _constant vs_class_browser <<
_proc @vs_class_browser()
_if method_finder.pid _is _unset
_then
method_finder.start_acp()
_endif
output_file << system.pathname_down(system.temp_directory_name, "vscode_class_browser.txt")
id_str << system.process_id.write_string
output_stream << _unset
_protect
output_stream << external_text_output_stream.new(output_file)
output_stream.write("processId|", id_str, newline_char)
_for key, val _over system.get_all_env().fast_keys_and_elements()
_loop
str << val.write_string.replace_all_instances_of("\", "/");
output_stream.write(key.write_string, "|", str, newline_char)
_endloop
_protection
_if output_stream _isnt _unset
_then
output_stream.close()
_endif
_endprotect
_endproc
$
_pragma(classify_level=debug)
## Jump to source in VS Code
_global vs_goto <<
_proc @vs_goto( method_string, _optional class_string, super? )
_global mfind
_global mjump
a_class << _unset
_if class_string _isnt _unset _andif
class_string.an_element() _isnt %^
_then
key << class_string.as_symbol()
class_string << _unset
# Use the provided class_string if it is a global.
_for a_package _over package.all_packages.fast_elements()
_loop
_if ( val << a_package[ key ] ) _isnt _unset
_then
a_class << val
class_string << write_string("^", a_class.class_name, "$")
_leave
_endif
_endloop
_endif
_if super? _is _true _andif a_class _isnt _unset
_then
class_string << _unset
mt << a_class.define_method_target
tables << rope.new()
# Find a parent implementation
_for parent_mt _over mt.parents( _true )
_loop
_if _not tables.includes?( parent_mt )
_then
super_class_string << write_string("^", parent_mt.meta_at(:class_name), "$")
results << mfind( method_string, super_class_string, _unset, 2, _false, _false, _false )
_if results.size _is 1
_then
mjump( 1 )
_return
_endif
tables.add_last( parent_mt )
_endif
_endloop
_endif
results << mfind( method_string, class_string, _unset, 2, _false, _false, _false )
_if results.size _is 1
_then
mjump( 1 )
_else
mfind( method_string, class_string )
_endif
_endproc
$
_pragma(classify_level=debug)
## Proc to control a timer to monitor output and save to a temporary file to append to a console
## file in VS Code.
_global _constant vs_monitor_output <<
_proc @vs_monitor_output(enable?)
_global timer, external_text_simple_output_stream
_global vs_output_timer, vs_default_terminal, vs_output
_global !output!, !error_output!, !terminal!
_if enable? _is _true
_then
_if vs_output_timer _is _unset
_then
write("Starting output monitor...")
_if vs_default_terminal _is _unset
_then
vs_default_terminal << !terminal!
_endif
_local simple? << external_text_simple_output_stream _isnt _unset
_local remove_trailing_lines << _proc(a_string)
end << 0
_for index _over a_string.size.downto(1)
_loop
_if _not a_string[index].white_space?
_then
end << index
_leave
_endif
_endloop
_return a_string.slice(1, end)
_endproc
_local orig_output << !output!
vs_output << internal_text_output_stream.new()
!output! << !error_output! << !terminal! << vs_output
temp_dir << _if system.os_name _is :windows
_then
>> system.getenv("TEMP")
_else
>> "/tmp"
_endif
_local output_file << system.pathname_down(temp_dir, "vscode_output_temp.txt")
_try
system.unlink(output_file, _true, _true)
_when error
# write("Cannot remove " + output_file)
_endtry
_if timer _isnt _unset
_then
vs_output_timer << timer.schedule_fixed_delay(
_proc @vs_output_timer()
_import output_file, remove_trailing_lines, simple?
_global vs_output
_lock vs_output
str << vs_output.string
_if _not str.empty? _andif str.last _is %newline
_then
output_stream << _unset
done? << _false
_protect
_if simple?
_then
_try
output_stream << external_text_simple_output_stream.new_appending(output_file)
_when filesystem_error
# Ignore
_return
_endtry
_else
output_stream << external_text_output_stream.new(output_file)
_endif
output_str << remove_trailing_lines(str)
output_stream.write(output_str, %newline)
done? << _true
_protection
_if output_stream _isnt _unset
_then
output_stream.close()
_endif
_if done?
_then
vs_output.reset()
_endif
_endprotect
_endif
_endlock
_endproc,
1.0, 0.4)
_else
vs_output_timer <<
_proc @vs_output_timer()
_import output_file, remove_trailing_lines
_global vs_output
_loop
_thisthread.sleep(400)
_lock vs_output
str << vs_output.string
_if _not str.empty?
_then
output_str << remove_trailing_lines(str)
output_stream << _unset
done? << _false
_protect
output_stream << external_text_output_stream.new(output_file)
output_stream.write(output_str, %newline)
done? << _true
_protection
_if output_stream _isnt _unset
_then
output_stream.close()
_endif
_if done?
_then
vs_output.reset()
_endif
_endprotect
_endif
_endlock
_endloop
_endproc.fork_at(_thisthread.low_background_priority)
_endif
_endif
_elif vs_output_timer _isnt _unset
_then
_if timer _isnt _unset
_then
vs_output_timer.cancel()
_else
vs_output_timer.kill()
_endif
vs_output_timer << _unset
vs_output << _unset
!output! << !error_output! << !terminal! << vs_default_terminal
_endif
_endproc
$
_block
# A timer task to monitor output.
_global vs_output_timer
# Store the original terminal.
_global vs_default_terminal
# Store the output for use with the console terminal.
_global vs_output
_if vs_output_timer _isnt _unset
_then
# Restart monitor
vs_monitor_output(_false)
vs_monitor_output(_true)
_else
vs_output_timer << _unset
vs_default_terminal << _unset
vs_output << _unset
_endif
_endblock
$
_pragma(classify_level=debug)
## A proc to perform the named proc and capture any output to add to a console file in VS Code.
_global vs_perform <<
_proc @vs_perform(proc_name, _gather args)
_global get_global_value
_global vs_output
_global !global_auto_declare?!
_dynamic !output!
_dynamic !error_output!
a_proc << get_global_value(proc_name)
_if a_proc _is _unset _orif a_proc.class_name _isnt :procedure
_then
_return
_endif
_if vs_output _isnt _unset
_then
orig_output << !output!
orig_error_output << !error_output!
auto_declare? << !global_auto_declare?!
_protect
!output! << !error_output! << vs_output
!global_auto_declare?! << _true
a_proc.invoke(_scatter args)
_protection
!output! << orig_output
!error_output! << orig_error_output
!global_auto_declare?! << auto_declare?
_endprotect
_else
a_proc.invoke(_scatter args)
_endif
_endproc
$
_pragma(classify_level=debug)
## Load temp file created in VS Code with a custom message at the Magik terminal.
_global _constant vs_load <<
_proc @vs_load()
_dynamic !output!
temp_dir << _if system.os_name _is :windows
_then
>> system.getenv("TEMP")
_else
>> "/tmp"
_endif
source_file << system.pathname_down(temp_dir, "vscode_temp.magik")
_if _not system.file_exists?(source_file)
_then
_return
_endif
msg << "Loading..."
input << _unset
_protect
input << external_text_input_stream.new(source_file)
_loop
_if (a_line << input.get_line()) _is _unset
_then
_leave
_endif
_if a_line.index_of_seq("# Output:") _is 1
_then
msg << a_line.slice_to_end(10)
_leave
_endif
_endloop
_protection
_if input _isnt _unset
_then
input.close()
_endif
_endprotect
orig_output << !output!
_protect
!output! << internal_text_output_stream.new()
orig_output.write(msg, %newline)
_try _with cond
load_file(source_file)
lines << !output!.string.split_by(%newline);
n_lines << lines.size
_if (n_lines > 1)
_then
_for i _over range(2, n_lines)
_loop
_if i <> n_lines
_then
orig_output.write(lines[i], %newline)
_else
orig_output.write(lines[i])
_endif
# orig_output.write(lines[i], %newline)
_endloop
_endif
_when error
cond.report_on(orig_output)
_endtry
_protection
!output! << orig_output
_endprotect
_endproc
$
_pragma(classify_level=debug)
## Evaluate the temp file created in VS Code and display the result in the console magik file.
_global _constant vs_console_load <<
_proc @vs_console_load()
_global external_text_simple_output_stream
_global !global_auto_declare?!
_global vs_default_terminal
_global vs_output
_global !terminal!
_dynamic !output!
_dynamic !error_output!
temp_dir << _if system.os_name _is :windows
_then
>> system.getenv("TEMP")
_else
>> "/tmp"
_endif
input_file << system.pathname_down(temp_dir, "vscode_temp.magik")
_if _not system.file_exists?(input_file)
_then
_return
_endif
output_file << _if vs_output _is _unset
_then
>> system.pathname_down(temp_dir, "vscode_console_temp.txt")
_else
>> system.pathname_down(temp_dir, "vscode_output_temp.txt")
_endif
_local remove_trailing_lines << _proc(a_string)
end << 0
_for index _over a_string.size.downto(1)
_loop
_if _not a_string[index].white_space?
_then
end << index
_leave
_endif
_endloop
_return a_string.slice(1, end)
_endproc
orig_output << !output!
orig_error_output << !error_output!
orig_terminal << !terminal!
input_stream << _unset
output_stream << _unset
output_str << ""
result << _unset
auto_declare? << !global_auto_declare?!
_protect
input_stream << external_text_input_stream.new(input_file)
output_stream << _if external_text_simple_output_stream _isnt _unset
_then
>> external_text_simple_output_stream.new_appending(output_file)
_else
>> external_text_output_stream.new(output_file)
_endif
_if vs_output _is _unset
_then
!output! << !error_output! << internal_text_output_stream.new()
_else
!output! << !error_output! << vs_output
!terminal! << vs_default_terminal
_endif
sw4? << system.vm_version < 5
input_lines << rope.new()
_loop
_if (a_line << input_stream.get_line()) _is _unset
_then
_leave
_endif
_if sw4?
_then
_if _not a_line.empty? _andif
a_line[1] _isnt %# _andif
a_line[1] _isnt %$ _andif
(a_line.size < 9 _orif _not a_line.subseq(1, 9).eq?("_package "))
_then
input_lines.add_last(a_line)
_endif
_else
_if a_line.size < 8 _orif a_line.subseq(1, 8) <> "# Magik>"
_then
input_lines.add_last(a_line)
_endif
_endif
_endloop
input_str << input_lines.join_as_strings(%newline)
!global_auto_declare?! << _true
result << input_str.evaluate()
output_str << !output!.string
output_str_empty? << output_str.empty?
_if vs_output _is _unset _andif _not output_str_empty?
_then
str << remove_trailing_lines(output_str)
output_stream.write(str, %newline)
_endif
_if result _isnt _unset _orif output_str_empty?
_then
output_stream.write(result, %newline)
_endif
_protection
_if vs_output _is _unset
_then
error_str << !error_output!.string
_if _not error_str.empty? _andif error_str <> output_str
_then
str << remove_trailing_lines(error_str)
output_stream.write(str, %newline)
_endif
_endif
_if input_stream _isnt _unset
_then
input_stream.close()
_endif
_if output_stream _isnt _unset
_then
output_stream.close()
_endif
!output! << orig_output
!error_output! << orig_error_output
!terminal! << orig_terminal
!global_auto_declare?! << auto_declare?
_endprotect
_return result
_endproc
$
_pragma(classify_level=debug)
## Save methods names to file to load as symbols in VS Code.
_global _constant vs_save_symbols <<
_proc @vs_save_symbols(_optional class_names)
_global slot_access_method_name
_global user_repository_paths
temp_dir << _if system.os_name _is :windows
_then
>> system.getenv("TEMP")
_else
>> "/tmp"
_endif
output_name << system.pathname_down(temp_dir, "vscode_symbols.txt")
temp_output_name << system.pathname_down(temp_dir, "vscode_symbols_temp.txt")
_local core_dir << smallworld_product.product(:sw_core).directory
_loop
index << core_dir.index_of("\")
_if index _is _unset _then _leave _endif
core_dir[index] << "/"
_endloop
_local home_drive << _if core_dir[2] = %:
_then
>> core_dir.subseq(1, 2)
_else
>> ""
_endif
_if class_names _isnt _unset _andif
system.file_exists?(output_name)
_then
a_set << set.new()
_for c_name _over class_names.fast_elements()
_loop
a_set.add(c_name.as_symbol())
_endloop
class_names << a_set
update? << _unset
_protect
input << external_text_input_stream.new(output_name)
_loop
_if (a_line << input.get_line()) _is _unset
_then
_leave
_endif
_if update? _is _unset
_then
update? << a_line.index_of_seq("update:") _is 1
_elif update?
_then
# Previous symbol file was an update -> append these classes to new update
class_name << a_line.split_by("|")[1].as_symbol()
class_names.add(class_name)
_endif
_endloop
_protection
_if input _isnt _unset
_then
input.close()
_thisthread.sleep(100)
_endif
_endprotect
_if update? _isnt _true
_then
# Previous symbol file was not an update -> save all methods
class_names << _unset
_endif
_endif
_try
system.unlink(temp_output_name, _true, _true)
_when error
write("Cannot remove " + temp_output_name)
_return
_endtry
_try
system.unlink(output_name, _true, _true)
_when error
write("Cannot remove " + output_name)
_return
_endtry
_local slot_mt << slot_access_method_name.method_table
_local serial_prefix << _if system.vm_version < 5
_then
>> "queued_work"
_else
>> sw_canvas_container.serialisation_thread_name
_endif
_local serial_prefix_n << serial_prefix.size + 1
_local update_source_path << _proc @update_source_path(source_path)
_import core_dir, home_drive
_if source_path _is _unset
_then
_return ""
_endif
res << source_path
_if source_path[1] = %/ _orif source_path[1] = %\
_then
_if source_path.index_of_seq("/sw_core/") _isnt _unset
_then
res << "".concatenation(core_dir, "/", source_path.split_by("/sw_core/")[2])
_else
a_path << "".concatenation(home_drive, source_path)
_if system.file_exists?(a_path)
_then
res << a_path
_endif
_endif
_endif
_return res
_endproc
_local get_source_file << _proc @get_source_file(mt)
_import update_source_path
source_file << mt.source_file
_if source_file _is _unset
_then
# Try the most common local method source file
methods << equality_hash_table.new()
_for m _over mt.local_methods()
_loop
_if _not m.slot_accessor?
_then
_try
m_source_file << m.source_file
_if m_source_file <> "Evaluated-inline"
_then
n << methods[m_source_file].default(0)
methods[m_source_file] << n + 1
_endif
_when error
_endtry
_endif
_endloop
max << 0
_for f, total _over methods.fast_keys_and_elements()
_loop
_if total > max
_then
source_file << f
max << total
_endif
_endloop
_endif
_return update_source_path(source_file)
_endproc
_local output_class << _proc @output_class(mt, c_name, output)
_import get_source_file
_import slot_mt
_import serial_prefix
_import serial_prefix_n
_import update_source_path
# p_name << _if (g_var << mt.meta_at(:exemplar_global)) _isnt _unset
# _then
# >> g_var.package.name
# _endif
# full_c_name << write_string(p_name, ":", c_name)
source_file << get_source_file(mt)
methods_str << internal_text_output_stream.new()
_for m _over mt.local_methods(_true)
_loop
m_name << m.name
_if m_name _is :exemplar _orif
m_name.method_table _is slot_mt _orif
m_name.an_element() _is %$
_then
_continue
_endif
_if m_name.index_of_seq(serial_prefix) _is 1 _andif
m_name.index_of(%!, serial_prefix_n) _isnt _unset
_then
_continue
_endif
classify_str << _if m.private?
_then
>> ",1,"
_else
>> ",,"
_endif
_if m.slot_accessor?
_then
methods_str.write(m_name, classify_str, "1,;")
_else
m_source_file << source_file
_try
m_file << m.source_file
_if m_file _isnt _unset _andif
m_file <> "Evaluated-inline" _andif
m_file.index_of_seq("load_mutated_methods.magik") _is _unset _andif
(c_name _is :sw_component _orif m_file.index_of_seq("sw_component.magik") _is _unset) # component properties
_then
m_source_file << update_source_path(m_file)
_endif
_when error
_endtry
_if m_source_file <> source_file
_then
methods_str.write(m_name, classify_str, ",", m_source_file, ";")
_else
methods_str.write(m_name, classify_str, ",;")
_endif
_endif
_endloop
parents_str << internal_text_output_stream.new()
_for parent_mt _over mt.parents()
_loop
parents_str.write(parent_mt.meta_at(:class_name), ";")
_endloop
str << "".concatenation(c_name, "|", source_file, "|", parents_str.string, "|", methods_str.string)
output.write(str, newline_char)
_endproc
done << set.new()
output << _unset
ok? << _false
_protect
output << external_text_output_stream.new(temp_output_name)
_if class_names _isnt _unset
_then
output.write("UPDATE:", newline_char)
_for c_name _over class_names.fast_elements()
_loop
key << c_name.as_symbol()
a_class << _for a_package _over package.all_packages.fast_elements()
_loop
_if (val << a_package[key]) _isnt _unset
_then
_leave _with val
_endif
_endloop
_if a_class _isnt _unset
_then
mt << a_class.define_method_target
output_class(mt, key, output)
_endif
_endloop
_else
_for g _over package.all_globals()
_loop
val << g.value
_if val _is _unset _orif
val.class_name _is :procedure
_then
_if val _isnt _unset _andif
(m_file << val.compiler_info[:source_file]) _isnt _unset
_then
m_file << update_source_path(m_file.as_charvec())
output.write("GLOBAL|", g.key, "|", m_file, newline_char)
_else
output.write("GLOBAL|", g.key, newline_char)
_endif
_continue
_endif
mt << val.define_method_target
c_name << mt.meta_at(:class_name)
_if done.includes?(c_name)
_then
_continue
_endif
done.add(c_name)
output_class(mt, c_name, output)
_endloop
# Add conditions
_for cond_key, a_cond _over condition.sys!perform(:template_map).fast_keys_and_elements()
_loop
m_file << a_cond.module_file
_if m_file _isnt _unset
_then
m_file << update_source_path(m_file.as_charvec())
output.write("CONDITION|", cond_key, "|", m_file, newline_char)
_else
output.write("CONDITION|", cond_key, newline_char)
_endif
_endloop
_endif
ok? << _true
_protection
_if output _isnt _unset
_then
output.close()
_if ok?
_then
_thisthread.sleep(100)
_try
system.rename(temp_output_name, output_name)
_when error
write("Cannot save symbols file")
_endtry
_endif
_endif
_endprotect
_endproc
$
_pragma(classify_level=debug)
##
## Load the module containing the specified file.
## Adds products and loads prerequisite modules as necessary.
##
_global _constant vs_load_file <<
_proc @vs_load_file( file_path, _optional force_reload? )
_global load_module
_if _not system.file_exists?( file_path )
_then
write( "File Not Found" )
_return
_endif
module_name << _unset
(filename, dir) << system.pathname_components( file_path )
module_dir << system.locate_file( dir, "module.def" )
_if module_dir _isnt _unset
_then
res << sw_module_manager.module_roots( module_dir, _false )
_if _not res.empty?
_then
module_name << res.a_key()[1]
_if module_name _is _unset _orif
module_name.size _is 0 _orif
module_name[1] = %#
_then
module_name << _unset
mod_def << system.pathname_down(module_dir, "module.def")
_if system.file_exists?(mod_def)
_then
a_stream << _unset
_protect
a_stream << external_text_input_stream.new(mod_def)
_loop
_if (a_line << a_stream.get_line()) _is _unset
_then
_leave
_endif
a_line << a_line.trim_spaces()
_if a_line.size > 0 _andif a_line[1] <> %#
_then
module_name << _if a_line.index_of(%tab) _isnt _unset
_then
>> a_line.split_by(%tab)[1]
_else
>> a_line.split_by(%space)[1]
_endif
_leave
_endif
_endloop
_protection
_if a_stream _isnt _unset
_then
a_stream.close()
_endif
_endprotect
_endif