Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8476ff1
WIP
Kingwl Dec 22, 2020
741a568
Avoid generated files
Kingwl Dec 22, 2020
52c1cce
Add controller
Kingwl Dec 22, 2020
434f631
Revert "Avoid generated files"
Kingwl Dec 23, 2020
9f5cfc2
Add dummy support
Kingwl Dec 23, 2020
3de96fd
Simplify code
Kingwl Dec 23, 2020
a6fd2cc
Use utils type converter
Kingwl Dec 24, 2020
bf4e237
Avoid generated file
Kingwl Dec 24, 2020
ff8ae0b
Avoid changes
Kingwl Dec 24, 2020
d24ab0a
Improve comments and code style
Kingwl Dec 24, 2020
1954e93
Adjust hint label styles
Kingwl Dec 24, 2020
2db89c7
rename to inline hints
Kingwl Dec 24, 2020
2697a42
add range WIP
Kingwl Dec 24, 2020
d26dbae
Adjust request schedule
Kingwl Dec 25, 2020
7222b35
Fix cr issues
Kingwl Dec 25, 2020
4b3d54c
Avoid changes
Kingwl Dec 25, 2020
d20f8ed
Add style controls
Kingwl Dec 25, 2020
2b380bf
Support whitespace options
Kingwl Dec 25, 2020
b4789ec
Fix typo
Kingwl Dec 25, 2020
413b5d4
Avoid ts changes
Kingwl Dec 25, 2020
f93a2b6
fix cr issues
Kingwl Jan 4, 2021
4331023
Merge branch 'master' into signaure_arguments_label
Kingwl Jan 11, 2021
73b4dab
Make lint happy
Kingwl Jan 11, 2021
9853c8f
Fix cr issues
Kingwl Jan 13, 2021
9af036b
Fix comments
Kingwl Jan 13, 2021
fcc00b2
Avoid ts changes (#2)
Kingwl Jan 18, 2021
3c2c937
Merge branch 'master' into signaure_arguments_label
Kingwl Jan 18, 2021
ebac10e
Avoid conflict error
Kingwl Jan 18, 2021
1c131cf
Avoid extra fields
Kingwl Jan 18, 2021
756337d
Merge branch 'master' into signaure_arguments_label
jrieken Jan 18, 2021
ae67879
don't propose new API on ThemableDecorationAttachmentRenderOptions
jrieken Jan 18, 2021
0d4bf78
remove hover (should come via decoration) and action/menu (should be …
jrieken Jan 18, 2021
1981776
less state inside InlineHintsController-type, only have one type of d…
jrieken Jan 18, 2021
5087b08
:lipstick:
jrieken Jan 18, 2021
4651f66
simpler decoration type management (rely on internal ref counting)
jrieken Jan 18, 2021
1d3b03b
padding should depend on font size too
jrieken Jan 18, 2021
d65ab8d
use all of context decoration as decoration type key
jrieken Jan 18, 2021
7a93867
clamp font size at editor font size, don't go bigger
jrieken Jan 18, 2021
a40b4e7
add API command `vscode.executeInlineHintProvider` and some end-to-en…
jrieken Jan 18, 2021
30f17c9
Merge branch 'master' into signaure_arguments_label
Kingwl Jan 19, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { DocumentSelector } from '../utils/documentSelector';
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
import { conditionalRegistration, requireSomeCapability } from '../utils/dependentRegistration';
import { Position } from '../utils/typeConverters';

class TypeScriptSginatureArgumentsLabelProvider implements vscode.SignatureArgumentsLabelProvider {
constructor(
private readonly client: ITypeScriptServiceClient
) { }

async provideSignatureArgumentsLabels(model: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.SignautreArgumentsLabel[]> {
const filepath = this.client.toOpenedFilePath(model);
if (!filepath) {
return [];
}

try {
const response = await this.client.execute('provideSignatureArgumentsLabel', { file: filepath }, token);
if (response.type !== 'response' || !response.success || !response.body) {
return [];
}

const labels = response.body.map(label => {
return new vscode.SignautreArgumentsLabel(label.name, Position.fromLocation(label.position));
});
return labels;
} catch (e) {
return [];
}
}
}

export function register(
selector: DocumentSelector,
client: ITypeScriptServiceClient
) {
return conditionalRegistration([
requireSomeCapability(client, ClientCapability.Semantic),
], () => {
return vscode.languages.registerSignatureArgumentsLabelProvider(selector.semantic,
new TypeScriptSginatureArgumentsLabelProvider(client));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class LanguageProvider extends Disposable {
import('./languageFeatures/typeDefinitions').then(provider => this._register(provider.register(selector, this.client))),
import('./languageFeatures/semanticTokens').then(provider => this._register(provider.register(selector, this.client))),
import('./languageFeatures/callHierarchy').then(provider => this._register(provider.register(selector, this.client))),
import('./languageFeatures/signatureArgumentsLabel').then(provider => this._register(provider.register(selector, this.client))),
]);
}

Expand Down
20 changes: 20 additions & 0 deletions extensions/typescript-language-features/src/typescriptService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ import { TypeScriptServiceConfiguration } from './utils/configuration';
import { PluginManager } from './utils/plugins';
import { TelemetryReporter } from './utils/telemetry';

export namespace Experimental {
export const enum CommandTypes {
ProvideSignatureArgumentsLabel = 'provideSignatureArgumentsLabel'
}

export interface ProvideSignatureArgumentsLabelRequest extends Proto.FileRequest {
command: CommandTypes.ProvideSignatureArgumentsLabel;
}

interface LabelItem {
name: string
position: Proto.Location
}

export interface ProvideSignatureArgumentsLabelResponse extends Proto.Response {
body?: LabelItem[];
}
}

export enum ServerType {
Syntax = 'syntax',
Semantic = 'semantic',
Expand Down Expand Up @@ -68,6 +87,7 @@ interface StandardTsServerRequests {
'prepareCallHierarchy': [Proto.FileLocationRequestArgs, Proto.PrepareCallHierarchyResponse];
'provideCallHierarchyIncomingCalls': [Proto.FileLocationRequestArgs, Proto.ProvideCallHierarchyIncomingCallsResponse];
'provideCallHierarchyOutgoingCalls': [Proto.FileLocationRequestArgs, Proto.ProvideCallHierarchyOutgoingCallsResponse];
'provideSignatureArgumentsLabel': [Proto.FileRequestArgs, Experimental.ProvideSignatureArgumentsLabelResponse];
}

interface NoResponseTsServerRequests {
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/browser/widget/codeEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ export class EditorModeContext extends Disposable {
private readonly _hasMultipleDocumentFormattingProvider: IContextKey<boolean>;
private readonly _hasMultipleDocumentSelectionFormattingProvider: IContextKey<boolean>;
private readonly _hasSignatureHelpProvider: IContextKey<boolean>;
private readonly _hasSignatureArgumentsLabelProvider: IContextKey<boolean>;
private readonly _isInWalkThrough: IContextKey<boolean>;

constructor(
Expand All @@ -1856,6 +1857,7 @@ export class EditorModeContext extends Disposable {
this._hasReferenceProvider = EditorContextKeys.hasReferenceProvider.bindTo(_contextKeyService);
this._hasRenameProvider = EditorContextKeys.hasRenameProvider.bindTo(_contextKeyService);
this._hasSignatureHelpProvider = EditorContextKeys.hasSignatureHelpProvider.bindTo(_contextKeyService);
this._hasSignatureArgumentsLabelProvider = EditorContextKeys.hasSignatureArgumentsLabelProvider.bindTo(_contextKeyService);
this._hasDocumentFormattingProvider = EditorContextKeys.hasDocumentFormattingProvider.bindTo(_contextKeyService);
this._hasDocumentSelectionFormattingProvider = EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(_contextKeyService);
this._hasMultipleDocumentFormattingProvider = EditorContextKeys.hasMultipleDocumentFormattingProvider.bindTo(_contextKeyService);
Expand Down Expand Up @@ -1884,6 +1886,7 @@ export class EditorModeContext extends Disposable {
this._register(modes.DocumentFormattingEditProviderRegistry.onDidChange(update));
this._register(modes.DocumentRangeFormattingEditProviderRegistry.onDidChange(update));
this._register(modes.SignatureHelpProviderRegistry.onDidChange(update));
this._register(modes.SignatureArgumentsLabelProviderRegistry.onDidChange(update));

update();
}
Expand Down Expand Up @@ -1935,6 +1938,7 @@ export class EditorModeContext extends Disposable {
this._hasReferenceProvider.set(modes.ReferenceProviderRegistry.has(model));
this._hasRenameProvider.set(modes.RenameProviderRegistry.has(model));
this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
this._hasSignatureArgumentsLabelProvider.set(modes.SignatureArgumentsLabelProviderRegistry.has(model));
this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._hasMultipleDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.all(model).length + modes.DocumentRangeFormattingEditProviderRegistry.all(model).length > 1);
Expand Down
10 changes: 9 additions & 1 deletion src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ export interface IEditorOptions {
* Controls strikethrough deprecated variables.
*/
showDeprecated?: boolean;
/**
* Controls show signature arguments label.
*/
showSignatureArgumentsLabel?: boolean
}

/**
Expand Down Expand Up @@ -3759,7 +3763,7 @@ export const enum EditorOption {
wrappingIndent,
wrappingStrategy,
showDeprecated,

showSignatureArgumentsLabel,
// Leave these at the end (because they have dependencies!)
editorClassName,
pixelRatio,
Expand Down Expand Up @@ -4263,6 +4267,10 @@ export const EditorOptions = {
EditorOption.showDeprecated, 'showDeprecated', true,
{ description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") }
)),
showSignatureArgumentsLabel: register(new EditorBooleanOption(
EditorOption.showSignatureArgumentsLabel, 'showSignatureArgumentsLabel', true,
{ description: nls.localize('showSignatureArgumentsLabel', "Controls show signature arguments label.") }
)),
snippetSuggestions: register(new EditorStringEnumOption(
EditorOption.snippetSuggestions, 'snippetSuggestions',
'inline' as 'top' | 'bottom' | 'inline' | 'none',
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/common/editorContextKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export namespace EditorContextKeys {
export const hasReferenceProvider = new RawContextKey<boolean>('editorHasReferenceProvider', false);
export const hasRenameProvider = new RawContextKey<boolean>('editorHasRenameProvider', false);
export const hasSignatureHelpProvider = new RawContextKey<boolean>('editorHasSignatureHelpProvider', false);
export const hasSignatureArgumentsLabelProvider = new RawContextKey<boolean>('editorHasSignatureArgumentsLabelProvider', false);

// -- mode context keys: formatting
export const hasDocumentFormattingProvider = new RawContextKey<boolean>('editorHasDocumentFormattingProvider', false);
Expand Down
15 changes: 14 additions & 1 deletion src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { Position } from 'vs/editor/common/core/position';
import { IPosition, 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';
Expand Down Expand Up @@ -1659,6 +1659,15 @@ export interface CodeLensProvider {
resolveCodeLens?(model: model.ITextModel, codeLens: CodeLens, token: CancellationToken): ProviderResult<CodeLens>;
}

export interface SignautreArgumentsLabel {
name: string
position: IPosition
}

export interface SignatureArgumentsLabelProvider {
provideSignatureArgumentsLabels(model: model.ITextModel, token: CancellationToken): ProviderResult<SignautreArgumentsLabel[]>;
}

export interface SemanticTokensLegend {
readonly tokenTypes: string[];
readonly tokenModifiers: string[];
Expand Down Expand Up @@ -1763,6 +1772,10 @@ export const TypeDefinitionProviderRegistry = new LanguageFeatureRegistry<TypeDe
* @internal
*/
export const CodeLensProviderRegistry = new LanguageFeatureRegistry<CodeLensProvider>();
/**
* @internal
*/
export const SignatureArgumentsLabelProviderRegistry = new LanguageFeatureRegistry<SignatureArgumentsLabelProvider>();

/**
* @internal
Expand Down
11 changes: 6 additions & 5 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@ export enum EditorOption {
wrappingIndent = 117,
wrappingStrategy = 118,
showDeprecated = 119,
editorClassName = 120,
pixelRatio = 121,
tabFocusMode = 122,
layoutInfo = 123,
wrappingInfo = 124
showSignatureArgumentsLabel = 120,
editorClassName = 121,
pixelRatio = 122,
tabFocusMode = 123,
layoutInfo = 124,
wrappingInfo = 125
}

/**
Expand Down
Loading