Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add method signature completions#46370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
andrewbranch merged 39 commits intomainfromgabritto/issue45670
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
39 commits
Select commitHold shift + click to select a range
701c5f3
prototype creation for method override completion snippet
gabrittoSep 10, 2021
2c84d88
WIP: start using codefix `addNewNodeForMemberSymbol` to create method…
gabrittoSep 17, 2021
4d2d476
update type of addNewNodeForMemberSymbol
gabrittoSep 20, 2021
c608a6e
add more tests and support more cases
gabrittoSep 21, 2021
2fa43e8
add more tests and fix some details
gabrittoSep 22, 2021
1d04720
wip: more fixes and tests
gabrittoSep 23, 2021
905caad
expose check override modifier in checker
gabrittoSep 23, 2021
8ad4042
fix test
gabrittoSep 30, 2021
d20eb68
WIP: add snippet support
gabrittoOct 1, 2021
c81f385
WIP: snippet support on emitter, adding snippets in completions
gabrittoOct 5, 2021
b124c84
make add snippets work with overloads (not synced)
gabrittoOct 5, 2021
db408cc
fix snippet adding
gabrittoOct 5, 2021
d7809c1
rebase
gabrittoOct 6, 2021
41a3c19
WIP: try to add snippet escaping in emitter
gabrittoOct 7, 2021
69ee9fc
support escaping in snippets
gabrittoOct 12, 2021
c3a64bc
small fixes; fixed tests
gabrittoOct 12, 2021
e079f71
more tests and fixes
gabrittoOct 13, 2021
d7c26c4
fix new tests
gabrittoOct 14, 2021
fe4fce8
fix modifier inheritance for overloads
gabrittoOct 14, 2021
b8bb27a
Merge branch 'main' into gabritto/issue45670
gabrittoOct 14, 2021
952aac1
merge conflict fixes; remove comments
gabrittoOct 14, 2021
00dc206
throw error if setOptions is called but not implemented
gabrittoOct 14, 2021
28539b6
fix newline handling
gabrittoOct 14, 2021
01eb2bb
fix weird stuff
gabrittoOct 14, 2021
70ebe86
fix tests
gabrittoOct 15, 2021
e76c18d
fix more tests
gabrittoOct 18, 2021
35c1ea3
Fix unbound host.getNewLine
andrewbranchOct 20, 2021
a639aef
fix isParameterDeclaration changes
gabrittoOct 25, 2021
4571e98
rename diagnostic to status and remove snippets from public api
gabrittoOct 25, 2021
3a6b6bf
rename emitter functions + fix indentation
gabrittoOct 25, 2021
302c0fc
check completion kind before calling isclasslikemembercompletion
gabrittoOct 25, 2021
7bdeaa8
fix missing type parameters
gabrittoOct 26, 2021
68e5913
Revert "fix missing type parameters"
gabrittoOct 26, 2021
d796043
add isAmbient flag to addNewNodeForMemberSymbol
gabrittoOct 26, 2021
f6ea5f2
add test for abstract overloads
gabrittoOct 26, 2021
221edac
refactor snippet escaping support
gabrittoOct 27, 2021
8e9cac9
add user preference flag for enabling class member snippets
gabrittoOct 27, 2021
c5f1166
update API baseline
gabrittoOct 27, 2021
a2665d8
update tabstop order
gabrittoOct 28, 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
PrevPrevious commit
update tabstop order
  • Loading branch information
@gabritto
gabritto committedOct 28, 2021
commita2665d8cf8f85a4d226c75b1587b724fad50553c
14 changes: 8 additions & 6 deletionssrc/services/completions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -849,13 +849,15 @@ namespace ts.Completions {
const importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);

let body;
let tabstopStart = 1;
if (preferences.includeCompletionsWithSnippetText) {
isSnippet = true;
// We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
const emptyStatement = factory.createExpressionStatement(factory.createIdentifier(""));
setSnippetElement(emptyStatement, { kind: SnippetKind.TabStop, order: 0 });
body = factory.createBlock([emptyStatement], /* multiline */ true);
const emptyStatement1 = factory.createExpressionStatement(factory.createIdentifier(""));
setSnippetElement(emptyStatement1, { kind: SnippetKind.TabStop, order: 1 });
tabstopStart = 2;
body = factory.createBlock([emptyStatement1], /* multiline */ true);
}
else {
body = factory.createBlock([], /* multiline */ true);
Expand DownExpand Up@@ -914,7 +916,7 @@ namespace ts.Completions {

if (completionNodes.length) {
if (preferences.includeCompletionsWithSnippetText) {
addSnippets(completionNodes);
addSnippets(completionNodes, tabstopStart);
}
insertText = printer.printSnippetList(ListFormat.MultiLine, factory.createNodeArray(completionNodes), sourceFile);
}
Expand DownExpand Up@@ -963,8 +965,8 @@ namespace ts.Completions {
return undefined;
}

function addSnippets(nodes: Node[]): void {
let order =1;
function addSnippets(nodes: Node[], orderStart: number): void {
let order =orderStart;
for (const node of nodes) {
addSnippetsWorker(node, /*parent*/ undefined);
}
Expand Down
2 changes: 1 addition & 1 deletiontests/cases/fourslash/completionsOverridingMethod2.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ verify.completions({
},
isSnippet: true,
insertText:
"\"\\$usd\"(${1:a}: ${2:number}): ${3:number} {\n $0\n}\n",
"\"\\$usd\"(${2:a}: ${3:number}): ${4:number} {\n $1\n}\n",
}
],
});
39 changes: 39 additions & 0 deletionstests/cases/fourslash/completionsOverridingProperties.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
/// <reference path="fourslash.ts" />

// @newline: LF
// @Filename: a.ts
// Case: Properties
////class Base {
//// protected foo: string = "bar";
////
////}
////
////class Sub extends Base {
//// /*a*/
////}




verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "foo",
sortText: completion.SortText.LocationPriority,
replacementSpan: {
fileName: "",
pos: 0,
end: 0,
},
insertText:
"protected foo: string;\n",
}
],
});

[8]ページ先頭

©2009-2025 Movatter.jp