(ctx context.Context, sourceFile *ast.SourceFile)
| 59 | } |
| 60 | |
| 61 | func (l *LanguageService) addNodeOutliningSpans(ctx context.Context, sourceFile *ast.SourceFile) []*lsproto.FoldingRange { |
| 62 | depthRemaining := 40 |
| 63 | current := 0 |
| 64 | |
| 65 | statements := sourceFile.Statements |
| 66 | n := len(statements.Nodes) |
| 67 | foldingRange := make([]*lsproto.FoldingRange, 0, 40) |
| 68 | for current < n { |
| 69 | for current < n && !ast.IsAnyImportSyntax(statements.Nodes[current]) { |
| 70 | foldingRange = append(foldingRange, visitNode(ctx, statements.Nodes[current], depthRemaining, sourceFile, l)...) |
| 71 | current++ |
| 72 | } |
| 73 | if current == n { |
| 74 | break |
| 75 | } |
| 76 | firstImport := current |
| 77 | for current < n && ast.IsAnyImportSyntax(statements.Nodes[current]) { |
| 78 | foldingRange = append(foldingRange, visitNode(ctx, statements.Nodes[current], depthRemaining, sourceFile, l)...) |
| 79 | current++ |
| 80 | } |
| 81 | lastImport := current - 1 |
| 82 | if lastImport != firstImport { |
| 83 | foldingRangeKind := lsproto.FoldingRangeKindImports |
| 84 | foldingRange = append(foldingRange, createFoldingRangeFromBounds( |
| 85 | ctx, |
| 86 | astnav.GetStartOfNode(astnav.FindChildOfKind(statements.Nodes[firstImport], |
| 87 | ast.KindImportKeyword, sourceFile), sourceFile, false /*includeJSDoc*/), |
| 88 | statements.Nodes[lastImport].End(), |
| 89 | foldingRangeKind, |
| 90 | sourceFile, |
| 91 | l, |
| 92 | )) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Visit the EOF Token so that comments which aren't attached to statements are included. |
| 97 | foldingRange = append(foldingRange, visitNode(ctx, sourceFile.EndOfFileToken, depthRemaining, sourceFile, l)...) |
| 98 | return foldingRange |
| 99 | } |
| 100 | |
| 101 | func (l *LanguageService) addRegionOutliningSpans(ctx context.Context, sourceFile *ast.SourceFile) []*lsproto.FoldingRange { |
| 102 | regions := make([]*lsproto.FoldingRange, 0, 40) |
no test coverage detected