renameSymbol function
Set up rename symbol support.
The source callback is called when the user confirms a rename
with a new name. It should return a RenameResult with all
locations where the symbol should be renamed.
Example:
renameSymbol(
(state, pos, newName) async {
final result = await lspClient.rename(state.doc, pos, newName);
if (result == null) return null;
return RenameResult(
locations: result.changes.map((c) => RenameLocation(
from: c.range.start,
to: c.range.end,
)).toList(),
);
},
RenameOptions(
prepareSource: (state, pos) async {
final prep = await lspClient.prepareRename(state.doc, pos);
if (prep == null) return null;
return PrepareRenameResult(
from: prep.range.start,
to: prep.range.end,
placeholder: prep.placeholder,
);
},
),
)
Implementation
Extension renameSymbol(
RenameSource source, [
RenameOptions options = const RenameOptions(),
]) {
final config = RenameConfig(
source: source,
options: options,
);
return ExtensionList([
renameFacet.of(config),
]);
}