Merge pull request #22965 from Microsoft/incrementalEditWithJsDocNode

[release-2.8] Correct the incremental parsing when there is jsDoc node
This commit is contained in:
Sheetal Nandi 2018-03-28 16:24:01 -07:00 committed by GitHub
commit 72776b0881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -7013,7 +7013,7 @@ namespace ts {
forEachChild(node, visitNode, visitArray);
if (hasJSDocNodes(node)) {
for (const jsDocComment of node.jsDoc) {
forEachChild(jsDocComment, visitNode, visitArray);
visitNode(<IncrementalNode><Node>jsDocComment);
}
}
checkNodePositions(node, aggressiveChecks);
@ -7119,10 +7119,16 @@ namespace ts {
function checkNodePositions(node: Node, aggressiveChecks: boolean) {
if (aggressiveChecks) {
let pos = node.pos;
forEachChild(node, child => {
const visitNode = (child: Node) => {
Debug.assert(child.pos >= pos);
pos = child.end;
});
};
if (hasJSDocNodes(node)) {
for (const jsDocComment of node.jsDoc) {
visitNode(jsDocComment);
}
}
forEachChild(node, visitNode);
Debug.assert(pos <= node.end);
}
}
@ -7160,7 +7166,11 @@ namespace ts {
// Adjust the pos or end (or both) of the intersecting element accordingly.
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
forEachChild(child, visitNode, visitArray);
if (hasJSDocNodes(child)) {
for (const jsDocComment of child.jsDoc) {
visitNode(<IncrementalNode><Node>jsDocComment);
}
}
checkNodePositions(child, aggressiveChecks);
return;
}

View File

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts"/>
////import a from 'a/aaaaaaa/aaaaaaa/aaaaaa/aaaaaaa';
/////**/import b from 'b';
////import c from 'c';
////
////[|/** @internal */|]
////export class LanguageIdentifier[| { }|]
// Force a syntax tree ot be created.
verify.outliningSpansInCurrentFile(test.ranges());
goTo.marker("");
edit.backspace(test.marker("").position);
verify.outliningSpansInCurrentFile(test.ranges());