mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 17:23:51 -05:00
Automatically add intermediate folders for SQL project items. (#16332)
* Automatically add intermediate folders for SQL project items. While using the SQL database projects through the API, I noticed that project may end up in somewhat inconsistent state, where files will be added to the project, but their parent folders will not. This in turn resulted in failure to remove these folders from project - they will show up in the UI tree, but deleting them will cause an error. In order to align with how Visual Studio manages the projects, this change will ensure that all intermediate folders are present in the project, when new files or folders are added. While this change improves project "correctness" when accessing it through SQL projects extension APIs, there is still a possibility that someone will open an "incorrect" previously created project. This change does not address it and folder removal may still fail. * Update the code to never throw on duplicate items when adding files and folders to project. After a conversation with the sqlproj owners, we agreed that there are no scenarios that would prompt us to throw an error, if duplicate item is being added to the project. Ultimately, the goal of such a request would be to have an item in the project file, which is already present, therefore the call becomes a no-op. This allowed me to simplify the new code that was ensuring all intermediate folders are present in the project when adding files and folders.
This commit is contained in:
@@ -45,30 +45,26 @@ declare module 'sqldbproj' {
|
||||
|
||||
/**
|
||||
* Adds the list of sql files and directories to the project, and saves the project file
|
||||
*
|
||||
* @param list list of files and folder Uris. Files and folders must already exist. No files or folders will be added if any do not exist.
|
||||
* @param doNotThrowOnDuplicate Flag that indicates whether duplicate entries should be ignored or throw an error.
|
||||
*/
|
||||
addToProject(list: vscode.Uri[], doNotThrowOnDuplicate?: boolean): Promise<void>;
|
||||
addToProject(list: vscode.Uri[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Adds a folder to the project, and saves the project file
|
||||
*
|
||||
* @param relativeFolderPath Relative path of the folder
|
||||
* @param doNotThrowOnDuplicate
|
||||
* Flag that indicates whether duplicate entries should be ignored or throw an error. If flag is set to `true` and
|
||||
* item already exists in the project file, then existing entry will be returned.
|
||||
*/
|
||||
addFolderItem(relativeFolderPath: string, doNotThrowOnDuplicate?: boolean): Promise<IFileProjectEntry>;
|
||||
addFolderItem(relativeFolderPath: string): Promise<IFileProjectEntry>;
|
||||
|
||||
/**
|
||||
* Writes a file to disk if contents are provided, adds that file to the project, and writes it to disk
|
||||
*
|
||||
* @param relativeFilePath Relative path of the file
|
||||
* @param contents Contents to be written to the new file
|
||||
* @param itemType Type of the project entry to add. This maps to the build action for the item.
|
||||
* @param doNotThrowOnDuplicate
|
||||
* Flag that indicates whether duplicate entries should be ignored or throw an error. If flag is set to `true` and
|
||||
* item already exists in the project file, then existing entry will be returned.
|
||||
*/
|
||||
addScriptItem(relativeFilePath: string, contents?: string, itemType?: string, doNotThrowOnDuplicate?: boolean): Promise<IFileProjectEntry>;
|
||||
addScriptItem(relativeFilePath: string, contents?: string, itemType?: string): Promise<IFileProjectEntry>;
|
||||
|
||||
/**
|
||||
* Adds a SQLCMD variable to the project
|
||||
|
||||
Reference in New Issue
Block a user