mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -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:
@@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
|
||||
/**
|
||||
* Base class for an item that appears in the ADS project tree
|
||||
*/
|
||||
export abstract class BaseProjectTreeItem {
|
||||
uri: vscode.Uri;
|
||||
parent?: BaseProjectTreeItem;
|
||||
|
||||
constructor(uri: vscode.Uri, parent?: BaseProjectTreeItem) {
|
||||
this.uri = uri;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
abstract get children(): BaseProjectTreeItem[];
|
||||
|
||||
abstract get treeItem(): vscode.TreeItem;
|
||||
|
||||
public get root() {
|
||||
let node: BaseProjectTreeItem = this;
|
||||
|
||||
while (node.parent !== undefined) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaf tree item that just displays text for messaging purposes
|
||||
*/
|
||||
export class MessageTreeItem extends BaseProjectTreeItem {
|
||||
private message: string;
|
||||
|
||||
constructor(message: string, parent?: BaseProjectTreeItem) {
|
||||
super(vscode.Uri.file(path.join(parent?.uri.path ?? 'Message', message)), parent);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
return new vscode.TreeItem(this.message, vscode.TreeItemCollapsibleState.None);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user