mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 09:35:38 -05:00
.sqlproj and datasources.json file parsing (#8921)
* Checkpoint * Adding mock contents for tree * added open sqlproj dialog * reading files from directory * Added directory traversal * Adding tree sorting by folder vs file and label * Improved auto-unfolding of tree based on node type * replacing fs with fs.promise alias * PR feedback * added activation event for when workspace contains sqlproj files * Returning after displaying error * Fixing linter errors * Reworked tree * Fixing missing grandchildren * Correcting tree URI construction * Refactoring to isolate tree item responsibilities from data model responsibilities * project file parsing * constructing tree from project files rather than filesystem * Fixing double-initialization * Changing projectEntry to take enum for file type * Correct node type for project item * Parsing datasources.json * Child nodes for sql data source * Localizing strings * Checkpoint * Adding mock contents for tree * added open sqlproj dialog * reading files from directory * Added directory traversal * Adding tree sorting by folder vs file and label * Improved auto-unfolding of tree based on node type * replacing fs with fs.promise alias * PR feedback * added activation event for when workspace contains sqlproj files * Returning after displaying error * Fixing linter errors * Reworked tree * Fixing missing grandchildren * Correcting tree URI construction * Refactoring to isolate tree item responsibilities from data model responsibilities * project file parsing * constructing tree from project files rather than filesystem * Fixing double-initialization * Changing projectEntry to take enum for file type * Correct node type for project item * Parsing datasources.json * Child nodes for sql data source * Localizing strings * missed file in merge * changed extension method to helper * cleanup * Adding docstrings
This commit is contained in:
@@ -3,7 +3,45 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
/**
|
||||
* Consolidates on the error message string
|
||||
*/
|
||||
export function getErrorMessage(error: Error | string): string {
|
||||
return (error instanceof Error) ? error.message : error;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes any leading portion shared between the two URIs from outerUri.
|
||||
* e.g. [@param innerUri: 'this\is'; @param outerUri: '\this\is\my\path'] => 'my\path'
|
||||
* @param innerUri the URI that will be cut away from the outer URI
|
||||
* @param outerUri the URI that will have any shared beginning portion removed
|
||||
*/
|
||||
export function trimUri(innerUri: vscode.Uri, outerUri: vscode.Uri): string {
|
||||
let innerParts = innerUri.path.split('/');
|
||||
let outerParts = outerUri.path.split('/');
|
||||
|
||||
while (innerParts.length > 0 && outerParts.length > 0 && innerParts[0].toLocaleLowerCase() === outerParts[0].toLocaleLowerCase()) {
|
||||
innerParts = innerParts.slice(1);
|
||||
outerParts = outerParts.slice(1);
|
||||
}
|
||||
|
||||
return outerParts.join('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims any character contained in @param chars from both the beginning and end of @param input
|
||||
*/
|
||||
export function trimChars(input: string, chars: string): string {
|
||||
let output = input;
|
||||
|
||||
let i = 0;
|
||||
while (chars.includes(output[i])) { i++; }
|
||||
output = output.substr(i);
|
||||
|
||||
i = 0;
|
||||
while (chars.includes(output[output.length - i - 1])) { i++; }
|
||||
output = output.substring(0, output.length - i);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user