mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
fix project tree tests failing on windows (#14759)
* fix project tree tests failing on windows * add back test * Addressing comments * change to doc comment * remove unnecessary change * undo other change
This commit is contained in:
@@ -10,11 +10,12 @@ import * as path from 'path';
|
||||
* Base class for an item that appears in the ADS project tree
|
||||
*/
|
||||
export abstract class BaseProjectTreeItem {
|
||||
uri: vscode.Uri;
|
||||
/** Project-relative URI that's compatible with the project tree */
|
||||
projectUri: vscode.Uri;
|
||||
parent?: BaseProjectTreeItem;
|
||||
|
||||
constructor(uri: vscode.Uri, parent?: BaseProjectTreeItem) {
|
||||
this.uri = uri;
|
||||
this.projectUri = uri;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ export abstract class BaseProjectTreeItem {
|
||||
abstract get treeItem(): vscode.TreeItem;
|
||||
|
||||
public get friendlyName(): string {
|
||||
return path.parse(this.uri.path).base;
|
||||
return path.parse(this.projectUri.path).base;
|
||||
}
|
||||
|
||||
public get root() {
|
||||
@@ -44,7 +45,7 @@ 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);
|
||||
super(vscode.Uri.file(path.join(parent?.projectUri.path ?? 'Message', message)), parent);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DataSourcesTreeItem extends BaseProjectTreeItem {
|
||||
private dataSources: DataSourceTreeItem[] = [];
|
||||
|
||||
constructor(project: ProjectRootTreeItem) {
|
||||
super(vscode.Uri.file(path.join(project.uri.path, constants.dataSourcesNodeName)), project);
|
||||
super(vscode.Uri.file(path.join(project.projectUri.path, constants.dataSourcesNodeName)), project);
|
||||
|
||||
this.construct();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class DataSourcesTreeItem extends BaseProjectTreeItem {
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const dataSources = new vscode.TreeItem(this.uri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
const dataSources = new vscode.TreeItem(this.projectUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
dataSources.contextValue = constants.DatabaseProjectItemType.dataSourceRoot;
|
||||
dataSources.iconPath = IconPathHelper.dataSourceGroup;
|
||||
|
||||
@@ -50,11 +50,11 @@ abstract class DataSourceTreeItem extends BaseProjectTreeItem { }
|
||||
*/
|
||||
export class SqlConnectionDataSourceTreeItem extends DataSourceTreeItem {
|
||||
constructor(private dataSource: SqlConnectionDataSource, dataSourcesNode: DataSourcesTreeItem) {
|
||||
super(vscode.Uri.file(path.join(dataSourcesNode.uri.path, dataSource.name)), dataSourcesNode);
|
||||
super(vscode.Uri.file(path.join(dataSourcesNode.projectUri.path, dataSource.name)), dataSourcesNode);
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
let item = new vscode.TreeItem(this.uri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
let item = new vscode.TreeItem(this.projectUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
item.label = `${this.dataSource.name} (${this.dataSource.typeFriendlyName})`;
|
||||
item.iconPath = IconPathHelper.dataSourceSql;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
private references: DatabaseReferenceTreeItem[] = [];
|
||||
|
||||
constructor(project: ProjectRootTreeItem) {
|
||||
super(vscode.Uri.file(path.join(project.uri.path, constants.databaseReferencesNodeName)), project);
|
||||
super(vscode.Uri.file(path.join(project.projectUri.fsPath, constants.databaseReferencesNodeName)), project);
|
||||
|
||||
this.construct();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const refFolderItem = new vscode.TreeItem(this.uri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
const refFolderItem = new vscode.TreeItem(this.projectUri, vscode.TreeItemCollapsibleState.Collapsed);
|
||||
refFolderItem.contextValue = constants.DatabaseProjectItemType.referencesRoot;
|
||||
refFolderItem.iconPath = IconPathHelper.referenceGroup;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class DatabaseReferencesTreeItem extends BaseProjectTreeItem {
|
||||
|
||||
export class DatabaseReferenceTreeItem extends BaseProjectTreeItem {
|
||||
constructor(private reference: IDatabaseReferenceProjectEntry, referencesTreeItem: DatabaseReferencesTreeItem) {
|
||||
super(vscode.Uri.file(path.join(referencesTreeItem.uri.path, reference.databaseName)), referencesTreeItem);
|
||||
super(vscode.Uri.file(path.join(referencesTreeItem.projectUri.fsPath, reference.databaseName)), referencesTreeItem);
|
||||
}
|
||||
|
||||
public get children(): BaseProjectTreeItem[] {
|
||||
@@ -53,7 +53,7 @@ export class DatabaseReferenceTreeItem extends BaseProjectTreeItem {
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const refItem = new vscode.TreeItem(this.uri, vscode.TreeItemCollapsibleState.None);
|
||||
const refItem = new vscode.TreeItem(this.projectUri, vscode.TreeItemCollapsibleState.None);
|
||||
refItem.label = this.reference.databaseName;
|
||||
refItem.contextValue = constants.DatabaseProjectItemType.reference;
|
||||
refItem.iconPath = IconPathHelper.referenceDatabase;
|
||||
|
||||
@@ -88,12 +88,10 @@ export class ExternalStreamingJobFileNode extends FileNode {
|
||||
export function sortFileFolderNodes(a: (FolderNode | FileNode), b: (FolderNode | FileNode)): number {
|
||||
if (a instanceof FolderNode && !(b instanceof FolderNode)) {
|
||||
return -1;
|
||||
}
|
||||
else if (!(a instanceof FolderNode) && b instanceof FolderNode) {
|
||||
} else if (!(a instanceof FolderNode) && b instanceof FolderNode) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return a.uri.fsPath.localeCompare(b.uri.fsPath);
|
||||
} else {
|
||||
return a.projectUri.fsPath.localeCompare(b.projectUri.fsPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +104,12 @@ function fsPathToProjectUri(fileSystemUri: vscode.Uri, projectNode: ProjectRootT
|
||||
|
||||
if (fileSystemUri.fsPath.startsWith(projBaseDir)) {
|
||||
localUri = fileSystemUri.fsPath.substring(projBaseDir.length);
|
||||
}
|
||||
else if (isFile) {
|
||||
} else if (isFile) {
|
||||
// if file is outside the folder add add at top level in tree
|
||||
// this is not true for folders otherwise the outside files will not be directly inside the top level
|
||||
let parts = utils.getPlatformSafeFileEntryPath(fileSystemUri.fsPath).split('/');
|
||||
const parts = utils.getPlatformSafeFileEntryPath(fileSystemUri.fsPath).split('/');
|
||||
localUri = parts[parts.length - 1];
|
||||
}
|
||||
|
||||
return vscode.Uri.file(path.join(projectNode.uri.path, localUri));
|
||||
return vscode.Uri.file(path.join(projectNode.projectUri.fsPath, localUri));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
|
||||
fileSystemUri: vscode.Uri;
|
||||
|
||||
constructor(project: Project) {
|
||||
super(vscode.Uri.file(project.projectFilePath), undefined);
|
||||
super(vscode.Uri.parse(path.basename(project.projectFilePath, sqlprojExtension)), undefined);
|
||||
|
||||
this.project = project;
|
||||
this.fileSystemUri = vscode.Uri.file(project.projectFilePath);
|
||||
@@ -45,10 +45,10 @@ export class ProjectRootTreeItem extends BaseProjectTreeItem {
|
||||
}
|
||||
|
||||
public get treeItem(): vscode.TreeItem {
|
||||
const projectItem = new vscode.TreeItem(this.uri, vscode.TreeItemCollapsibleState.Expanded);
|
||||
const projectItem = new vscode.TreeItem(this.fileSystemUri, vscode.TreeItemCollapsibleState.Expanded);
|
||||
projectItem.contextValue = DatabaseProjectItemType.project;
|
||||
projectItem.iconPath = IconPathHelper.databaseProject;
|
||||
projectItem.label = path.basename(this.uri.fsPath, sqlprojExtension);
|
||||
projectItem.label = path.basename(this.projectUri.fsPath, sqlprojExtension);
|
||||
|
||||
return projectItem;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user