Adds floating block comments to the outlining spans response (#36880)

* Adds floating block comments to the outlining spans response

* Only use one route for grabbing outline nodes, which now includes special casing the EOF token
This commit is contained in:
Orta
2020-02-25 17:09:16 -05:00
committed by GitHub
parent 43863cafe2
commit 8a797cad2b
6 changed files with 45 additions and 8 deletions

View File

@@ -10,7 +10,8 @@ namespace ts.OutliningElementsCollector {
function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push<OutliningSpan>): void {
let depthRemaining = 40;
let current = 0;
const statements = sourceFile.statements;
// Includes the EOF Token so that comments which aren't attached to statements are included
const statements = [...sourceFile.statements, sourceFile.endOfFileToken];
const n = statements.length;
while (current < n) {
while (current < n && !isAnyImportSyntax(statements[current])) {
@@ -33,7 +34,7 @@ namespace ts.OutliningElementsCollector {
if (depthRemaining === 0) return;
cancellationToken.throwIfCancellationRequested();
if (isDeclaration(n)) {
if (isDeclaration(n) || n.kind === SyntaxKind.EndOfFileToken) {
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
}