CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit,
Query, RootChange, SourceChange, SourceFileEdit,
symbol_index::{FileSymbol, LibrarySymbolsQuery},
- rename::rename
};
impl db::RootDatabase {
.collect()
}
- pub(crate) fn rename(&self, position: FilePosition, new_name: &str) -> Option<SourceChange> {
- rename(self, position, new_name)
- }
-
pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
let name = name_ref.text();
let mut query = Query::new(name.to_string());
position: FilePosition,
) -> Option<(&ast::Name, &ast::Module)> {
let ast_name = find_node_at_offset::<ast::Name>(syntax, position.offset);
- let ast_name_parent = ast_name
- .and_then(|n| n.syntax().parent())
- .and_then(|p| ast::Module::cast(p));
+ let ast_name_parent = ast::Module::cast(ast_name?.syntax().parent()?);
if let (Some(ast_module), Some(name)) = (ast_name_parent, ast_name) {
return Some((name, ast_module));
FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range,
RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit,
- WorkspaceEdit, DocumentChanges, TextDocumentEdit, DocumentChangeOperation, ResourceOp
+ WorkspaceEdit
};
use ra_ide_api::{
FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity,
return Ok(None);
}
- let mut source_change = change.unwrap();
- let text_document_edits = source_change
- .source_file_edits
- .drain(..)
- .into_iter()
- .map(|e| e.try_conv_with(&world))
- .collect::<Result<Vec<TextDocumentEdit>>>();
-
- let text_document_ops = source_change
- .file_system_edits
- .drain(..)
- .into_iter()
- .map(|e| e.try_conv_with(&world))
- .collect::<Result<Vec<ResourceOp>>>();
-
- let mut document_changes = Vec::new();
- document_changes.extend(
- text_document_edits?
- .into_iter()
- .map(DocumentChangeOperation::Edit),
- );
- document_changes.extend(
- text_document_ops?
- .into_iter()
- .map(DocumentChangeOperation::Op),
- );
+ let source_change_req = change.unwrap().try_conv_with(&world)?;
- Ok(Some(WorkspaceEdit {
- changes: None,
- document_changes: Some(DocumentChanges::Operations(document_changes)),
- }))
+ Ok(Some(source_change_req.workspace_edit))
}
pub fn handle_references(