From 08c18a0644967d6bd8229065538576a1f90ae90f Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 31 Aug 2023 07:20:51 -0400 Subject: [PATCH] Fix display of routines inside a server-side project (#1226) --- src/utils/FileProviderUtil.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/utils/FileProviderUtil.ts b/src/utils/FileProviderUtil.ts index 3b0b37f3..bb4dce4a 100644 --- a/src/utils/FileProviderUtil.ts +++ b/src/utils/FileProviderUtil.ts @@ -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)))) " + @@ -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 (" + @@ -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, @@ -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 " +