-
Notifications
You must be signed in to change notification settings - Fork 13k
Add Intellisense to JsDoc #4283
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@billti @CyrusNajmabadi could you take a look |
if (paramTag.typeExpression) { | ||
insideJsDocTagExpression = position > paramTag.typeExpression.pos && position < paramTag.typeExpression.end; | ||
}; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These branches are identical, just let each fall through and use a variable typeTagOrParamTag
of type JSDocTypeTag | JSDocParamTag
.
} | ||
|
||
function getAllJsDocCompletionEntries(): CompletionEntry[] { | ||
return ts.map(JsDocTagNames, tagName => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider caching the result. these are not going to change between invocations. saves you the allocations.
see keywordCompletions
for an example.
@@ -131,6 +131,46 @@ namespace ts { | |||
let scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); | |||
|
|||
let emptyArray: any[] = []; | |||
|
|||
const jsDocTagNames: string[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the type annotation.
Playing around with this, and it returns no completions if I don't have the param name yet, for example, if the cursor is where the /**
@param {|}
*/
function foo(a){
// TODO
} |
The problem is that if there is no param name, in the parser the JsDoc comment won't be parsed as a valid jstag node right now, so the compiler can't tell me if I'm inside the braces. |
Seems like we'll need to fix that then. Having to skip over the type and then backtrack to it to get intellisense if not very intuitive or usable. It should be easy to still parse the tag as an Also, |
I thought the reason we stopped parsing param tag without any param names is to be conservative about the type checking process; however, after I talked to Cyrus it turns out to be fine to keep the parsing going. Therefore now the fix for parsing param tag is added, and the |
👍 |
This PR provides completion list for the following cases:
@
sign or in the tagname, e.g.:and
The initial implementation only applies to js files, as currently the parser stores the
JSDocComment
nodes in the tree for js files but not ts files. Support for ts files may need some discussion.