mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from master
This commit is contained in:
@@ -2,11 +2,9 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -47,10 +45,15 @@ export interface IFileService {
|
||||
onDidChangeFileSystemProviderRegistrations: Event<IFileSystemProviderRegistrationEvent>;
|
||||
|
||||
/**
|
||||
* Registeres a file system provider for a certain scheme.
|
||||
* Registers a file system provider for a certain scheme.
|
||||
*/
|
||||
registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable;
|
||||
|
||||
/**
|
||||
* Tries to activate a provider with the given scheme.
|
||||
*/
|
||||
activateProvider(scheme: string): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Checks if this file service can handle the given resource.
|
||||
*/
|
||||
@@ -67,51 +70,51 @@ export interface IFileService {
|
||||
* the stat service is asked to automatically resolve child folders that only
|
||||
* contain a single element.
|
||||
*/
|
||||
resolveFile(resource: URI, options?: IResolveFileOptions): TPromise<IFileStat>;
|
||||
resolveFile(resource: URI, options?: IResolveFileOptions): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Same as resolveFile but supports resolving mulitple resources in parallel.
|
||||
* Same as resolveFile but supports resolving multiple resources in parallel.
|
||||
* If one of the resolve targets fails to resolve returns a fake IFileStat instead of making the whole call fail.
|
||||
*/
|
||||
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): TPromise<IResolveFileResult[]>;
|
||||
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Thenable<IResolveFileResult[]>;
|
||||
|
||||
/**
|
||||
*Finds out if a file identified by the resource exists.
|
||||
* Finds out if a file identified by the resource exists.
|
||||
*/
|
||||
existsFile(resource: URI): TPromise<boolean>;
|
||||
existsFile(resource: URI): Thenable<boolean>;
|
||||
|
||||
/**
|
||||
* Resolve the contents of a file identified by the resource.
|
||||
*
|
||||
* The returned object contains properties of the file and the full value as string.
|
||||
*/
|
||||
resolveContent(resource: URI, options?: IResolveContentOptions): TPromise<IContent>;
|
||||
resolveContent(resource: URI, options?: IResolveContentOptions): Thenable<IContent>;
|
||||
|
||||
/**
|
||||
* Resolve the contents of a file identified by the resource.
|
||||
*
|
||||
* The returned object contains properties of the file and the value as a readable stream.
|
||||
*/
|
||||
resolveStreamContent(resource: URI, options?: IResolveContentOptions): TPromise<IStreamContent>;
|
||||
resolveStreamContent(resource: URI, options?: IResolveContentOptions): Thenable<IStreamContent>;
|
||||
|
||||
/**
|
||||
* Updates the content replacing its previous value.
|
||||
*/
|
||||
updateContent(resource: URI, value: string | ITextSnapshot, options?: IUpdateContentOptions): TPromise<IFileStat>;
|
||||
updateContent(resource: URI, value: string | ITextSnapshot, options?: IUpdateContentOptions): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Moves the file to a new path identified by the resource.
|
||||
*
|
||||
* The optional parameter overwrite can be set to replace an existing file at the location.
|
||||
*/
|
||||
moveFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat>;
|
||||
moveFile(source: URI, target: URI, overwrite?: boolean): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Copies the file to a path identified by the resource.
|
||||
*
|
||||
* The optional parameter overwrite can be set to replace an existing file at the location.
|
||||
*/
|
||||
copyFile(source: URI, target: URI, overwrite?: boolean): TPromise<IFileStat>;
|
||||
copyFile(source: URI, target: URI, overwrite?: boolean): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Creates a new file with the given path. The returned promise
|
||||
@@ -119,20 +122,26 @@ export interface IFileService {
|
||||
*
|
||||
* The optional parameter content can be used as value to fill into the new file.
|
||||
*/
|
||||
createFile(resource: URI, content?: string, options?: ICreateFileOptions): TPromise<IFileStat>;
|
||||
createFile(resource: URI, content?: string, options?: ICreateFileOptions): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Reads a folder's content with the given path. The returned promise
|
||||
* will have the list of children as a result.
|
||||
*/
|
||||
readFolder(resource: URI): Thenable<string[]>;
|
||||
|
||||
/**
|
||||
* Creates a new folder with the given path. The returned promise
|
||||
* will have the stat model object as a result.
|
||||
*/
|
||||
createFolder(resource: URI): TPromise<IFileStat>;
|
||||
createFolder(resource: URI): Thenable<IFileStat>;
|
||||
|
||||
/**
|
||||
* Deletes the provided file. The optional useTrash parameter allows to
|
||||
* move the file to trash. The optional recursive parameter allows to delete
|
||||
* non-empty folders recursively.
|
||||
*/
|
||||
del(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): TPromise<void>;
|
||||
del(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Allows to start a watcher that reports file change events on the provided resource.
|
||||
@@ -182,7 +191,7 @@ export interface IWatchOptions {
|
||||
excludes: string[];
|
||||
}
|
||||
|
||||
export enum FileSystemProviderCapabilities {
|
||||
export const enum FileSystemProviderCapabilities {
|
||||
FileReadWrite = 1 << 1,
|
||||
FileOpenReadWriteClose = 1 << 2,
|
||||
FileFolderCopy = 1 << 3,
|
||||
@@ -194,25 +203,26 @@ export enum FileSystemProviderCapabilities {
|
||||
export interface IFileSystemProvider {
|
||||
|
||||
readonly capabilities: FileSystemProviderCapabilities;
|
||||
onDidChangeCapabilities: Event<void>;
|
||||
|
||||
onDidChangeFile: Event<IFileChange[]>;
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable;
|
||||
|
||||
stat(resource: URI): TPromise<IStat>;
|
||||
mkdir(resource: URI): TPromise<void>;
|
||||
readdir(resource: URI): TPromise<[string, FileType][]>;
|
||||
delete(resource: URI, opts: FileDeleteOptions): TPromise<void>;
|
||||
stat(resource: URI): Thenable<IStat>;
|
||||
mkdir(resource: URI): Thenable<void>;
|
||||
readdir(resource: URI): Thenable<[string, FileType][]>;
|
||||
delete(resource: URI, opts: FileDeleteOptions): Thenable<void>;
|
||||
|
||||
rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
|
||||
copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
|
||||
rename(from: URI, to: URI, opts: FileOverwriteOptions): Thenable<void>;
|
||||
copy?(from: URI, to: URI, opts: FileOverwriteOptions): Thenable<void>;
|
||||
|
||||
readFile?(resource: URI): TPromise<Uint8Array>;
|
||||
writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): TPromise<void>;
|
||||
readFile?(resource: URI): Thenable<Uint8Array>;
|
||||
writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): Thenable<void>;
|
||||
|
||||
open?(resource: URI): TPromise<number>;
|
||||
close?(fd: number): TPromise<void>;
|
||||
read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): TPromise<number>;
|
||||
write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): TPromise<number>;
|
||||
open?(resource: URI): Thenable<number>;
|
||||
close?(fd: number): Thenable<void>;
|
||||
read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Thenable<number>;
|
||||
write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Thenable<number>;
|
||||
}
|
||||
|
||||
export interface IFileSystemProviderRegistrationEvent {
|
||||
@@ -221,7 +231,7 @@ export interface IFileSystemProviderRegistrationEvent {
|
||||
provider?: IFileSystemProvider;
|
||||
}
|
||||
|
||||
export enum FileOperation {
|
||||
export const enum FileOperation {
|
||||
CREATE,
|
||||
DELETE,
|
||||
MOVE,
|
||||
@@ -237,7 +247,7 @@ export class FileOperationEvent {
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
get target(): IFileStat {
|
||||
get target(): IFileStat | undefined {
|
||||
return this._target;
|
||||
}
|
||||
|
||||
@@ -249,7 +259,7 @@ export class FileOperationEvent {
|
||||
/**
|
||||
* Possible changes that can occur to a file.
|
||||
*/
|
||||
export enum FileChangeType {
|
||||
export const enum FileChangeType {
|
||||
UPDATED = 0,
|
||||
ADDED = 1,
|
||||
DELETED = 2
|
||||
@@ -284,22 +294,24 @@ export class FileChangesEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this change event contains the provided file with the given change type. In case of
|
||||
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
|
||||
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
|
||||
* provided file path.
|
||||
*/
|
||||
contains(resource: URI, type: FileChangeType): boolean {
|
||||
contains(resource: URI, type?: FileChangeType): boolean {
|
||||
if (!resource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const checkForChangeType = !isUndefinedOrNull(type);
|
||||
|
||||
return this._changes.some(change => {
|
||||
if (change.type !== type) {
|
||||
if (checkForChangeType && change.type !== type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For deleted also return true when deleted folder is parent of target path
|
||||
if (type === FileChangeType.DELETED) {
|
||||
if (change.type === FileChangeType.DELETED) {
|
||||
return isEqualOrParent(resource, change.resource, !isLinux /* ignorecase */);
|
||||
}
|
||||
|
||||
@@ -483,12 +495,15 @@ export interface IStringStream {
|
||||
* Will return null when finished.
|
||||
*/
|
||||
export interface ITextSnapshot {
|
||||
read(): string;
|
||||
read(): string | null;
|
||||
}
|
||||
|
||||
export class StringSnapshot implements ITextSnapshot {
|
||||
constructor(private _value: string) { }
|
||||
read(): string {
|
||||
private _value: string | null;
|
||||
constructor(value: string) {
|
||||
this._value = value;
|
||||
}
|
||||
read(): string | null {
|
||||
let ret = this._value;
|
||||
this._value = null;
|
||||
return ret;
|
||||
@@ -499,7 +514,7 @@ export class StringSnapshot implements ITextSnapshot {
|
||||
*/
|
||||
export function snapshotToString(snapshot: ITextSnapshot): string {
|
||||
const chunks: string[] = [];
|
||||
let chunk: string;
|
||||
let chunk: string | null;
|
||||
while (typeof (chunk = snapshot.read()) === 'string') {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
@@ -620,7 +635,7 @@ export class FileOperationError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export enum FileOperationResult {
|
||||
export const enum FileOperationResult {
|
||||
FILE_IS_BINARY,
|
||||
FILE_IS_DIRECTORY,
|
||||
FILE_NOT_FOUND,
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { join, isEqual, isEqualOrParent } from 'vs/base/common/paths';
|
||||
import { FileChangeType, FileChangesEvent, isParent } from 'vs/platform/files/common/files';
|
||||
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
@@ -17,7 +15,7 @@ suite('Files', () => {
|
||||
return URI.file(join('C:\\', path));
|
||||
}
|
||||
|
||||
test('FileChangesEvent', function () {
|
||||
test('FileChangesEvent', () => {
|
||||
let changes = [
|
||||
{ resource: URI.file(join('C:\\', '/foo/updated.txt')), type: FileChangeType.UPDATED },
|
||||
{ resource: URI.file(join('C:\\', '/foo/otherupdated.txt')), type: FileChangeType.UPDATED },
|
||||
|
||||
Reference in New Issue
Block a user