Skip to content
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

JSDoc support #6024

Merged
merged 10 commits into from
Jan 23, 2016
Merged

JSDoc support #6024

merged 10 commits into from
Jan 23, 2016

Conversation

RyanCavanaugh
Copy link
Member

Adds support for adding type information in JavaScript files using jsdoc tags

Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType);
let functionType = <JSDocFunctionType>node.parent;
let index = indexOf(functionType.parameters, node);
return "p" + index;
Copy link
Member

Choose a reason for hiding this comment

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

Will we ever manifest this name to the user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@ahejlsberg
Copy link
Member

The parseJSDocOptionalType function in parser.ts is never called.

@@ -1241,6 +1265,8 @@ namespace ts {

case SyntaxKind.CallExpression:
if (isInJavaScriptFile(node)) {
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
// this check if we've already seen the module indicator
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing where you skip this check.

// Keep going
}
else {
identifierStarted = true;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, so an identifier can start with anything but the characters checked for above, but then after that must contain proper identifier characters. That seems a bit odd.


if (startPos === pos) {
function scanJsDocIdentifier(): Identifier {
Copy link
Member

Choose a reason for hiding this comment

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

Should be parseJSDocIdentifier. The scanning is handled by the scanner.

Copy link
Member

Choose a reason for hiding this comment

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

Also, it should call nextJSDocToken(), similar to what parseIdentifier in the main parser does.

return pos += 1, token = SyntaxKind.CommaToken;
}
else if (isWhiteSpace(ch)) {
// Keep going
Copy link
Member

Choose a reason for hiding this comment

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

This should never happen though right? As you've eaten the preceding white space, and there's nothing in here where you would consume white space inside a token.

precedingLineBreak = savePrecedingLineBreak;
tokenValue = saveTokenValue;
hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape;
tokenIsUnterminated = saveTokenIsUnterminated;
Copy link
Member

Choose a reason for hiding this comment

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

It seems a little fragile to use a method (setText - which calls setTextPos) to modify the state prior to callback execution, then manually restore each field individually after. If anyone added further state changes in setText (or setTextPos), they'd need to know to come and manually undo those same changes here. Can this set/restore be made more symmetrical/colocated somehow?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same pattern we use elsewhere (e.g. in speculationHelper). I don't see any obvious improvement.

@@ -3860,12 +3923,33 @@ namespace ts {
return result;
}

function isOptionalParameter(node: ParameterDeclaration) {
function isOptionalParameter(node: ParameterDeclaration, skipSignatureCheck?: boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

The skipSignatureCheck parameter never appears to be used.

const onClose = () => { return; };

// Use a socket for comms if defined
const tss_debug: string = process.env["TSS_DEBUG"];
Copy link
Member

Choose a reason for hiding this comment

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

All these edits to server.ts look like changes I made in my branch to help with debugging Sublime but hadn't pushed to 'master' (and are part of bigger changes on both Sublime and tsserver to use TCP over stdin/stdout if configured to do so via TSS_DEBUG). Any idea how the changes in this file got in this code review?

Copy link
Member Author

Choose a reason for hiding this comment

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

Undone.

@ahejlsberg
Copy link
Member

Made it all the way through. I think we're good once my comments are addressed.

@RyanCavanaugh RyanCavanaugh merged commit 120fa19 into microsoft:master Jan 23, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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.

7 participants