Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative approach to search API - less reliance on inheritance #220010

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/vscode-dts/vscode.proposed.fileSearchProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,68 @@ declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/73524

/**
* Options unique to finding files to target
*/
export interface FileTargetOptions {
/**
* The root folder to search within.
*/
folder: Uri;

/**
* Files that match an `includes` glob pattern should be included in the search.
*/
includes: string[];

/**
* Files that match an `excludes` glob pattern should be excluded from the search.
*/
excludes: GlobPattern[];

/**
* Whether symlinks should be followed while searching.
* See the vscode setting `"search.followSymlinks"` for more information.
*/
followSymlinks: boolean;

/**
* Which file locations we should look for ignore (.gitignore or .ignore) files to respect.
* Any time that `parent` or `global` is set to `true`, `local` will also be `true`.
*/
useIgnoreFiles: {
/**
* Use ignore files at the current workspace root.
*/
local: boolean;
/**
* Use ignore files at the parent directory.
*/
parent: boolean;
/**
* Use global ignore files.
*/
global: boolean;
};
}

/**
* Options that apply to file search.
*/
export interface FileSearchOptions extends SearchProviderOptions {
export interface FileSearchOptions {
/**
* Options for choosing which files to include in the search
*/
fileTargetOptions: FileTargetOptions;
/**
* A CancellationToken that represents the session for this search query. If the provider chooses to, this object can be used as the key for a cache,
* and searches with the same session object can search the same cache. When the token is cancelled, the session is complete and the cache can be cleared.
*/
session: CancellationToken;
/**
* The maximum number of results to be returned.
*/
maxResults: number;
}

/**
Expand All @@ -32,9 +85,11 @@ declare module 'vscode' {
* Provide the set of files that match a certain file path pattern.
* @param pattern The search pattern to match against file paths.
* @param options A set of options to consider while searching files.
* @param session A CancellationToken that represents the session for this search query. If the provider chooses to, this object can be used as the key for a cache,
* and searches with the same session object can search the same cache. When the token is cancelled, the session is complete and the cache can be cleared.
* @param token A cancellation token.
*/
provideFileSearchResults(pattern: string, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
provideFileSearchResults(pattern: string, options: FileSearchOptions, session: CancellationToken, token: CancellationToken): ProviderResult<Uri[]>;
}

export namespace workspace {
Expand Down
21 changes: 13 additions & 8 deletions src/vscode-dts/vscode.proposed.findFiles2.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

declare module 'vscode' {

export interface FindFiles2Options {
// note: this is just FindTextInFilesOptions without select properties (include, previewOptions, beforeContext, afterContext)

export interface FindFilesTargetOptions {
/**
* A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
* will be matched against the file paths of resulting matches relative to their workspace.
Expand All @@ -19,11 +17,6 @@ declare module 'vscode' {
*/
useExcludeSettings?: ExcludeSettingOptions;

/**
* The maximum number of results to search for
*/
maxResults?: number;

/**
* Which file locations we should look for ignore (.gitignore or .ignore) files to respect.
* When `undefined`, we will follow settings (or assume the value if only one is valid) using the value for the corresponding `search.use*IgnoreFiles` settting.
Expand Down Expand Up @@ -53,6 +46,18 @@ declare module 'vscode' {
followSymlinks?: boolean;
}

export interface FindFiles2Options {
/**
* options that dictate which files to target
*/
fileTargetOptions?: FindFilesTargetOptions;

/**
* The maximum number of results to search for
*/
maxResults?: number;
}

/*
* Options for following search.exclude and files.exclude settings.
*/
Expand Down
43 changes: 31 additions & 12 deletions src/vscode-dts/vscode.proposed.findTextInFiles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,59 @@ declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/59924

/**
* Options that can be set on a findTextInFiles search.
*/
export interface FindTextInFilesOptions extends FindFiles2Options {
export interface FindTextInFilesTargetOptions extends FindFilesTargetOptions {

/**
* A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
* will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern}
* to restrict the search results to a {@link WorkspaceFolder workspace folder}.
*/
include?: GlobPattern;
}

/**
* Options that can be set on a findTextInFiles search.
*/
export interface FindTextInFilesOptions {
/**
* Interpret files using this encoding.
* See the vscode setting `"files.encoding"`
* options that dictate which files to target
*/
encoding?: string;
fileTargetOptions?: FindTextInFilesTargetOptions;

/**
* Options to specify the size of the result text preview.
* Options that dictate how the search query is presented
*/
previewOptions?: TextSearchPreviewOptions;
presentationOptions?: {
/**
* Options to specify the size of the result text preview.
*/
previewOptions?: TextSearchPreviewOptions;

/**
* Number of lines of context to include before and after each match.
*/
surroundingContext?: number;
};

/**
* Number of lines of context to include before and after each match.
* The maximum number of results to search for
*/
surroundingContext?: number;
maxResults?: number;

/**
* Interpret files using this encoding.
* See the vscode setting `"files.encoding"`
*/
encoding?: string;

}

export namespace workspace {
/**
* Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
* @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
* @param options An optional set of query options. Include and exclude patterns, maxResults, etc.
* @param callback A callback, called for each result
* @param options A set of query options.
* @param token A token that can be used to signal cancellation to the underlying search engine.
* @return A thenable that resolves when the search is complete.
*/
Expand Down
80 changes: 23 additions & 57 deletions src/vscode-dts/vscode.proposed.textSearchProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,11 @@ declare module 'vscode' {
isWordMatch?: boolean;
}

/**
* Options common to file and text search
*/
export interface SearchProviderOptions {
/**
* The root folder to search within.
*/
folder: Uri;

/**
* Files that match an `includes` glob pattern should be included in the search.
*/
includes: string[];

/**
* Files that match an `excludes` glob pattern should be excluded from the search.
*/
excludes: GlobPattern[];

export interface TextSearchProviderFileTargetOptions extends FileTargetOptions {
/**
* Whether symlinks should be followed while searching.
* See the vscode setting `"search.followSymlinks"` for more information.
* exclude files larger than `maxFileSize` in bytes.
*/
followSymlinks: boolean;

/**
* Which file locations we should look for ignore (.gitignore or .ignore) files to respect.
* Any time that `parent` or `global` is set to `true`, `local` will also be `true`.
*/
useIgnoreFiles: {
/**
* Use ignore files at the current workspace root.
*/
local: boolean;
/**
* Use ignore files at the parent directory.
*/
parent: boolean;
/**
* Use global ignore files.
*/
global: boolean;
};

/**
* The maximum number of results to be returned.
*/
maxResults: number;
maxFileSize: number;
}

/**
Expand All @@ -107,28 +64,37 @@ declare module 'vscode' {
/**
* Options that apply to text search.
*/
export interface TextSearchProviderOptions extends SearchProviderOptions {
export interface TextSearchProviderOptions {
/**
* Options for choosing which files to include in the search
*/
fileTargetOptions: TextSearchProviderFileTargetOptions;

/**
* Options to specify the size of the result text preview.
* Options that dictate how the search query is presented
*/
previewOptions: TextSearchPreviewOptions;
presentationOptions: {
/**
* Options to specify the size of the result text preview.
*/
previewOptions: TextSearchPreviewOptions;

/**
* Number of lines of context to include before and after each match.
*/
surroundingContext: number;
};

/**
* Exclude files larger than `maxFileSize` in bytes.
* The maximum number of results to be returned.
*/
maxFileSize: number;
maxResults: number;

/**
* Interpret files using this encoding.
* See the vscode setting `"files.encoding"`
*/
encoding: string;

/**
* Number of lines of context to include before and after each match.
*/
surroundingContext: number;
}

/**
Expand Down Expand Up @@ -241,7 +207,7 @@ declare module 'vscode' {
* @param progress A progress callback that must be invoked for all results.
* @param token A cancellation token.
*/
provideTextSearchResults(query: TextSearchQuery, options: TextSearchProviderOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
provideTextSearchResults(query: TextSearchQuery, Options: TextSearchProviderOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
}

export namespace workspace {
Expand Down
Loading