Skip to content

Commit

Permalink
[linked editing] finalize LinkedEditingRangeProvider. Fixes #109923
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Dec 1, 2020
1 parent ec2bcdb commit 20bf09b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 58 deletions.
52 changes: 52 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,44 @@ declare module 'vscode' {
provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>;
}

/**
* Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents.
*/
export class LinkedEditingRanges {
constructor(ranges: Range[], wordPattern?: RegExp);

/**
* A list of ranges that can be edited together. The ranges must have
* identical length and text content. The ranges cannot overlap.
*/
readonly ranges: Range[];

/**
* An optional word pattern that describes valid contents for the given ranges.
* If no pattern is provided, the language configuration's word pattern will be used.
*/
readonly wordPattern?: RegExp;
}

/**
* The linked editing range provider interface defines the contract between extensions and
* the linked editing feature.
*/
export interface LinkedEditingRangeProvider {
/**
* For a given position in a document, returns the range of the symbol at the position and all ranges
* that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
* is valid. An optional word pattern can be returned with the result to describe valid contents.
* If no result-specific word pattern is provided, the word pattern from the language configuration is used.
*
* @param document The document in which the provider was invoked.
* @param position The position at which the provider was invoked.
* @param token A cancellation token.
* @return A list of ranges that can be edited together
*/
provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
}

/**
* A tuple of two characters, like a pair of
* opening and closing brackets.
Expand Down Expand Up @@ -10842,6 +10880,19 @@ declare module 'vscode' {
*/
export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable;

/**
* Register a linked editing range provider.
*
* Multiple providers can be registered for a language. In that case providers are sorted
* by their [score](#languages.match) and the best-matching provider that has a result 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 linked editing range provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;

/**
* Set a [language configuration](#LanguageConfiguration) for a language.
*
Expand All @@ -10850,6 +10901,7 @@ declare module 'vscode' {
* @return A [disposable](#Disposable) that unsets this configuration.
*/
export function setLanguageConfiguration(language: string, configuration: LanguageConfiguration): Disposable;

}

/**
Expand Down
57 changes: 0 additions & 57 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,63 +983,6 @@ declare module 'vscode' {

//#endregion

//#region LinkedEditing: https://github.com/microsoft/vscode/issues/109923 @aeschli

/**
* The linked editing range provider interface defines the contract between extensions and
* the linked editing feature.
*/
export interface LinkedEditingRangeProvider {
/**
* For a given position in a document, returns the range of the symbol at the position and all ranges
* that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
* is valid. An optional word pattern can be returned with the result to describe valid contents.
* If no result-specific word pattern is provided, the word pattern from the language configuration is used.
*
* @param document The document in which the provider was invoked.
* @param position The position at which the provider was invoked.
* @param token A cancellation token.
* @return A list of ranges that can be edited together
*/
provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
}

namespace languages {
/**
* Register a linked editing range provider.
*
* Multiple providers can be registered for a language. In that case providers are sorted
* by their [score](#languages.match) and the best-matching provider that has a result 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 linked editing range provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;
}

/**
* Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents.
*/
export class LinkedEditingRanges {
constructor(ranges: Range[], wordPattern?: RegExp);

/**
* A list of ranges that can be edited together. The ranges must have
* identical length and text content. The ranges cannot overlap.
*/
readonly ranges: Range[];

/**
* An optional word pattern that describes valid contents for the given ranges.
* If no pattern is provided, the language configuration's word pattern will be used.
*/
readonly wordPattern?: RegExp;
}

//#endregion

//#region Custom editor move https://github.com/microsoft/vscode/issues/86146

// TODO: Also for custom editor
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostLanguageFeatures.registerDocumentHighlightProvider(extension, checkSelector(selector), provider);
},
registerLinkedEditingRangeProvider(selector: vscode.DocumentSelector, provider: vscode.LinkedEditingRangeProvider): vscode.Disposable {
checkProposedApiEnabled(extension);
return extHostLanguageFeatures.registerLinkedEditingRangeProvider(extension, checkSelector(selector), provider);
},
registerReferenceProvider(selector: vscode.DocumentSelector, provider: vscode.ReferenceProvider): vscode.Disposable {
Expand Down

0 comments on commit 20bf09b

Please sign in to comment.