mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 12:15:34 -06:00
Merge pull request #22965 from Microsoft/incrementalEditWithJsDocNode
[release-2.8] Correct the incremental parsing when there is jsDoc node
This commit is contained in:
commit
72776b0881
@ -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;
|
||||
}
|
||||
|
||||
15
tests/cases/fourslash/incrementalParsingWithJsDoc.ts
Normal file
15
tests/cases/fourslash/incrementalParsingWithJsDoc.ts
Normal 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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user