Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
cd99389
Add signature arguments label support
Kingwl Dec 23, 2020
ab3c937
Support rest parameters and destruction
Kingwl Dec 24, 2020
d91b2f7
make lint
Kingwl Dec 24, 2020
8388add
Fix tuple rest parameters
Kingwl Dec 24, 2020
1058fdd
Adjust name styles
Kingwl Dec 24, 2020
1517b1f
Rename to inline hints
Kingwl Dec 24, 2020
fd9b09f
Partition inline hints
Kingwl Dec 25, 2020
23afce2
Adjust range pred
Kingwl Dec 25, 2020
ee6527e
Add function expression like hints
Kingwl Dec 25, 2020
679b58d
Support configure inline hints
Kingwl Dec 25, 2020
446bee4
Display hints in single line
Kingwl Dec 25, 2020
d2fbd1e
Add test suits and tests
Kingwl Dec 27, 2020
c4abb87
Add range tests
Kingwl Dec 28, 2020
a9e007a
Support more hints
Kingwl Dec 29, 2020
df62a11
Add more options
Kingwl Dec 30, 2020
fce2619
Fix logical
Kingwl Dec 30, 2020
679f066
Add more cases
Kingwl Dec 30, 2020
eb4b4ad
Support call chains
Kingwl Dec 30, 2020
9297051
Rename options
Kingwl Dec 30, 2020
467b5cd
Match lastest protocol
Kingwl Jan 13, 2021
e5ca31b
Update protocol changes
Kingwl Jan 14, 2021
37a7089
Support context value and hover message
Kingwl Jan 16, 2021
2ccfc98
Revert "Support context value and hover message"
Kingwl Jan 21, 2021
0e5f223
Revert "Update protocol changes"
Kingwl Jan 21, 2021
7197d0d
Add hover message
Kingwl Jan 21, 2021
e785943
Accept baseline
Kingwl Jan 21, 2021
637c7f8
Update src/services/inlineHints.ts
Kingwl Feb 4, 2021
b3c3e7e
Update src/services/inlineHints.ts
Kingwl Feb 4, 2021
7948cec
Merge branch 'master' into signature_arguments_labels_support
Kingwl Feb 4, 2021
a374417
Cache across the program
Kingwl Feb 4, 2021
7ac2a35
Merge branch 'master' into signature_arguments_labels_support
Kingwl May 7, 2021
5767d7e
Fix possible undefined
Kingwl May 7, 2021
d7d72d6
Update protocol changes
Kingwl Jun 3, 2021
9306d72
Fix missing property
Kingwl Jun 3, 2021
5cab46f
Merge branch 'main' into signature_arguments_labels_support
Kingwl Jun 3, 2021
2750c6b
Make lint happy
Kingwl Jun 4, 2021
0090962
Avoid call chain hints
Kingwl Jun 10, 2021
f771afc
I'm bad
Kingwl Jun 10, 2021
67dcbb0
Add whitespace before type
Kingwl Jun 10, 2021
957756c
Add more tests
Kingwl Jun 10, 2021
db4135b
Should care about jsdoc
Kingwl Jun 10, 2021
b74af7c
Support complex rest parameter
Kingwl Jun 10, 2021
388cc6d
Avoid module symbol hints
Kingwl Jun 14, 2021
f5695a1
Care about leading comments
Kingwl Jun 14, 2021
6336803
Fix CR issues
Kingwl Jun 15, 2021
09cdf37
Avoid changes
Kingwl Jun 15, 2021
71bae5e
Simplify comments contains
Kingwl Jun 15, 2021
cba4dc3
Fix CR issues
Kingwl Jun 18, 2021
0e8cdb6
Accept baseline
Kingwl Jun 18, 2021
cc06dbc
Merge branch 'main' into signature_arguments_labels_support
Kingwl Jun 18, 2021
e8fef30
Check parameter name before create regex
Kingwl Jun 18, 2021
d8dc8f1
Rename option
Kingwl Jun 24, 2021
52c9d5c
Avoid makers
Kingwl Jun 24, 2021
7ce7a44
Skip parens for argument
Kingwl Jun 24, 2021
24e1a4a
Fix CR issues
Kingwl Jun 24, 2021
6b279e7
Fix enums
Kingwl Jun 25, 2021
8e9a8d8
Accept baseline
Kingwl Jun 25, 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
Prev Previous commit
Next Next commit
Rename option
  • Loading branch information
Kingwl committed Jun 24, 2021
commit d8dc8f193cd3dba4ebcab5bda03629c2ff54e937
5 changes: 2 additions & 3 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8479,9 +8479,8 @@ namespace ts {
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly provideRefactorNotApplicableReason?: boolean;
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
Comment thread
Kingwl marked this conversation as resolved.
Outdated
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down
14 changes: 11 additions & 3 deletions src/services/inlayHints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ namespace ts.InlayHints {
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
Comment thread
Kingwl marked this conversation as resolved.
};

function shouldShowParameterNameHints(preferences: UserPreferences) {
return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all";
}

function shouldShowLiteralParameterNameHintsOnly(preferences: UserPreferences) {
return preferences.includeInlayParameterNameHints === "literals";
}

export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
const { file, program, span, cancellationToken, preferences } = context;
const sourceFileText = file.text;
Expand Down Expand Up @@ -52,7 +60,7 @@ namespace ts.InlayHints {
else if (preferences.includeInlayEnumMemberValueHints && isEnumMember(node)) {
visitEnumMember(node);
}
else if (preferences.includeInlayParameterNameHints && (isCallExpression(node) || isNewExpression(node))) {
else if (shouldShowParameterNameHints(preferences) && (isCallExpression(node) || isNewExpression(node))) {
visitCallOrNewExpression(node);
}
else {
Expand Down Expand Up @@ -147,14 +155,14 @@ namespace ts.InlayHints {

for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (!preferences.includeInlayNonLiteralParameterNameHints && !isHintableExpression(arg)) {
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableExpression(arg)) {
continue;
}

const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
if (identifierNameInfo) {
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
const isParameterNameNotSameAsArgument = preferences.includeInlayDuplicatedParameterNameHints || !isIdentifier(arg) || arg.text !== parameterName;
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !isIdentifier(arg) || arg.text !== parameterName;
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,8 @@ namespace ts {
}

export interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean,
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down
10 changes: 4 additions & 6 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3957,9 +3957,8 @@ declare namespace ts {
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly provideRefactorNotApplicableReason?: boolean;
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down Expand Up @@ -5746,9 +5745,8 @@ declare namespace ts {
includeInsertTextCompletions?: boolean;
}
interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down
10 changes: 4 additions & 6 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3957,9 +3957,8 @@ declare namespace ts {
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly provideRefactorNotApplicableReason?: boolean;
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down Expand Up @@ -5746,9 +5745,8 @@ declare namespace ts {
includeInsertTextCompletions?: boolean;
}
interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down
5 changes: 2 additions & 3 deletions tests/cases/fourslash/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,8 @@ declare namespace FourSlashInterface {
readonly importModuleSpecifierEnding?: "minimal" | "index" | "js";
}
interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: boolean;
readonly includeInlayNonLiteralParameterNameHints?: boolean;
readonly includeInlayDuplicatedParameterNameHints?: boolean;
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

const markers = test.markers();
Comment thread
Kingwl marked this conversation as resolved.
Outdated
verify.getInlayHints([], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
5 changes: 2 additions & 3 deletions tests/cases/fourslash/inlayHintsShouldWork13.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: true,
includeInlayNonLiteralParameterNameHints: true,
includeInlayDuplicatedParameterNameHints: false,
includeInlayParameterNameHints: "all",
includeInlayParameterNameHintsWhenArgumentMatchesName: false,
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork14.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
//// foo(1, 2);

verify.getInlayHints([], undefined, {
includeInlayParameterNameHints: false
includeInlayParameterNameHints: "none"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork29.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ verify.getInlayHints([
whitespaceBefore: true
}
], undefined, {
includeInlayParameterNameHints: true,
includeInlayParameterNameHints: "literals",
includeInlayFunctionParameterTypeHints: true
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ verify.getInlayHints(
whitespaceAfter: true
}
}), span, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
})
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork33.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ verify.getInlayHints(
whitespaceAfter: true
}
}), span, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
3 changes: 1 addition & 2 deletions tests/cases/fourslash/inlayHintsShouldWork34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ verify.getInlayHints(
kind: ts.InlayHintKind.Parameter,
whitespaceAfter: true
})) , undefined, {
includeInlayParameterNameHints: true,
includeInlayNonLiteralParameterNameHints: false
includeInlayParameterNameHints: "literals"
});
3 changes: 1 addition & 2 deletions tests/cases/fourslash/inlayHintsShouldWork35.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ verify.getInlayHints(
kind: ts.InlayHintKind.Parameter,
whitespaceAfter: true
})) , undefined, {
includeInlayParameterNameHints: true,
includeInlayNonLiteralParameterNameHints: true
includeInlayParameterNameHints: "all"
});
5 changes: 2 additions & 3 deletions tests/cases/fourslash/inlayHintsShouldWork36.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: true,
includeInlayNonLiteralParameterNameHints: true,
includeInlayDuplicatedParameterNameHints: true,
includeInlayParameterNameHints: "all",
includeInlayParameterNameHintsWhenArgumentMatchesName: true,
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork47.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork49.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
goTo.file('/a.js')
const markers = test.markers();
verify.getInlayHints([], undefined, {
Comment thread
Kingwl marked this conversation as resolved.
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork50.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ verify.getInlayHints([
whitespaceAfter: true
},
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork52.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true,
includeInlayParameterNameHints: "literals",
includeInlayFunctionLikeReturnTypeHints: true
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork53.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});
2 changes: 1 addition & 1 deletion tests/cases/fourslash/inlayHintsShouldWork9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ verify.getInlayHints([
whitespaceAfter: true
}
], undefined, {
includeInlayParameterNameHints: true
includeInlayParameterNameHints: "literals"
});