formatGoToDefinitionResult function
Format goToDefinition result.
Implementation
String formatGoToDefinitionResult(List<LspLocation>? locations, {String? cwd}) {
if (locations == null || locations.isEmpty) {
return 'No definition found. This may occur if the cursor is not on a '
'symbol, or if the definition is in an external library not indexed '
'by the LSP server.';
}
final valid = locations.where((l) => l.uri.isNotEmpty).toList();
if (valid.isEmpty) {
return 'No definition found. This may occur if the cursor is not on a '
'symbol, or if the definition is in an external library not indexed '
'by the LSP server.';
}
if (valid.length == 1) {
return 'Defined in ${formatLocation(valid[0], cwd: cwd)}';
}
final locationList = valid
.map((loc) => ' ${formatLocation(loc, cwd: cwd)}')
.join('\n');
return 'Found ${valid.length} definitions:\n$locationList';
}