Skip to content

Commit

Permalink
Exclude Namespace prefix (#311)
Browse files Browse the repository at this point in the history
* New setting: NamespacePrefixToIgnore

* New setting: NamespacePrefixToIgnore
  • Loading branch information
vdevmt authored Dec 19, 2024
1 parent 8d00f3a commit b1b5b51
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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* )?\"*",
Expand Down
1 change: 1 addition & 0 deletions src/NAVObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export class NAVObject {
this.objectType = '';
this.objectId = '';
this.objectName = '';
this.objectNamespace = '';
this.extendedObjectName = '';
this.extendedObjectId = '';

Expand Down
2 changes: 2 additions & 0 deletions src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions src/WorkspaceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1b5b51

Please sign in to comment.