mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
reformat the world
This commit is contained in:
parent
5cb1d41a30
commit
12e3b4c70b
129 changed files with 727 additions and 2509 deletions
|
@ -46,12 +46,7 @@ pub fn handle_extend_selection(
|
|||
.into_iter()
|
||||
.map_conv_with(&line_index)
|
||||
.map(|range| FileRange { file_id, range })
|
||||
.map(|frange| {
|
||||
world
|
||||
.analysis()
|
||||
.extend_selection(frange)
|
||||
.map(|it| it.conv_with(&line_index))
|
||||
})
|
||||
.map(|frange| world.analysis().extend_selection(frange).map(|it| it.conv_with(&line_index)))
|
||||
.collect::<Cancelable<Vec<_>>>()?;
|
||||
Ok(req::ExtendSelectionResult { selections })
|
||||
}
|
||||
|
@ -67,10 +62,7 @@ pub fn handle_find_matching_brace(
|
|||
.into_iter()
|
||||
.map_conv_with(&line_index)
|
||||
.map(|offset| {
|
||||
world
|
||||
.analysis()
|
||||
.matching_brace(FilePosition { file_id, offset })
|
||||
.unwrap_or(offset)
|
||||
world.analysis().matching_brace(FilePosition { file_id, offset }).unwrap_or(offset)
|
||||
})
|
||||
.map_conv_with(&line_index)
|
||||
.collect();
|
||||
|
@ -171,11 +163,7 @@ pub fn handle_workspace_symbol(
|
|||
let all_symbols = params.query.contains('#');
|
||||
let libs = params.query.contains('*');
|
||||
let query = {
|
||||
let query: String = params
|
||||
.query
|
||||
.chars()
|
||||
.filter(|&c| c != '#' && c != '*')
|
||||
.collect();
|
||||
let query: String = params.query.chars().filter(|&c| c != '#' && c != '*').collect();
|
||||
let mut q = Query::new(query);
|
||||
if !all_symbols {
|
||||
q.only_types();
|
||||
|
@ -367,10 +355,7 @@ pub fn handle_completion(
|
|||
Some(items) => items,
|
||||
};
|
||||
let line_index = world.analysis().file_line_index(position.file_id);
|
||||
let items = items
|
||||
.into_iter()
|
||||
.map(|item| item.conv_with(&line_index))
|
||||
.collect();
|
||||
let items = items.into_iter().map(|item| item.conv_with(&line_index)).collect();
|
||||
|
||||
Ok(Some(req::CompletionResponse::Array(items)))
|
||||
}
|
||||
|
@ -496,9 +481,8 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
|
|||
.into());
|
||||
}
|
||||
|
||||
let optional_change = world
|
||||
.analysis()
|
||||
.rename(FilePosition { file_id, offset }, &*params.new_name)?;
|
||||
let optional_change =
|
||||
world.analysis().rename(FilePosition { file_id, offset }, &*params.new_name)?;
|
||||
let change = match optional_change {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
|
@ -517,14 +501,10 @@ pub fn handle_references(
|
|||
let line_index = world.analysis().file_line_index(file_id);
|
||||
let offset = params.position.conv_with(&line_index);
|
||||
|
||||
let refs = world
|
||||
.analysis()
|
||||
.find_all_refs(FilePosition { file_id, offset })?;
|
||||
let refs = world.analysis().find_all_refs(FilePosition { file_id, offset })?;
|
||||
|
||||
Ok(Some(
|
||||
refs.into_iter()
|
||||
.filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok())
|
||||
.collect(),
|
||||
refs.into_iter().filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()).collect(),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -540,9 +520,7 @@ pub fn handle_formatting(
|
|||
|
||||
use std::process;
|
||||
let mut rustfmt = process::Command::new("rustfmt");
|
||||
rustfmt
|
||||
.stdin(process::Stdio::piped())
|
||||
.stdout(process::Stdio::piped());
|
||||
rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped());
|
||||
|
||||
if let Ok(path) = params.text_document.uri.to_file_path() {
|
||||
if let Some(parent) = path.parent() {
|
||||
|
@ -582,10 +560,7 @@ pub fn handle_code_action(
|
|||
let line_index = world.analysis().file_line_index(file_id);
|
||||
let range = params.range.conv_with(&line_index);
|
||||
|
||||
let assists = world
|
||||
.analysis()
|
||||
.assists(FileRange { file_id, range })?
|
||||
.into_iter();
|
||||
let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter();
|
||||
let fixes = world
|
||||
.analysis()
|
||||
.diagnostics(file_id)?
|
||||
|
@ -720,18 +695,11 @@ pub fn handle_code_lens_resolve(world: ServerWorld, code_lens: CodeLens) -> Resu
|
|||
to_value(locations).unwrap(),
|
||||
]),
|
||||
};
|
||||
Ok(CodeLens {
|
||||
range: code_lens.range,
|
||||
command: Some(cmd),
|
||||
data: None,
|
||||
})
|
||||
Ok(CodeLens { range: code_lens.range, command: Some(cmd), data: None })
|
||||
}
|
||||
None => Ok(CodeLens {
|
||||
range: code_lens.range,
|
||||
command: Some(Command {
|
||||
title: "Error".into(),
|
||||
..Default::default()
|
||||
}),
|
||||
command: Some(Command { title: "Error".into(), ..Default::default() }),
|
||||
data: None,
|
||||
}),
|
||||
}
|
||||
|
@ -744,16 +712,11 @@ pub fn handle_document_highlight(
|
|||
let file_id = params.text_document.try_conv_with(&world)?;
|
||||
let line_index = world.analysis().file_line_index(file_id);
|
||||
|
||||
let refs = world
|
||||
.analysis()
|
||||
.find_all_refs(params.try_conv_with(&world)?)?;
|
||||
let refs = world.analysis().find_all_refs(params.try_conv_with(&world)?)?;
|
||||
|
||||
Ok(Some(
|
||||
refs.into_iter()
|
||||
.map(|r| DocumentHighlight {
|
||||
range: r.1.conv_with(&line_index),
|
||||
kind: None,
|
||||
})
|
||||
.map(|r| DocumentHighlight { range: r.1.conv_with(&line_index), kind: None })
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
|
@ -785,10 +748,7 @@ pub fn publish_decorations(
|
|||
file_id: FileId,
|
||||
) -> Result<req::PublishDecorationsParams> {
|
||||
let uri = world.file_id_to_uri(file_id)?;
|
||||
Ok(req::PublishDecorationsParams {
|
||||
uri,
|
||||
decorations: highlight(&world, file_id)?,
|
||||
})
|
||||
Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? })
|
||||
}
|
||||
|
||||
fn highlight(world: &ServerWorld, file_id: FileId) -> Result<Vec<Decoration>> {
|
||||
|
@ -797,10 +757,7 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result<Vec<Decoration>> {
|
|||
.analysis()
|
||||
.highlight(file_id)?
|
||||
.into_iter()
|
||||
.map(|h| Decoration {
|
||||
range: h.range.conv_with(&line_index),
|
||||
tag: h.tag,
|
||||
})
|
||||
.map(|h| Decoration { range: h.range.conv_with(&line_index), tag: h.tag })
|
||||
.collect();
|
||||
Ok(res)
|
||||
}
|
||||
|
|
|
@ -7,9 +7,7 @@ pub struct Subscriptions {
|
|||
|
||||
impl Subscriptions {
|
||||
pub fn new() -> Subscriptions {
|
||||
Subscriptions {
|
||||
subs: FxHashSet::default(),
|
||||
}
|
||||
Subscriptions { subs: FxHashSet::default() }
|
||||
}
|
||||
pub fn add_sub(&mut self, file_id: FileId) {
|
||||
self.subs.insert(file_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue