Skip to content

Tagged Template Signature Help Support in Language Service - #1204

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 23 commits into
masterfrom
taggedSigHelp
Nov 25, 2014
Merged

Daniel Rosenwasser (DanielRosenwasser) merged 23 commits into
masterfrom
taggedSigHelp

Conversation

@DanielRosenwasser

Copy link
Copy Markdown
Member

Signature Help for Tagged Templates

This PR enables signature help support in the language service for tagged template strings.

The idea is that a tagged template is a bit of an implicit function invocation. Whenever a user requests signature help (or it is triggered by the consuming environment), we should figure out what function a tag refers to, which overload should be chosen, and which parameter is currently being fed.

Substitution-Argument Correspondence

When a template expression is tagged, each substitution expression corresponds to an argument in invoking that tag. Specifically, the Nth substitution expression in a tagged template expression is the (N+1)th argument in an invocation.

TemplateStringsArray Argument

Whenever the cursor lies within a template literal (whether a no-substitution literal, or a fragment of a template expression), the parameter in question is the first parameter of the tag in question. This is because each template literal in a tagged template corresponds to an array element in the cooked/raw array object specified in ES6. This means that as the cursor moves through a template expression, parameters will not be highlighted from left-to-right consistently.

sighelptemplates2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Paramter"

Comment thread src/compiler/parser.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you mean unclosed in this context?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably be more explicit - it kind of sounds like I'm referring to a template expression without a template tail. I really mean unterminated, in the sense that your literal isn't explicitly sealed off with a backtick. I'll clarify it. Thanks!

Comment thread src/compiler/parser.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Say that this can be call or new

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove else

Comment thread src/services/utilities.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just ===

@JsonFreeman

Copy link
Copy Markdown
Contributor

👍

@yuit

Copy link
Copy Markdown
Contributor

LGTM

Daniel Rosenwasser (DanielRosenwasser) added a commit that referenced this pull request Nov 25, 2014
Tagged Template Signature Help Support in Language Service
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants