From 91e6bce34c3a2d771b815cd73c176018186b31b5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 18 Nov 2016 15:44:15 -0800 Subject: [PATCH] Address PR comments --- src/compiler/binder.ts | 4 ++-- src/compiler/parser.ts | 20 ++++++++++---------- src/compiler/types.ts | 4 ++-- src/compiler/utilities.ts | 12 ++++++------ src/services/navigationBar.ts | 4 ++-- src/services/services.ts | 6 +++--- src/services/utilities.ts | 8 ++++---- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1afe51db021..c2bfce10e57 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -599,8 +599,8 @@ namespace ts { // Binding of JsDocComment should be done before the current block scope container changes. // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. - if (isInJavaScriptFile(node) && node.jsDocComments) { - forEach(node.jsDocComments, bind); + if (isInJavaScriptFile(node) && node.jsDoc) { + forEach(node.jsDoc, bind); } if (checkUnreachable(node)) { bindEachChild(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a3c21eaf8dc..d286a9d9dac 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -689,10 +689,10 @@ namespace ts { continue; } - if (!node.jsDocComments) { - node.jsDocComments = []; + if (!node.jsDoc) { + node.jsDoc = []; } - node.jsDocComments.push(jsDoc); + node.jsDoc.push(jsDoc); } } @@ -719,11 +719,11 @@ namespace ts { const saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDocComments) { - for (const jsDocComment of n.jsDocComments) { - jsDocComment.parent = n; - parent = jsDocComment; - forEachChild(jsDocComment, visitNode); + if (n.jsDoc) { + for (const jsDoc of n.jsDoc) { + jsDoc.parent = n; + parent = jsDoc; + forEachChild(jsDoc, visitNode); } } parent = saveParent; @@ -6954,8 +6954,8 @@ namespace ts { } forEachChild(node, visitNode, visitArray); - if (node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { + if (node.jsDoc) { + for (const jsDocComment of node.jsDoc) { forEachChild(jsDocComment, visitNode, visitArray); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 51805228e48..2a4b9e66d82 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -497,8 +497,8 @@ namespace ts { parent?: Node; // Parent node (initialized by binding) /* @internal */ original?: Node; // The original node if this is an updated node. /* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms). - /* @internal */ jsDocComments?: JSDoc[]; // JSDoc for the node, if it has any. - /* @internal */ jsDocCache?: (JSDoc | JSDocTag)[]; // JSDoc for the node, plus JSDoc and tags retrieved from its parents + /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node + /* @internal */ jsDocCache?: (JSDoc | JSDocTag)[]; // All JSDoc that applies to the node, including parent docs and @param tags /* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding) /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5669ac9be8d..1d14854cd1f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -239,7 +239,7 @@ namespace ts { return !nodeIsMissing(node); } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. if (nodeIsMissing(node)) { @@ -250,8 +250,8 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); + if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + return getTokenPosOfNode(node.jsDoc[0]); } // For a syntax list, it is possible that one of its children has JSDocComment nodes, while @@ -259,7 +259,7 @@ namespace ts { // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. if (node.kind === SyntaxKind.SyntaxList && (node)._children.length > 0) { - return getTokenPosOfNode((node)._children[0], sourceFile, includeJsDocComment); + return getTokenPosOfNode((node)._children[0], sourceFile, includeJsDoc); } return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -1495,10 +1495,10 @@ namespace ts { } if (isVariableLike(node) && node.initializer) { - cache = concatenate(cache, node.initializer.jsDocComments); + cache = concatenate(cache, node.initializer.jsDoc); } - cache = concatenate(cache, node.jsDocComments); + cache = concatenate(cache, node.jsDoc); } } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 51ce9b6001d..1cbaa3d640f 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -225,8 +225,8 @@ namespace ts.NavigationBar { break; default: - forEach(node.jsDocComments, jsDocComment => { - forEach(jsDocComment.tags, tag => { + forEach(node.jsDoc, jsDoc => { + forEach(jsDoc.tags, tag => { if (tag.kind === SyntaxKind.JSDocTypedefTag) { addLeafNode(tag); } diff --git a/src/services/services.ts b/src/services/services.ts index 3c0b7838314..f826a8850fe 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1956,9 +1956,9 @@ namespace ts { break; default: forEachChild(node, walk); - if (node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - forEachChild(jsDocComment, walk); + if (node.jsDoc) { + for (const jsDoc of node.jsDoc) { + forEachChild(jsDoc, walk); } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 82b13f82327..e19fdc0a84a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -951,10 +951,10 @@ namespace ts { } if (node) { - if (node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - if (jsDocComment.tags) { - for (const tag of jsDocComment.tags) { + if (node.jsDoc) { + for (const jsDoc of node.jsDoc) { + if (jsDoc.tags) { + for (const tag of jsDoc.tags) { if (tag.pos <= position && position <= tag.end) { return tag; }