From b1b5b510a2ac5230e8ebcf78df6e3d0e6fcf45a0 Mon Sep 17 00:00:00 2001 From: Vito Iacovone <83955400+vdevmt@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:38:17 +0100 Subject: [PATCH] Exclude Namespace prefix (#311) * New setting: NamespacePrefixToIgnore * New setting: NamespacePrefixToIgnore --- README.md | 1 + package.json | 6 ++++++ src/NAVObject.ts | 1 + src/Settings.ts | 2 ++ src/WorkspaceFiles.ts | 11 +++++++++-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ec99d05..cf055c2e 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ tableextension 50100 "Just Some Table Extension" extends Customer //18 * `SkipWarningMessageOnRenameAll`: Skips the Warning when renaming all files which can disturb custom VS tasks. * `RenameWithGit`: Use 'git mv' to rename a file. This keeps history of the file, but stages the rename, which you should commit separately. **The feature is still in preview-mode, therefore the default value is 'false'** * `ReorganizeByNamespace`: This is a feature that allows for the automatic reorganization of files by creating folder structures based on the namespaces defined within the files. **The feature is still in preview-mode, therefore the default value is 'false'** +* `NamespacePrefixToIgnore`: This configuration allows you to exclude a part of Namespace during the files reorganization process based on the namespaces defined within the files. **The feature is still in preview-mode** ## Skip String manipulation You can skip string manipulation by adding comments to your code: diff --git a/package.json b/package.json index 1b7d53be..7492d6f2 100644 --- a/package.json +++ b/package.json @@ -273,6 +273,12 @@ "description": "This is a feature that allows for the automatic reorganization of files by creating folder structures based on the namespaces defined within the files. The feature is still in preview-mode, therefore the default value is 'false'", "scope": "resource" }, + "CRS.NamespacePrefixToIgnore": { + "type": "string", + "default": "", + "description": "This configuration allows you to exclude a part of Namespace during the files reorganization process based on the namespaces defined within the files. The feature is still in preview-mode", + "scope": "resource" + }, "CRS.SearchObjectNamesRegexPattern": { "type": "string", "default": "^\\w+ (\\d* )?\"*", diff --git a/src/NAVObject.ts b/src/NAVObject.ts index a3e29c1f..05501716 100644 --- a/src/NAVObject.ts +++ b/src/NAVObject.ts @@ -297,6 +297,7 @@ export class NAVObject { this.objectType = ''; this.objectId = ''; this.objectName = ''; + this.objectNamespace = ''; this.extendedObjectName = ''; this.extendedObjectId = ''; diff --git a/src/Settings.ts b/src/Settings.ts index 64bdf4b9..62942193 100644 --- a/src/Settings.ts +++ b/src/Settings.ts @@ -35,6 +35,7 @@ export class Settings { static readonly DisableCRSSnippets = 'DisableCRSSnippets'; static readonly RenameWithGit = 'RenameWithGit'; static readonly ReorganizeByNamespace = 'ReorganizeByNamespace'; + static readonly NamespacePrefixToIgnore = 'NamespacePrefixToIgnore'; static readonly Browser = 'browser'; static readonly Incognito = 'incognito'; static readonly packageCachePath = 'packageCachePath'; @@ -102,6 +103,7 @@ export class Settings { this.SettingCollection[this.PublicWebBaseUrl] = this.getSetting(this.PublicWebBaseUrl); this.SettingCollection[this.RenameWithGit] = this.getSetting(this.RenameWithGit); this.SettingCollection[this.ReorganizeByNamespace] = this.getSetting(this.ReorganizeByNamespace); + this.SettingCollection[this.NamespacePrefixToIgnore] = this.getSetting(this.NamespacePrefixToIgnore); this.SettingCollection[this.SearchObjectNamesRegexPattern] = this.getSetting(this.SearchObjectNamesRegexPattern); this.SettingCollection[this.DependencyGraphIncludeTestApps] = this.getSetting(this.DependencyGraphIncludeTestApps); this.SettingCollection[this.DependencyGraphExcludeAppNames] = this.getSetting(this.DependencyGraphExcludeAppNames); diff --git a/src/WorkspaceFiles.ts b/src/WorkspaceFiles.ts index a3ab46e8..d358d3f4 100644 --- a/src/WorkspaceFiles.ts +++ b/src/WorkspaceFiles.ts @@ -317,8 +317,15 @@ export class WorkspaceFiles { } if (mySettings[Settings.ReorganizeByNamespace]) { - let directoryPath = path.join(...navObject.objectNamespace.split(".")) - return directoryPath + let directoryPath = path.join(...navObject.objectNamespace.split(".")); + + if (mySettings[Settings.NamespacePrefixToIgnore]) { + directoryPath = path.join( + ...navObject.objectNamespace.replace(new RegExp(`^${mySettings[Settings.NamespacePrefixToIgnore]}\\.?`), "").split(".") + ); + } + + return directoryPath; } return navObject.objectType