Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6965,7 +6965,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);
Expand Down Expand Up @@ -7071,10 +7071,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);
}
}
Expand Down Expand Up @@ -7112,7 +7118,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;
}
Expand Down
15 changes: 15 additions & 0 deletions tests/cases/fourslash/incrementalParsingWithJsDoc.ts
Original file line number Diff line number Diff line change
@@ -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());