Merge InlayHintOptions into UserPreferences (#47729)

* get rid of inlayhintoptions

* update userpreferences in protocol
This commit is contained in:
Gabriela Araujo Britto
2022-02-15 19:56:16 -03:00
committed by GitHub
parent 0798faf596
commit d0e1255d18
11 changed files with 47 additions and 39 deletions

View File

@@ -8693,6 +8693,13 @@ namespace ts {
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly provideRefactorNotApplicableReason?: boolean;
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean,
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
readonly includeInlayEnumMemberValueHints?: boolean;
}
/** Represents a bigint literal value without requiring bigint support */

View File

@@ -841,7 +841,7 @@ namespace FourSlash {
});
}
public verifyInlayHints(expected: readonly FourSlashInterface.VerifyInlayHintsOptions[], span: ts.TextSpan = { start: 0, length: this.activeFile.content.length }, preference?: ts.InlayHintsOptions) {
public verifyInlayHints(expected: readonly FourSlashInterface.VerifyInlayHintsOptions[], span: ts.TextSpan = { start: 0, length: this.activeFile.content.length }, preference?: ts.UserPreferences) {
const hints = this.languageService.provideInlayHints(this.activeFile.fileName, span, preference);
assert.equal(hints.length, expected.length, "Number of hints");

View File

@@ -255,7 +255,7 @@ namespace FourSlashInterface {
}
}
public getInlayHints(expected: readonly VerifyInlayHintsOptions[], span: ts.TextSpan, preference?: ts.InlayHintsOptions) {
public getInlayHints(expected: readonly VerifyInlayHintsOptions[], span: ts.TextSpan, preference?: ts.UserPreferences) {
this.state.verifyInlayHints(expected, span, preference);
}

View File

@@ -600,7 +600,7 @@ namespace Harness.LanguageService {
provideCallHierarchyOutgoingCalls(fileName: string, position: number) {
return unwrapJSONCallResult(this.shim.provideCallHierarchyOutgoingCalls(fileName, position));
}
provideInlayHints(fileName: string, span: ts.TextSpan, preference: ts.InlayHintsOptions) {
provideInlayHints(fileName: string, span: ts.TextSpan, preference: ts.UserPreferences) {
return unwrapJSONCallResult(this.shim.provideInlayHints(fileName, span, preference));
}
getEmitOutput(fileName: string): ts.EmitOutput {

View File

@@ -3420,6 +3420,14 @@ namespace ts.server.protocol {
readonly displayPartsForJSDoc?: boolean;
readonly generateReturnInDocTemplate?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean,
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
readonly includeInlayEnumMemberValueHints?: boolean;
}
export interface CompilerOptions {

View File

@@ -7,11 +7,11 @@ namespace ts.InlayHints {
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
};
function shouldShowParameterNameHints(preferences: InlayHintsOptions) {
function shouldShowParameterNameHints(preferences: UserPreferences) {
return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all";
}
function shouldShowLiteralParameterNameHintsOnly(preferences: InlayHintsOptions) {
function shouldShowLiteralParameterNameHintsOnly(preferences: UserPreferences) {
return preferences.includeInlayParameterNameHints === "literals";
}

View File

@@ -2636,7 +2636,7 @@ namespace ts {
return declaration ? CallHierarchy.getOutgoingCalls(program, declaration) : [];
}
function provideInlayHints(fileName: string, span: TextSpan, preferences: InlayHintsOptions = emptyOptions): InlayHint[] {
function provideInlayHints(fileName: string, span: TextSpan, preferences: UserPreferences = emptyOptions): InlayHint[] {
synchronizeHostData();
const sourceFile = getValidSourceFile(fileName);
return InlayHints.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences));

View File

@@ -282,7 +282,7 @@ namespace ts {
prepareCallHierarchy(fileName: string, position: number): string;
provideCallHierarchyIncomingCalls(fileName: string, position: number): string;
provideCallHierarchyOutgoingCalls(fileName: string, position: number): string;
provideInlayHints(fileName: string, span: TextSpan, preference: InlayHintsOptions | undefined): string;
provideInlayHints(fileName: string, span: TextSpan, preference: UserPreferences | undefined): string;
getEmitOutput(fileName: string): string;
getEmitOutputObject(fileName: string): EmitOutput;
@@ -1069,7 +1069,7 @@ namespace ts {
);
}
public provideInlayHints(fileName: string, span: TextSpan, preference: InlayHintsOptions | undefined): string {
public provideInlayHints(fileName: string, span: TextSpan, preference: UserPreferences | undefined): string {
return this.forwardJSONCall(
`provideInlayHints('${fileName}', '${JSON.stringify(span)}', ${JSON.stringify(preference)})`,
() => this.languageService.provideInlayHints(fileName, span, preference)

View File

@@ -585,16 +585,6 @@ namespace ts {
includeInsertTextCompletions?: boolean;
}
export interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean,
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
readonly includeInlayEnumMemberValueHints?: boolean;
}
export type SignatureHelpTriggerCharacter = "," | "(" | "<";
export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
@@ -1620,6 +1610,6 @@ namespace ts {
cancellationToken: CancellationToken;
host: LanguageServiceHost;
span: TextSpan;
preferences: InlayHintsOptions;
preferences: UserPreferences;
}
}