From ee95924f96e10bcf01478064bc9e0884a08cab78 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 19 Apr 2018 11:39:49 +0200 Subject: [PATCH] update to latest, proposed api --- fsprovider-sample/src/fileSystemProvider.ts | 6 +- fsprovider-sample/src/vscode.proposed.d.ts | 119 ++------------------ 2 files changed, 11 insertions(+), 114 deletions(-) diff --git a/fsprovider-sample/src/fileSystemProvider.ts b/fsprovider-sample/src/fileSystemProvider.ts index cf6b6080..812cf835 100644 --- a/fsprovider-sample/src/fileSystemProvider.ts +++ b/fsprovider-sample/src/fileSystemProvider.ts @@ -115,7 +115,7 @@ export class MemFS implements vscode.FileSystemProvider2 { let basename = path.posix.basename(uri.path); let parent = this._lookupDir(dirname); if (!parent.entries.has(basename)) { - throw new Error(); + throw vscode.FileError.EntryNotFound(); } parent.entries.delete(basename); parent.mtime = Date.now(); @@ -150,7 +150,7 @@ export class MemFS implements vscode.FileSystemProvider2 { child = entry.entries.get(part); } if (!child) { - throw new Error(); + throw vscode.FileError.EntryNotFound(); } entry = child; } @@ -160,7 +160,7 @@ export class MemFS implements vscode.FileSystemProvider2 { private _lookupDir(uri: vscode.Uri): Directory { let entry = this._lookup(uri); if (!(entry instanceof Directory)) { - throw new Error(); + throw vscode.FileError.EntryNotADirectory(); } return entry; } diff --git a/fsprovider-sample/src/vscode.proposed.d.ts b/fsprovider-sample/src/vscode.proposed.d.ts index 704e11b1..e6ddc081 100644 --- a/fsprovider-sample/src/vscode.proposed.d.ts +++ b/fsprovider-sample/src/vscode.proposed.d.ts @@ -11,94 +11,6 @@ declare module 'vscode' { export function sampleFunction(): Thenable; } - //#region Aeschli: folding - - export class FoldingRangeList { - - /** - * The folding ranges. - */ - ranges: FoldingRange[]; - - /** - * Creates new folding range list. - * - * @param ranges The folding ranges - */ - constructor(ranges: FoldingRange[]); - } - - - export class FoldingRange { - - /** - * The start line number (zero-based) of the range to fold. The hidden area starts after the last character of that line. - */ - startLine: number; - - /** - * The end line number (0-based) of the range to fold. The hidden area ends at the last character of that line. - */ - endLine: number; - - /** - * The actual color value for this color range. - */ - type?: FoldingRangeType | string; - - /** - * Creates a new folding range. - * - * @param startLineNumber The first line of the fold - * @param type The last line of the fold - */ - constructor(startLineNumber: number, endLineNumber: number, type?: FoldingRangeType | string); - } - - export enum FoldingRangeType { - /** - * Folding range for a comment - */ - Comment = 'comment', - /** - * Folding range for a imports or includes - */ - Imports = 'imports', - /** - * Folding range for a region (e.g. `#region`) - */ - Region = 'region' - } - - export namespace languages { - - /** - * Register a folding provider. - * - * Multiple folding can be registered for a language. In that case providers are sorted - * by their [score](#languages.match) and the best-matching provider is used. Failure - * of the selected provider will cause a failure of the whole operation. - * - * @param selector A selector that defines the documents this provider is applicable to. - * @param provider A folding provider. - * @return A [disposable](#Disposable) that unregisters this provider when being disposed. - */ - export function registerFoldingProvider(selector: DocumentSelector, provider: FoldingProvider): Disposable; - } - - export interface FoldingContext { - maxRanges?: number; - } - - export interface FoldingProvider { - /** - * Returns a list of folding ranges or null if the provider does not want to participate or was cancelled. - */ - provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult; - } - - //#endregion - //#region Joh: file system provider export enum FileChangeType { @@ -172,32 +84,17 @@ declare module 'vscode' { // create(resource: Uri): Thenable; } - // export class FileError extends Error { + export class FileError extends Error { - // /** - // * Entry already exists, e.g. when creating a file or folder. - // */ - // static readonly EntryExists: FileError; + static EntryExists(message?: string): FileError; + static EntryNotFound(message?: string): FileError; + static EntryNotADirectory(message?: string): FileError; + static EntryIsADirectory(message?: string): FileError; - // /** - // * Entry does not exist. - // */ - // static readonly EntryNotFound: FileError; + readonly code: string; - // /** - // * Entry is not a directory. - // */ - // static readonly EntryNotADirectory: FileError; - - // /** - // * Entry is a directory. - // */ - // static readonly EntryIsADirectory: FileError; - - // readonly code: string; - - // constructor(code: string, message?: string); - // } + constructor(message?: string, code?: string); + } export enum FileChangeType2 { Changed = 1,