import { URI } from '../model/uri'; import { Event } from '../common/event'; /** * Represents a source of files and content */ export interface IDataStore { /** * List the URIs known to this store. * * With no argument, returns the full set of URIs the store can see (the * usual workspace enumeration). * * When a workspace-relative glob `pattern` is passed, the store **must** * return only URIs matching that glob. */ list: (pattern?: string) => Promise; /** * Read the content of the file from the store * * Returns `null` in case of errors while reading */ read: (uri: URI) => Promise; /** * Write content to the file. Creates parent directories as needed. * Overwrites existing files. */ write: (uri: URI, content: string) => Promise; /** * Delete the file at the given URI. No-op if it doesn't exist. */ delete: (uri: URI) => Promise; /** * Move (rename) a file from one URI to another. Creates destination * parent directories as needed. Atomic where the underlying filesystem * supports it. */ move: (from: URI, to: URI) => Promise; /** * Returns true if the file exists at the given URI. */ exists: (uri: URI) => Promise; } export interface IWatcher { onDidChange: Event; onDidCreate: Event; onDidDelete: Event; } export interface IMatcher { /** * Filters the given list of URIs, keepin only the ones that * are matched by this Matcher * * @param files the URIs to check */ match(files: URI[]): URI[]; /** * Returns whether this URI is matched by this Matcher * * @param uri the URI to check */ isMatch(uri: URI): boolean; /** * Refreshes the list of files that this matcher matches * To be used when new files are added to the workspace, * it can be a more or less expensive operation depending on the * implementation of the matcher */ refresh(): Promise; /** * The include globs */ include: string[]; /** * The exclude lobs */ exclude: string[]; } export declare class GenericDataStore implements IDataStore { private readonly listFiles; private readFile; private readonly writeFile?; private readonly deleteFile?; private readonly moveFile?; private readonly fileExists?; constructor(listFiles: (pattern?: string) => Promise, readFile: (uri: URI) => Promise, writeFile?: (uri: URI, content: string) => Promise, deleteFile?: (uri: URI) => Promise, moveFile?: (from: URI, to: URI) => Promise, fileExists?: (uri: URI) => Promise); list(pattern?: string): Promise; read(uri: URI): Promise; write(uri: URI, content: string): Promise; delete(uri: URI): Promise; move(from: URI, to: URI): Promise; exists(uri: URI): Promise; } /** * A matcher that instead of using globs uses a list of files to * check the matches. * The {@link refresh} function has been added to the interface to accommodate * this matcher, far from ideal but to be refactored later */ export declare class FileListBasedMatcher implements IMatcher { private readonly listFiles; private files; include: string[]; exclude: string[]; constructor(files: URI[], listFiles: () => Promise, include?: string[], exclude?: string[]); match(files: URI[]): URI[]; isMatch(uri: URI): boolean; refresh(): Promise; static createFromListFn(listFiles: () => Promise, include?: string[], exclude?: string[]): Promise; } /** * A matcher that includes all URIs passed to it */ export declare class AlwaysIncludeMatcher implements IMatcher { include: string[]; exclude: string[]; match(files: URI[]): URI[]; isMatch(uri: URI): boolean; refresh(): Promise; } export declare class SubstringExcludeMatcher implements IMatcher { include: string[]; exclude: string[]; constructor(exclude: string); match(files: URI[]): URI[]; isMatch(uri: URI): boolean; refresh(): Promise; } //# sourceMappingURL=datastore.d.ts.map