-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add method signature completions #46370
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all commits
701c5f3
2c84d88
4d2d476
c608a6e
2fa43e8
1d04720
905caad
8ad4042
d20eb68
c81f385
b124c84
db408cc
d7809c1
41a3c19
69ee9fc
c3a64bc
e079f71
d7c26c4
fe4fce8
b8bb27a
952aac1
00dc206
28539b6
01eb2bb
70ebe86
e76c18d
35c1ea3
a639aef
4571e98
3a6b6bf
302c0fc
7bdeaa8
68e5913
d796043
f6ea5f2
221edac
8e9cac9
c5f1166
a2665d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1283,7 +1283,13 @@ namespace ts { | |
currentParenthesizerRule = undefined; | ||
} | ||
|
||
function pipelineEmitWithHintWorker(hint: EmitHint, node: Node): void { | ||
function pipelineEmitWithHintWorker(hint: EmitHint, node: Node, allowSnippets = true): void { | ||
if (allowSnippets) { | ||
const snippet = getSnippetElement(node); | ||
if (snippet) { | ||
return emitSnippetNode(hint, node, snippet); | ||
} | ||
} | ||
if (hint === EmitHint.SourceFile) return emitSourceFile(cast(node, isSourceFile)); | ||
if (hint === EmitHint.IdentifierName) return emitIdentifier(cast(node, isIdentifier)); | ||
if (hint === EmitHint.JsxAttributeValue) return emitLiteral(cast(node, isStringLiteral), /*jsxAttributeEscape*/ true); | ||
|
@@ -1924,6 +1930,32 @@ namespace ts { | |
} | ||
} | ||
|
||
// | ||
// Snippet Elements | ||
// | ||
|
||
function emitSnippetNode(hint: EmitHint, node: Node, snippet: SnippetElement) { | ||
switch (snippet.kind) { | ||
case SnippetKind.Placeholder: | ||
emitPlaceholder(hint, node, snippet); | ||
break; | ||
case SnippetKind.TabStop: | ||
emitTabStop(snippet); | ||
break; | ||
} | ||
} | ||
|
||
function emitPlaceholder(hint: EmitHint, node: Node, snippet: Placeholder) { | ||
nonEscapingWrite(`\$\{${snippet.order}:`); // `${2:` | ||
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bypasses the normal emit pipeline, which might be a problem if you want to emit synthetic JSDoc comments for JS files in the future (since that requires |
||
nonEscapingWrite(`\}`); // `}` | ||
// `${2:...}` | ||
} | ||
|
||
function emitTabStop(snippet: TabStop) { | ||
nonEscapingWrite(`\$${snippet.order}`); | ||
} | ||
|
||
// | ||
// Identifiers | ||
// | ||
|
@@ -4457,6 +4489,16 @@ namespace ts { | |
writer.writeProperty(s); | ||
} | ||
|
||
function nonEscapingWrite(s: string) { | ||
// This should be defined in a snippet-escaping text writer. | ||
if (writer.nonEscapingWrite) { | ||
writer.nonEscapingWrite(s); | ||
} | ||
else { | ||
writer.write(s); | ||
} | ||
} | ||
|
||
function writeLine(count = 1) { | ||
for (let i = 0; i < count; i++) { | ||
writer.writeLine(i > 0); | ||
|
Uh oh!
There was an error while loading. Please reload this page.