diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index d0cb01f2976..f65b17c31b0 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -9,7 +9,7 @@ import { Event } from 'vs/base/common/event'; import { IMarkdownString } from 'vs/base/common/htmlContent'; import { IDisposable } from 'vs/base/common/lifecycle'; import { URI, UriComponents } from 'vs/base/common/uri'; -import { IPosition, Position } from 'vs/editor/common/core/position'; +import { Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token'; @@ -1661,7 +1661,7 @@ export interface CodeLensProvider { export interface InlineHint { text: string; - position: IPosition; + range: IRange; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } diff --git a/src/vs/editor/contrib/inlineHints/inlineHintsController.ts b/src/vs/editor/contrib/inlineHints/inlineHintsController.ts index 67bd5470c46..1fcc1c2d625 100644 --- a/src/vs/editor/contrib/inlineHints/inlineHintsController.ts +++ b/src/vs/editor/contrib/inlineHints/inlineHintsController.ts @@ -16,7 +16,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { InlineHintsProvider, InlineHintsProviderRegistry, InlineHint } from 'vs/editor/common/modes'; import { EditorOption } from 'vs/editor/common/config/editorOptions'; import { flatten } from 'vs/base/common/arrays'; -import { inlineHintForeground, inlineHintBackground } from 'vs/platform/theme/common/colorRegistry'; +import { editorInlineHintForeground, editorInlineHintBackground } from 'vs/platform/theme/common/colorRegistry'; import { CancellationToken } from 'vs/base/common/cancellation'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Range } from 'vs/editor/common/core/range'; @@ -154,10 +154,10 @@ export class InlineHintsDetector extends Disposable implements IEditorContributi const decorations = flatten(hintsData.map(hints => hints.list.map(hint => { return { range: { - startLineNumber: hint.position.lineNumber, - startColumn: hint.position.column, - endLineNumber: hint.position.lineNumber, - endColumn: hint.position.column + startLineNumber: hint.range.startLineNumber, + startColumn: hint.range.startColumn, + endLineNumber: hint.range.endLineNumber, + endColumn: hint.range.endColumn }, options: ModelDecorationOptions.EMPTY }; @@ -173,13 +173,13 @@ export class InlineHintsDetector extends Disposable implements IEditorContributi let decorations: IModelDeltaDecoration[] = []; let newDecorationsTypes: { [key: string]: boolean } = {}; const { fontSize, fontFamily } = this._getLayoutInfo(); - const backgroundColor = this._themeService.getColorTheme().getColor(inlineHintBackground); - const fontColor = this._themeService.getColorTheme().getColor(inlineHintForeground); + const backgroundColor = this._themeService.getColorTheme().getColor(editorInlineHintBackground); + const fontColor = this._themeService.getColorTheme().getColor(editorInlineHintForeground); for (let i = 0; i < hintsData.length; i++) { const hint = hintsData[i].list; for (let j = 0; j < hint.length && decorations.length < MAX_DECORATORS; j++) { - const { text, position, whitespaceBefore, whitespaceAfter } = hint[j]; + const { text, range, whitespaceBefore, whitespaceAfter } = hint[j]; const marginBefore = whitespaceBefore ? fontSize / 3 : 0; const marginAfter = whitespaceAfter ? fontSize / 3 : 0; @@ -203,10 +203,10 @@ export class InlineHintsDetector extends Disposable implements IEditorContributi newDecorationsTypes[key] = true; decorations.push({ range: { - startLineNumber: position.lineNumber, - startColumn: position.column, - endLineNumber: position.lineNumber, - endColumn: position.column + startLineNumber: range.startLineNumber, + startColumn: range.startColumn, + endLineNumber: range.endLineNumber, + endColumn: range.endColumn }, options: this._codeEditorService.resolveDecorationOptions(key, true) }); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 09863393a31..aae108b813c 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -6405,7 +6405,7 @@ declare namespace monaco.languages { export interface InlineHint { text: string; - position: IPosition; + range: IRange; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } diff --git a/src/vs/platform/theme/common/colorRegistry.ts b/src/vs/platform/theme/common/colorRegistry.ts index 219bec51d2b..df2c3894198 100644 --- a/src/vs/platform/theme/common/colorRegistry.ts +++ b/src/vs/platform/theme/common/colorRegistry.ts @@ -260,8 +260,8 @@ export const editorHintBorder = registerColor('editorHint.border', { dark: null, export const sashHoverBorder = registerColor('sash.hoverBorder', { dark: null, light: null, hc: null }, nls.localize('sashActiveBorder', "Border color of active sashes.")); -export const inlineHintForeground = registerColor('inlineHint.foreground', { dark: '#A7A6A5', light: '#A7A6A5', hc: null }, nls.localize('inlineHintForeground', 'Foreground color of inline hints')); -export const inlineHintBackground = registerColor('inlineHint.background', { dark: '#3A3A3A', light: '#3A3A3A', hc: null }, nls.localize('inlineHintBackground', 'Background color of inline hints')); +export const editorInlineHintForeground = registerColor('editorInlineHint.foreground', { dark: '#A7A6A5', light: '#A7A6A5', hc: null }, nls.localize('editorInlineHintForeground', 'Foreground color of inline hints')); +export const editorInlineHintBackground = registerColor('editorInlineHint.background', { dark: '#3A3A3A', light: '#3A3A3A', hc: null }, nls.localize('editorInlineHintBackground', 'Background color of inline hints')); /** * Editor background color. * Because of bug https://monacotools.visualstudio.com/DefaultCollection/Monaco/_workitems/edit/13254 diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index e365a95fb96..5e8463ccb5d 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1952,6 +1952,13 @@ declare module 'vscode' { export namespace languages { export function getTokenInformationAtPosition(document: TextDocument, position: Position): Promise; + } + + //#endregion + + //@region https://github.com/microsoft/vscode/issues/16221 + + export namespace languages { /** * Register a inline hints provider. * @@ -1966,6 +1973,66 @@ declare module 'vscode' { export function registerInlineHintsProvider(selector: DocumentSelector, provider: InlineHintsProvider): Disposable; } + export interface ThemableDecorationAttachmentRenderOptions { + /** + * CSS styling property that will be applied to the decoration attachment. + */ + fontSize?: string; + /** + * CSS styling property that will be applied to the decoration attachment. + */ + fontFamily?: string; + /** + * CSS styling property that will be applied to the decoration attachment. + */ + padding?: string; + } + + /** + * Inline hint information. + */ + export class InlineHint { + /** + * The text of the hint. + */ + text: string; + /** + * The position of the hint. + */ + range: Range; + /** + * Whitespace before the hint. + */ + whitespaceBefore?: boolean; + /** + * Whitespace after the hint. + */ + whitespaceAfter?: boolean; + + /** + * Creates a new inline hint information object. + * + * @param text The text of the hint. + * @param range The range of the hint. + * @param whitespaceBefore Whitespace before the hint. + * @param whitespaceAfter TWhitespace after the hint. + */ + constructor(text: string, range: Range, whitespaceBefore?: boolean, whitespaceAfter?: boolean); + } + + /** + * The document formatting provider interface defines the contract between extensions and + * the inline hints feature. + */ + export interface InlineHintsProvider { + /** + * @param model The document in which the command was invoked. + * @param token A cancellation token. + * + * @return A list of arguments labels or a thenable that resolves to such. + */ + provideInlineHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult; + } //#endregion //#region https://github.com/microsoft/vscode/issues/104436 @@ -2371,67 +2438,6 @@ declare module 'vscode' { //#endregion - export interface ThemableDecorationAttachmentRenderOptions { - /** - * CSS styling property that will be applied to the decoration attachment. - */ - fontSize?: string; - /** - * CSS styling property that will be applied to the decoration attachment. - */ - fontFamily?: string; - /** - * CSS styling property that will be applied to the decoration attachment. - */ - padding?: string; - } - - /** - * Inline hint information. - */ - export class InlineHint { - /** - * The text of the hint. - */ - text: string; - /** - * The position of the hint. - */ - position: Position; - /** - * Whitespace before the hint. - */ - whitespaceBefore?: boolean; - /** - * Whitespace after the hint. - */ - whitespaceAfter?: boolean; - - /** - * Creates a new inline hint information object. - * - * @param text The text of the parameter. - * @param position The position of the argument. - * @param whitespaceBefore Whitespace before the hint. - * @param whitespaceAfter TWhitespace after the hint. - */ - constructor(text: string, position: Position, whitespaceBefore?: boolean, whitespaceAfter?: boolean); - } - - /** - * The document formatting provider interface defines the contract between extensions and - * the inline hints feature. - */ - export interface InlineHintsProvider { - /** - * @param model The document in which the command was invoked. - * @param token A cancellation token. - * - * @return A list of arguments labels or a thenable that resolves to such. - */ - provideInlineHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult; - } - /** * Represents a storage utility for secrets, information that is * sensitive. diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index f08cced1942..b0144d0f781 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1288,7 +1288,7 @@ export interface ISignatureHelpContextDto { export interface IInlineHintDto { text: string - position: IPosition + range: IRange } export interface IInlineHintsDto { diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index 861a010f412..3fe5e063c0d 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -1776,12 +1776,6 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF return this._createDisposable(handle); } - registerInlineHintsProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.InlineHintsProvider): vscode.Disposable { - const handle = this._addNewAdapter(new InlineHintsAdapter(this._documents, provider), extension); - this._proxy.$registerInlineHintsProvider(handle, this._transformDocumentSelector(selector)); - return this._createDisposable(handle); - } - $provideSignatureHelp(handle: number, resource: UriComponents, position: IPosition, context: extHostProtocol.ISignatureHelpContextDto, token: CancellationToken): Promise { return this._withAdapter(handle, SignatureHelpAdapter, adapter => adapter.provideSignatureHelp(URI.revive(resource), position, context, token), undefined); } @@ -1792,6 +1786,12 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF // --- inline hints + registerInlineHintsProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.InlineHintsProvider): vscode.Disposable { + const handle = this._addNewAdapter(new InlineHintsAdapter(this._documents, provider), extension); + this._proxy.$registerInlineHintsProvider(handle, this._transformDocumentSelector(selector)); + return this._createDisposable(handle); + } + $provideInlineHints(handle: number, resource: UriComponents, range: IRange, token: CancellationToken): Promise { return this._withAdapter(handle, InlineHintsAdapter, adapter => adapter.provideInlineHints(URI.revive(resource), range, token), undefined); } diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index dec42ed93e3..e0d50f643bf 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -1023,7 +1023,7 @@ export namespace InlineHint { export function from(hint: vscode.InlineHint): modes.InlineHint { return { text: hint.text, - position: Position.from(hint.position), + range: Range.from(hint.range), whitespaceBefore: hint.whitespaceBefore, whitespaceAfter: hint.whitespaceAfter }; @@ -1032,7 +1032,7 @@ export namespace InlineHint { export function to(hint: modes.InlineHint): vscode.InlineHint { return { text: hint.text, - position: Position.to(hint.position), + range: Range.to(hint.range), whitespaceBefore: hint.whitespaceBefore, whitespaceAfter: hint.whitespaceAfter }; diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 7c8cff3d68d..4e8fe79acfd 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1376,13 +1376,13 @@ export enum SignatureHelpTriggerKind { @es5ClassCompat export class InlineHint { text: string; - position: Position; + range: Range; whitespaceBefore?: boolean; whitespaceAfter?: boolean; - constructor(text: string, position: Position, whitespaceBefore?: boolean, whitespaceAfter?: boolean) { + constructor(text: string, range: Range, whitespaceBefore?: boolean, whitespaceAfter?: boolean) { this.text = text; - this.position = position; + this.range = range; this.whitespaceBefore = whitespaceBefore; this.whitespaceAfter = whitespaceAfter; }