formatDocumentSymbolResult function

String formatDocumentSymbolResult(
  1. List<LspDocumentSymbol>? symbols, {
  2. String? cwd,
})

Format documentSymbol result (hierarchical outline).

Implementation

String formatDocumentSymbolResult(
  List<LspDocumentSymbol>? symbols, {
  String? cwd,
}) {
  if (symbols == null || symbols.isEmpty) {
    return 'No symbols found in document. This may occur if the file is empty, '
        'not supported by the LSP server, or if the server has not fully '
        'indexed the file.';
  }
  final lines = <String>['Document symbols:'];
  for (final symbol in symbols) {
    lines.addAll(_formatDocumentSymbolNode(symbol));
  }
  return lines.join('\n');
}