Skip to content

Commit

Permalink
a bit more jsdoc, #47475
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Apr 23, 2018
1 parent d2c4286 commit 2bf2546
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
46 changes: 39 additions & 7 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,44 @@ declare module 'vscode' {
//#region Joh: file system provider (new)

/**
* A type that filesystem providers should use to signal errors.
*
* This class has factory methods for common error-cases, like `EntryNotFound` when
* a file or folder doesn't exist. Use them like so `throw vscode.FileSystemError.EntryNotFound(uri);`
*/
export class FileSystemError extends Error {

static EntryExists(message?: string): FileSystemError;
static EntryNotFound(message?: string): FileSystemError;
static EntryNotADirectory(message?: string): FileSystemError;
static EntryIsADirectory(message?: string): FileSystemError;
/**
* Create an error to signal that a file or folder wasn't found.
* @param messageOrUri Message or uri.
*/
static EntryNotFound(messageOrUri?: string | Uri): FileSystemError;

/**
* Create an error to signal that a file or folder already exists, e.g. when
* creating but not overwriting a file.
* @param messageOrUri Message or uri.
*/
static EntryExists(messageOrUri?: string | Uri): FileSystemError;

constructor(message?: string);
/**
* Create an error to signal that a file is not a folder.
* @param messageOrUri Message or uri.
*/
static EntryNotADirectory(messageOrUri?: string | Uri): FileSystemError;

/**
* Create an error to signal that a file is a folder.
* @param messageOrUri Message or uri.
*/
static EntryIsADirectory(messageOrUri?: string | Uri): FileSystemError;

/**
* Creates a new filesystem error.
*
* @param messageOrUri Message or uri.
*/
constructor(messageOrUri?: string | Uri);
}

export enum FileChangeType2 {
Expand All @@ -122,6 +150,10 @@ declare module 'vscode' {
* The event filesystem providers must use to signal a file change.
*/
export interface FileChangeEvent {

/**
*
*/
type: FileChangeType2;

/**
Expand All @@ -131,7 +163,7 @@ declare module 'vscode' {
}

/**
* Metadata about a file.
* The `FileStat`-type represents metadata about a file.
*/
export interface FileStat2 {
/**
Expand Down Expand Up @@ -161,7 +193,7 @@ declare module 'vscode' {
}

/**
*
* Commonly used options when reading, writing, or stat'ing files or folders.
*/
export interface FileOptions {

Expand Down
24 changes: 12 additions & 12 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1834,26 +1834,26 @@ export enum FileType {

export class FileSystemError extends Error {

static EntryExists(message?: string): FileSystemError {
return new FileSystemError(message, 'EntryExists', FileSystemError.EntryExists);
static EntryExists(messageOrUri?: string | URI): FileSystemError {
return new FileSystemError(messageOrUri, 'EntryExists', FileSystemError.EntryExists);
}
static EntryNotFound(message?: string): FileSystemError {
return new FileSystemError(message, 'EntryNotFound', FileSystemError.EntryNotFound);
static EntryNotFound(messageOrUri?: string | URI): FileSystemError {
return new FileSystemError(messageOrUri, 'EntryNotFound', FileSystemError.EntryNotFound);
}
static EntryNotADirectory(message?: string): FileSystemError {
return new FileSystemError(message, 'EntryNotADirectory', FileSystemError.EntryNotADirectory);
static EntryNotADirectory(messageOrUri?: string | URI): FileSystemError {
return new FileSystemError(messageOrUri, 'EntryNotADirectory', FileSystemError.EntryNotADirectory);
}
static EntryIsADirectory(message?: string): FileSystemError {
return new FileSystemError(message, 'EntryIsADirectory', FileSystemError.EntryIsADirectory);
static EntryIsADirectory(messageOrUri?: string | URI): FileSystemError {
return new FileSystemError(messageOrUri, 'EntryIsADirectory', FileSystemError.EntryIsADirectory);
}

constructor(message?: string, code?: string, hide?: Function) {
super(message);
constructor(uriOrMessage?: string | URI, code?: string, terminator?: Function) {
super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage);
this.name = code ? `${code} (FileSystemError)` : `FileSystemError`;

if (typeof Error.captureStackTrace === 'function' && typeof hide === 'function') {
if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') {
// nice stack traces
Error.captureStackTrace(this, hide);
Error.captureStackTrace(this, terminator);
}
}
}
Expand Down

0 comments on commit 2bf2546

Please sign in to comment.