Skip to content

Commit 50446cf

Browse files
authored
Merge pull request #242 from intersystems/fix-studio-dtl
Fix behavior with BPL/DTL editing via Studio
2 parents ca4aebc + 5d73357 commit 50446cf

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111
- Link from WebUI to Settings page works properly (#230)
1212
- VSCode Web Views launch in external browser when connecting over unsecured connections (#227)
13+
- DTL/BPL editing through Studio reflected properly in source control
1314

1415
## [2.1.0] - 2023-01-23
1516

cls/SourceControl/Git/Extension.cls

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
138138
set Enabled = $case(menuItemName,"AddToSC":1,"RemoveFromSC":1,:-1)
139139
} elseif menuItemName = "Revert" {
140140
set Enabled = 1
141-
do ..GetStatus(itemName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
141+
do ..GetStatus(.itemName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
142142
if '(##class(Change).IsUncommitted(##class(Utils).FullExternalName(itemName))) || ($username '= userCheckedOut) {
143143
set Enabled = 0
144144
}
145145
} elseif menuItemName = "Commit" {
146146
set Enabled = 1
147-
do ..GetStatus(itemName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
147+
do ..GetStatus(.itemName, .isInSourceControl, .isEditable,.isCheckedOut,.userCheckedOut)
148148
if '(##class(Change).IsUncommitted(##class(Utils).FullExternalName(itemName))) || ($username '= userCheckedOut) {
149149
set Enabled = 0
150150
}
@@ -210,7 +210,7 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
210210
{
211211
set sc = $$$OK
212212
try {
213-
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
213+
set InternalName = ##class(Utils).NormalizeInternalName(.InternalName)
214214
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
215215
if ##class(Utils).IsNamespaceInGit() && ..IsInSourceControl(InternalName) {
216216
set filename = ##class(Utils).FullExternalName(InternalName)
@@ -277,11 +277,11 @@ Method IsReadOnly(InternalName As %String) As %Boolean
277277
/// Check the status of the given item
278278
/// User should be able to edit the item if it is not locked by another user
279279
/// Check if another user has committed any changes to the item and return the status
280-
Method GetStatus(InternalName As %String, ByRef IsInSourceControl As %Boolean, ByRef Editable As %Boolean, ByRef IsCheckedOut As %Boolean, ByRef UserCheckedOut As %String) As %Status
280+
Method GetStatus(ByRef InternalName As %String, ByRef IsInSourceControl As %Boolean, ByRef Editable As %Boolean, ByRef IsCheckedOut As %Boolean, ByRef UserCheckedOut As %String) As %Status
281281
{
282-
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
282+
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(.InternalName)
283283
set Editable='..IsReadOnly(),IsCheckedOut=1,UserCheckedOut=""
284-
set filename=##class(SourceControl.Git.Utils).FullExternalName(InternalName)
284+
set filename=##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
285285
set IsInSourceControl=(filename'=""&&($$$FileExists(filename)))
286286
if filename="" quit $$$OK
287287
if InternalName="" quit $$$OK

cls/SourceControl/Git/PackageManagerContext.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ClassMethod ForInternalName(InternalName As %String = "") As SourceControl.Git.P
3434
{
3535
set instance = ..%Get()
3636
set instance.InternalName = InternalName
37+
set InternalName = instance.InternalName
3738
quit instance
3839
}
3940

cls/SourceControl/Git/Utils.cls

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
262262

263263
ClassMethod Revert(InternalName As %String) As %Status
264264
{
265-
set filename = ..FullExternalName(InternalName)
265+
set filename = ..FullExternalName(.InternalName)
266266
do ..RunGitCommand("checkout", .errStream, .outStream, "--", filename)
267267
$$$QuitOnError(##class(SourceControl.Git.Change).RemoveUncommitted(filename,0,1))
268268
$$$QuitOnError(##class(SourceControl.Git.Change).RefreshUncommitted(0,1))
@@ -272,7 +272,7 @@ ClassMethod Revert(InternalName As %String) As %Status
272272

273273
ClassMethod Commit(InternalName As %String, Message As %String = "example commit message") As %Status
274274
{
275-
set filename = ..FullExternalName(InternalName)
275+
set filename = ..FullExternalName(.InternalName)
276276
set username = ..GitUserName()
277277
set email = ..GitUserEmail()
278278
set author = username_" <"_email_">"
@@ -430,7 +430,7 @@ ClassMethod NormalizeFolder(folder As %String) As %String
430430

431431
ClassMethod ExternalName(InternalName As %String, ByRef MappingExists As %Boolean) As %String
432432
{
433-
quit ..Name(InternalName,.MappingExists)
433+
quit ..Name(.InternalName,.MappingExists)
434434
}
435435

436436
ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
@@ -454,7 +454,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
454454
#dim ec as %Status = $$$OK
455455
for i = 1:1:$length(InternalName, ",") {
456456
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
457-
#dim type as %String = ..Type(item)
457+
#dim type as %String = ..Type(.item)
458458

459459
#dim sc as %Status = ..ExportItem(item,,1,.filenames)
460460
if 'sc {
@@ -465,7 +465,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
465465
if (FileInternalName = "") {
466466
continue
467467
}
468-
set FileType = ##class(SourceControl.Git.Utils).Type(FileInternalName)
468+
set FileType = ##class(SourceControl.Git.Utils).Type(.FileInternalName)
469469

470470
set @..#Storage@("items", FileInternalName) = ""
471471
do ..RunGitCommand("add",.errStream,.outStream,filenames(i))
@@ -491,7 +491,7 @@ ClassMethod RemoveFromGit(InternalName)
491491

492492
ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status
493493
{
494-
#dim type as %String = ..Type(InternalName)
494+
#dim type as %String = ..Type(.InternalName)
495495
#dim ec as %Status = $$$OK
496496
if (type = "prj") || (type = "pkg") || (type = "csp" && ..IsCspFolder(InternalName)) {
497497
// we delete complex items
@@ -588,7 +588,7 @@ ClassMethod FindTrackedFilesInCSPFolders(InternalName As %String, ByRef trackedF
588588
ClassMethod FindTrackedFiles(InternalName As %String, ByRef trackedFiles As %String) As %Status
589589
{
590590

591-
#dim type as %String = ..Type(InternalName)
591+
#dim type as %String = ..Type(.InternalName)
592592
set InternalName = ..NameWithoutExtension(InternalName)
593593

594594
if (type = "pkg") {
@@ -604,7 +604,7 @@ ClassMethod FindTrackedFiles(InternalName As %String, ByRef trackedFiles As %Str
604604
/// Description
605605
ClassMethod FindTrackedParent(InternalName As %String, ByRef parentElement As %String) As %Status
606606
{
607-
#dim type as %String = ..Type(InternalName)
607+
#dim type as %String = ..Type(.InternalName)
608608
set isInSourceControl = 0
609609
if type = "cls" {
610610
#define StripExtension(%s) $Piece(%s,".",1,$Length(%s, ".") - 1)
@@ -638,7 +638,7 @@ ClassMethod RemoveFromServerSideSourceControl(InternalName As %String) As %Statu
638638
for i = 1:1:$length(InternalName, ",") {
639639
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
640640
#dim tsc as %Status = $$$OK
641-
#dim type as %String = ..Type(InternalName)
641+
#dim type as %String = ..Type(.InternalName)
642642

643643
if $data(@..#Storage@("items", item)) {
644644
kill @..#Storage@("items", item)
@@ -661,7 +661,7 @@ ClassMethod RemoveFromSourceControl(InternalName As %String, cascadeDelete As %B
661661
}
662662
for i = 1:1:$length(InternalName, ",") {
663663
#dim tsc as %Status = $$$OK
664-
#dim type as %String = ..Type(InternalName)
664+
#dim type as %String = ..Type(.InternalName)
665665

666666
set item = $piece(InternalName, ",", i)
667667
if $data(@..#Storage@("items", ..NormalizeExtension(item))) {
@@ -726,6 +726,20 @@ ClassMethod Type(InternalName As %String) As %String
726726
}
727727
}
728728

729+
// For an abstract document, use the GetOther() method to try to determine its "real" class
730+
If ##class(%RoutineMgr).UserType(InternalName,.docclass,.doctype) {
731+
// Check for a real abstract document subclass (or GetOther() may not work)
732+
If $classmethod(docclass,"%IsA","%Studio.AbstractDocument") {
733+
// Grab the actual name
734+
Set actualName = $classmethod(docclass,"GetOther",InternalName)
735+
// The actualName is only valid if we get a single .cls as a result
736+
If actualName'[",",$ZCVT($P(actualName,".",$L(actualName,".")),"U")="CLS" {
737+
// We use what GetOther() gives us, thus Demo.Loan.FindRateProcess.bpl becomes Demo.Loan.FindRateProcess.cls
738+
Set InternalName = actualName
739+
}
740+
}
741+
}
742+
729743
quit type
730744
}
731745

@@ -746,7 +760,7 @@ ClassMethod IsItemInProject(InternalName As %String, projectName As %String) As
746760
// we should check two cases
747761
// direct inclusion
748762
// inclusion in package or csp-folder that contained in project
749-
#dim type as %String = ..Type(InternalName)
763+
#dim type as %String = ..Type(.InternalName)
750764
#dim name as %String = $case(type, "cls": ..NameWithoutExtension(InternalName),
751765
"pkg": $translate(..NameWithoutExtension(InternalName), "/", "."),
752766
"csp": $extract(InternalName, 2, *),
@@ -874,7 +888,7 @@ ClassMethod IsInSourceControl(InternalName As %String, ByRef sourceControlItem A
874888
// projects for everything
875889
// csp-folders for csp and static files
876890

877-
#dim type as %String = ..Type(InternalName)
891+
#dim type as %String = ..Type(.InternalName)
878892
if type = "cls" {
879893
#define StripExtension(%s) $Piece(%s,".",1,$Length(%s, ".") - 1)
880894
set className = $$$StripExtension(InternalName)
@@ -898,12 +912,12 @@ ClassMethod IsInSourceControl(InternalName As %String, ByRef sourceControlItem A
898912
quit isInSourceControl
899913
}
900914

901-
ClassMethod FullExternalName(InternalName As %String, ByRef MappingExists As %Boolean) As %String [ CodeMode = expression ]
915+
ClassMethod FullExternalName(ByRef InternalName As %String, ByRef MappingExists As %Boolean) As %String [ CodeMode = expression ]
902916
{
903-
##class(%File).NormalizeFilename(..TempFolder()_..ExternalName(InternalName, .MappingExists))
917+
##class(%File).NormalizeFilename(..TempFolder()_..ExternalName(.InternalName, .MappingExists))
904918
}
905919

906-
ClassMethod NormalizeInternalName(name As %String) As %String
920+
ClassMethod NormalizeInternalName(ByRef name As %String) As %String
907921
{
908922
//Studio passes name of routine with dots as it is in folders
909923
//e.g. Package.SubPackage.Routine.mac has InternalName = /Package/SubPackage/Routine.mac
@@ -914,12 +928,12 @@ ClassMethod NormalizeInternalName(name As %String) As %String
914928
quit ""
915929
}
916930

931+
set type = ..Type(.name)
932+
917933
if $extract(name) '= "/" {
918934
quit $piece(name,".",1,*-1)_"."_$zconvert($piece(name,".",*),"U")
919935
}
920936

921-
set type = ..Type(name)
922-
923937
if (type = "inc") || (type = "mac") || (type = "int") {
924938
set name = $extract($translate(name, "/", "."), 2, *)
925939
}
@@ -966,7 +980,7 @@ ClassMethod RemoveRoutineTSH(InternalName As %String) As %Status
966980

967981
ClassMethod DeleteExternalFile(InternalName As %String) As %Status
968982
{
969-
#dim fullName = ##class(Utils).FullExternalName(InternalName)
983+
#dim fullName = ##class(Utils).FullExternalName(.InternalName)
970984
#dim ec as %Status = $$$OK
971985
if ##class(%File).Exists(fullName) {
972986
set ec = ##class(%File).Delete(fullName)
@@ -979,7 +993,7 @@ ClassMethod DeleteExternalFile(InternalName As %String) As %Status
979993
/// if temp file for InternalName not found return "0,0" in tempFileTSH
980994
ClassMethod GetTempFileAndRoutineTS(InternalName As %String, ByRef tempFileTSH As %String, ByRef routineTSH As %String)
981995
{
982-
#dim filename as %String = ..FullExternalName(InternalName)
996+
#dim filename as %String = ..FullExternalName(.InternalName)
983997
set tempFileTSH = ##class(%File).GetFileDateModified(filename)
984998
set routineTSH = ..RoutineTSH(InternalName)
985999
//file not found or path not found or some other error
@@ -1031,7 +1045,7 @@ ClassMethod FixProjectCspReferences(projectName As %String) As %Status
10311045
/// if <var>force</var> = 1 then imports in any case.
10321046
ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose As %Boolean = 1) As %Status
10331047
{
1034-
#dim filename as %String = ..FullExternalName(InternalName)
1048+
#dim filename as %String = ..FullExternalName(.InternalName)
10351049
#dim fileTSH = ##class(%File).GetFileDateModified(filename)
10361050
#dim sc as %Status = $$$OK
10371051

@@ -1261,7 +1275,7 @@ ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %In
12611275

12621276
ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0, ByRef filenames) As %Status
12631277
{
1264-
#dim type = ..Type(InternalName)
1278+
#dim type = ..Type(.InternalName)
12651279
if type = "pkg" {
12661280
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force, .filenames))
12671281
}elseif type = "prj" && expand {
@@ -1454,7 +1468,6 @@ ClassMethod GitStatus(ByRef files, IncludeAllFiles = 0)
14541468
*/
14551469
ClassMethod Name(InternalName As %String, ByRef MappingExists As %Boolean) As %String
14561470
{
1457-
14581471
set MappingExists = -1
14591472
set InternalName=##class(%Studio.SourceControl.Interface).normalizeName(InternalName)
14601473
set context = ##class(SourceControl.Git.PackageManagerContext).%Get()

0 commit comments

Comments
 (0)