@@ -416,17 +416,32 @@ This method watches only for tail of global and detects if global still alive</D
416
416
<Method name =" GenerateAutocompleteFile" >
417
417
<Description >
418
418
Generates autocomplete file for namespace. Second parameter deсides if
419
- it will be regenerated again </Description >
419
+ it will be regenerated again. But if namespace equals to "%" - generates
420
+ autocomplete file for system classes. Make sure that autocomplete for
421
+ system classes generates one time and forever. </Description >
420
422
<FormalSpec >namespace:%String,newFile:%Boolean</FormalSpec >
421
423
<ReturnType >%String</ReturnType >
422
424
<Implementation ><![CDATA[
425
+
423
426
set filename = ..GetJSAutocompleteFilePath($NAMESPACE)
424
427
428
+ set system = 0
429
+ if (namespace = "%") {
430
+ set namespace = "%SYS"
431
+ set filename = ..GetJSAutocompleteFilePath("_")
432
+ set system = 1
433
+ }
434
+
435
+ if (system) && (##class(%File).Exists(filename)) {
436
+ do ..SendData("_", ..ConstClientLoadAutocomplete)
437
+ quit $$$OK
438
+ }
439
+
425
440
do ..StartClearIO()
426
441
427
- if ('##class(%SYS.Namespace).Exists($REPLACE( namespace,"_","%") )) {
442
+ if ('##class(%SYS.Namespace).Exists(namespace)) {
428
443
do ..EndClearIO()
429
- do ..SendData("Wrong namespace name : " _ namespace)
444
+ do ..SendData("Wrong namespace: " _ namespace)
430
445
quit $$$NOTOK
431
446
}
432
447
@@ -449,15 +464,12 @@ it will be regenerated again </Description>
449
464
quit $$$OK
450
465
}
451
466
452
- set filename = ..GetJSAutocompleteFilePath(namespace)
453
-
454
467
}
455
468
456
- do ..SendData("Generating language file for " _ namespace _ ", pleace, wait.")
457
-
458
- // write empty file in case of other terminal applications may require it
459
- //do ..WriteToFile(filename,"{}")
460
-
469
+ set thisName = $REPLACE(namespace,"_","%")
470
+ if (system) { set thisName = "SYSTEM" }
471
+ do ..SendData("Generating language file for " _ thisName _ ", pleace, wait. ")
472
+
461
473
// get all classes names
462
474
set result = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
463
475
do result.Execute()
@@ -466,14 +478,20 @@ it will be regenerated again </Description>
466
478
The next COULD BE IMPROVED FOR SPEED, I beleive.
467
479
Generates compressed JSON string of type:
468
480
{
469
- "%ClassName1": {
470
- "methodName": 0,
471
- "propertyName": 0,
472
- "parameterName": 0,
473
- ...
481
+ "class": {
482
+ "%ClassName1": {
483
+ "methodName": 0,
484
+ "propertyName": 0,
485
+ "parameterName": 0,
486
+ ...
487
+ },
488
+ "ClassName2": {
489
+ ...
490
+ }
474
491
},
475
- "ClassName2": {
476
- ...
492
+ "global": {
493
+ "^%g1": 0,
494
+ "^g2": 0
477
495
}
478
496
}
479
497
*/
@@ -488,6 +506,9 @@ it will be regenerated again </Description>
488
506
while (result.Next()) { // forming autocomplete for each class
489
507
490
508
set className = result.Data("Name")
509
+ if (($EXTRACT(className,1)="%")'=system) {
510
+ continue
511
+ }
491
512
do file.Write(first _ """" _ className _ """:{")
492
513
if (first = "") set first = ","
493
514
@@ -501,36 +522,39 @@ it will be regenerated again </Description>
501
522
502
523
for i=1:1:countMethods {
503
524
set current = current + 1
504
- do file.Write("""" _cdefs .Methods.GetAt(i).Name _ """:0")
525
+ do file.Write("""" _ cdefs .Methods.GetAt(i).Name _ """:0")
505
526
if (current'=total) do file.Write(",")
506
527
}
507
528
508
529
for i=1:1:countProperties {
509
530
set current = current + 1
510
- do file.Write("""" _cdefs .Properties.GetAt(i).Name _ """:0")
531
+ do file.Write("""" _ cdefs .Properties.GetAt(i).Name _ """:0")
511
532
if (current'=total) do file.Write(",")
512
533
}
513
534
514
535
for i=1:1:countParameters {
515
536
set current = current + 1
516
- do file.Write("""" _cdefs .Parameters.GetAt(i).Name _ """:0")
537
+ do file.Write("""" _ cdefs .Parameters.GetAt(i).Name _ """:0")
517
538
if (current'=total) do file.Write(",")
518
539
}
519
540
520
541
do file.Write("}")
521
542
522
543
}
523
544
524
- do file.Write("},""global"":" _ ..getGlobalsJSON() _"}")
525
-
545
+ do file.Write("}")
546
+ if ('system) {
547
+ do file.Write(",""global"":" _ ..getGlobalsJSON())
548
+ }
549
+ do file.Write("}")
526
550
do file.Close()
527
- //do ..WriteToFile(filename,data)
528
551
529
- do ..SendData($c(10)_"Language file for " _ namespace _ " classes created .")
552
+ do ..SendData($c(10)_"Language file for " _ thisName _ " generated .")
530
553
531
554
do ..EndClearIO()
532
-
533
- do ..SendData(namespace,..ConstClientLoadAutocomplete)
555
+ if (system) {
556
+ do ..SendData("_",..ConstClientLoadAutocomplete)
557
+ } else { do ..SendData(namespace,..ConstClientLoadAutocomplete) }
534
558
535
559
quit $$$OK
536
560
]]> </Implementation >
@@ -759,10 +783,10 @@ Method description:
759
783
760
784
set result = ..AddWatch(data)
761
785
if ('$$$ISOK(result)) {
762
- set result = ..RemoveWatch(data)
763
- if ('$$$ISOK(result)) {
764
- do ..SendData("unreal", ..ConstClientWatch)
765
- }
786
+ set result = ..RemoveWatch(data)
787
+ if ('$$$ISOK(result)) {
788
+ do ..SendData("unreal", ..ConstClientWatch)
789
+ }
766
790
}
767
791
768
792
} elseif (action = ..ConstServerActionExecuteSQL) { // sql
@@ -771,6 +795,7 @@ Method description:
771
795
772
796
} elseif (action = ..ConstServerActionGenerateAutocomplete) {
773
797
798
+ do ..GenerateAutocompleteFile("%", data)
774
799
do ..GenerateAutocompleteFile(..CurrentNamespace, data)
775
800
776
801
} elseif (action = ..ConstServerActionReset) {
0 commit comments