Skip to content

Commit

Permalink
Fix display of routines inside a server-side project (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano authored Aug 31, 2023
1 parent d40effa commit 08c18a0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/utils/FileProviderUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function projectContentsFromUri(uri: vscode.Uri, overrideFlat?: boo
"WHEN Type = 'CLS' THEN Name||'.cls' " +
"ELSE Name END Name, Type FROM %Studio.Project_ProjectItemsList(?) " +
"WHERE (Name %STARTSWITH ? OR Name %STARTSWITH ?) AND (" +
"(Type = 'MAC' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.mac,*.int,*.inc',1,1,1,1,0,1) AS sod WHERE Name = sod.Name)) OR " +
"(Type = 'MAC' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.mac,*.int,*.inc,*.bas,*.mvi',1,1,1,1,0,1) AS sod WHERE Name = sod.Name)) OR " +
"(Type = 'CSP' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.cspall',1,1,1,1,0,1) AS sod WHERE '/'||Name = sod.Name)) OR " +
"(Type NOT IN ('CLS','PKG','MAC','CSP','DIR','GBL') AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.other',1,1,1,1,0,1) AS sod WHERE Name = sod.Name))) OR " +
"(Type = 'CLS' AND (Package IS NOT NULL OR (Package IS NULL AND EXISTS (SELECT dcd.ID FROM %Dictionary.ClassDefinition AS dcd WHERE dcd.ID = Name)))) " +
Expand All @@ -40,10 +40,13 @@ export async function projectContentsFromUri(uri: vscode.Uri, overrideFlat?: boo
const l = String(folder.length + 1); // Need the + 1 because SUBSTR is 1 indexed
query =
"SELECT sod.Name, pil.Type FROM %Library.RoutineMgr_StudioOpenDialog(?,1,1,1,0,0,1) AS sod JOIN %Studio.Project_ProjectItemsList(?) AS pil ON " +
"(pil.Type = 'MAC' AND ?||sod.Name = pil.Name) OR " +
"(pil.Type = 'CLS' AND ?||sod.Name = pil.Name||'.cls') OR (pil.Type = 'PKG' AND ?||sod.Name = pil.Name) OR " +
"((pil.Type = 'CLS' OR pil.Type = 'PKG') AND pil.Name %STARTSWITH ?||sod.Name||'.') " +
"WHERE pil.Type = 'MAC' OR pil.Type = 'CLS' OR pil.Type = 'PKG' UNION SELECT sod.Name, pil.Type FROM " +
"WHERE pil.Type = 'CLS' OR pil.Type = 'PKG' " +
"UNION SELECT CASE WHEN $LENGTH(SUBSTR(sod.Name,?),'.') > 2 THEN $PIECE(SUBSTR(sod.Name,?),'.') ELSE SUBSTR(sod.Name,?) END Name, pil.Type FROM " +
"%Library.RoutineMgr_StudioOpenDialog(?,1,1,1,1,0,1) AS sod JOIN %Studio.Project_ProjectItemsList(?) AS pil ON " +
"pil.Type = 'MAC' AND sod.Name = pil.Name " +
"UNION SELECT sod.Name, pil.Type FROM " +
"%Library.RoutineMgr_StudioOpenDialog(?,1,1,1,0,0,1) AS sod JOIN %Studio.Project_ProjectItemsList(?,1) AS pil ON " +
"(pil.Type = 'DIR' AND ?||sod.Name %STARTSWITH pil.Name||'/') OR (pil.Type = 'CSP' AND ?||sod.Name = pil.Name) " +
"UNION SELECT $PIECE(SUBSTR(Name,?),'/') AS Name, Type FROM %Studio.Project_ProjectItemsList(?,1) WHERE (" +
Expand All @@ -59,7 +62,11 @@ export async function projectContentsFromUri(uri: vscode.Uri, overrideFlat?: boo
folderDots,
folderDots,
folderDots,
folderDots,
l,
l,
l,
`${folderDots}*.${["mac", "int", "inc", "bas", "mvi"].join(`,${folderDots}*.`)}`,
project,
folder + "*",
project,
folder,
Expand All @@ -83,7 +90,7 @@ export async function projectContentsFromUri(uri: vscode.Uri, overrideFlat?: boo
query =
`SELECT DISTINCT BY (${nameCol}) ${nameCol} ` +
"Name, Type FROM %Studio.Project_ProjectItemsList(?,1) AS pil WHERE " +
"(Type = 'MAC' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.mac,*.int,*.inc',1,1,1,1,0,1) AS sod WHERE pil.Name = sod.Name)) OR " +
"(Type = 'MAC' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.mac,*.int,*.inc,*.bas,*.mvi',1,1,1,1,0,1) AS sod WHERE pil.Name = sod.Name)) OR " +
"(Type = 'CSP' AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.cspall',1,1,1,1,0,1) AS sod WHERE pil.Name = sod.Name)) OR " +
"(Type NOT IN ('CLS','PKG','MAC','CSP','DIR','GBL') AND EXISTS (SELECT sod.Size FROM %Library.RoutineMgr_StudioOpenDialog('*.other',1,1,1,1,0,1) AS sod WHERE " +
"$PIECE(sod.Name,'.',1,$LENGTH(sod.Name,'.')-1) = $PIECE(pil.Name,'.',1,$LENGTH(pil.Name,'.')-1) AND UPPER($PIECE(sod.Name,'.',$LENGTH(sod.Name,'.'))) = $PIECE(pil.Name,'.',$LENGTH(pil.Name,'.')))) OR " +
Expand Down

0 comments on commit 08c18a0

Please sign in to comment.