Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Apr 11, 2020
1 parent 6e5294d commit f27842b
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/citeproc/ris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Into<Reference> for RisReference {

if let Some(place) = self.place {
ordinary.insert(Variable::EventPlace, place.clone());
ordinary.insert(Variable::PublisherPlace, place.clone());
ordinary.insert(Variable::PublisherPlace, place);
}

if let Some(abstrct) = self.abstrct {
Expand Down
115 changes: 55 additions & 60 deletions src/completion/latex/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,44 @@ impl FeatureProvider for LatexUserCommandCompletionProvider {

#[boxed]
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
combinators::command(req, |current_cmd_node| {
async move {
let current_cmd = req
.current()
.content
.as_latex()
.unwrap()
.tree
.as_command(current_cmd_node)
.unwrap();

let mut items = Vec::new();
for doc in req.related() {
if let DocumentContent::Latex(table) = &doc.content {
table
.commands
.iter()
.filter(|cmd_node| **cmd_node != current_cmd_node)
.map(|cmd_node| {
let cmd = table.tree.as_command(*cmd_node).unwrap();
cmd.name.text()[1..].to_owned()
})
.unique()
.map(|cmd| {
let text_edit =
TextEdit::new(current_cmd.short_name_range(), cmd.clone());
factory::command(
req,
cmd,
None,
None,
text_edit,
&LatexComponentId::User,
)
})
.for_each(|item| items.push(item));
}
combinators::command(req, |current_cmd_node| async move {
let current_cmd = req
.current()
.content
.as_latex()
.unwrap()
.tree
.as_command(current_cmd_node)
.unwrap();

let mut items = Vec::new();
for doc in req.related() {
if let DocumentContent::Latex(table) = &doc.content {
table
.commands
.iter()
.filter(|cmd_node| **cmd_node != current_cmd_node)
.map(|cmd_node| {
let cmd = table.tree.as_command(*cmd_node).unwrap();
cmd.name.text()[1..].to_owned()
})
.unique()
.map(|cmd| {
let text_edit =
TextEdit::new(current_cmd.short_name_range(), cmd.clone());
factory::command(
req,
cmd,
None,
None,
text_edit,
&LatexComponentId::User,
)
})
.for_each(|item| items.push(item));
}
items
}
items
})
.await
}
Expand All @@ -72,31 +70,28 @@ impl FeatureProvider for LatexUserEnvironmentCompletionProvider {

#[boxed]
async fn execute<'a>(&'a self, req: &'a FeatureRequest<Self::Params>) -> Self::Output {
combinators::environment(req, |ctx| {
async move {
let mut items = Vec::new();
for doc in req.related() {
if let DocumentContent::Latex(table) = &doc.content {
for env in &table.environments {
if (env.left.parent == ctx.node || env.right.parent == ctx.node)
&& doc.uri == req.current().uri
{
continue;
}

if let Some(item) = Self::make_item(req, &table, &env.left, ctx.range) {
items.push(item);
}

if let Some(item) = Self::make_item(req, &table, &env.right, ctx.range)
{
items.push(item);
}
combinators::environment(req, |ctx| async move {
let mut items = Vec::new();
for doc in req.related() {
if let DocumentContent::Latex(table) = &doc.content {
for env in &table.environments {
if (env.left.parent == ctx.node || env.right.parent == ctx.node)
&& doc.uri == req.current().uri
{
continue;
}

if let Some(item) = Self::make_item(req, &table, env.left, ctx.range) {
items.push(item);
}

if let Some(item) = Self::make_item(req, &table, env.right, ctx.range) {
items.push(item);
}
}
}
items
}
items
})
.await
}
Expand All @@ -106,7 +101,7 @@ impl LatexUserEnvironmentCompletionProvider {
fn make_item(
req: &FeatureRequest<CompletionParams>,
table: &latex::SymbolTable,
delim: &latex::EnvironmentDelimiter,
delim: latex::EnvironmentDelimiter,
name_range: Range,
) -> Option<CompletionItem> {
delim.name(&table.tree).map(|name| {
Expand Down
5 changes: 2 additions & 3 deletions src/diagnostics/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ impl BuildDiagnosticsProvider {
let log_uris = snapshot
.resolve_aux_targets(tex_uri, options, current_dir, "log")
.unwrap_or_default();
for log_path in log_uris
if let Some(log_path) = log_uris
.into_iter()
.filter(|uri| uri.scheme() == "file")
.filter_map(|uri| uri.to_file_path().ok())
.filter(|path| path.exists())
.next()
.find(|path| path.exists())
{
let modified = fs::metadata(&log_path).await?.modified()?;
let mut log_files = self.log_files.lock().await;
Expand Down
2 changes: 1 addition & 1 deletion src/hover/latex/citation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl LatexCitationHoverProvider {
let key = Self::get_key(req)?;
for tree in req
.related()
.into_iter()
.iter()
.filter_map(|doc| doc.content.as_bibtex())
{
for entry in tree
Expand Down
4 changes: 2 additions & 2 deletions src/outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl OutlineContext {
let caption = table
.captions
.iter()
.find(|cap| table.is_direct_child(caption_env, table.tree.range(cap.parent).start))?;
.find(|cap| table.is_direct_child(*caption_env, table.tree.range(cap.parent).start))?;

let caption_text = table.tree.print_group_content(
caption.parent,
Expand Down Expand Up @@ -360,7 +360,7 @@ impl OutlineContext {
let mut item_nodes: Vec<_> = table
.items
.iter()
.filter(|item| table.is_enum_item(enumeration, **item))
.filter(|item| table.is_enum_item(*enumeration, **item))
.map(|item| LatexItemNode {
item: *item,
range: Range::default(),
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/latex_section/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ pub fn symbols(view: &DocumentView, table: &latex::SymbolTable) -> Vec<LatexSymb
.environments
.iter()
.filter(|env| env.left.is_enum(&table.tree))
.map(|enumeration| make_symbol(view, table, enumeration))
.map(|enumeration| make_symbol(view, table, *enumeration))
.collect()
}

fn make_symbol(
view: &DocumentView,
table: &latex::SymbolTable,
enumeration: &latex::Environment,
enumeration: latex::Environment,
) -> LatexSymbol {
let name = titlecase(enumeration.left.name(&table.tree).unwrap().text());

Expand Down
4 changes: 2 additions & 2 deletions src/symbol/latex_section/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn make_symbol(
let env = table
.environments
.iter()
.find(|env| table.is_direct_child(env, table.tree.range(caption.parent).start))?;
.find(|env| table.is_direct_child(**env, table.tree.range(caption.parent).start))?;

let text = table.tree.print_group_content(
caption.parent,
Expand All @@ -36,7 +36,7 @@ fn make_symbol(
.map(latex::Token::text)
.and_then(OutlineCaptionKind::parse)?;

let label = table.find_label_by_environment(env);
let label = table.find_label_by_environment(*env);
let number = label.and_then(|label| OutlineContext::find_number(view, table, *label));

let name = match &number {
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/latex_section/theorem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ pub fn symbols(view: &DocumentView, table: &latex::SymbolTable) -> Vec<LatexSymb
table
.environments
.iter()
.filter_map(|env| make_symbol(view, table, env))
.filter_map(|env| make_symbol(view, table, *env))
.collect()
}

fn make_symbol(
view: &DocumentView,
main_table: &latex::SymbolTable,
env: &latex::Environment,
env: latex::Environment,
) -> Option<LatexSymbol> {
let env_name = env.left.name(&main_table.tree).map(latex::Token::text)?;

Expand Down
2 changes: 1 addition & 1 deletion src/symbol/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl LatexSymbol {
deprecated: Some(self.deprecated),
kind: self.kind.into(),
container_name: None,
location: Location::new(uri.clone().into(), self.full_range),
location: Location::new(uri.into(), self.full_range),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/syntax/latex/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl SymbolTable {
}
}

pub fn is_direct_child(&self, env: &Environment, pos: Position) -> bool {
pub fn is_direct_child(&self, env: Environment, pos: Position) -> bool {
env.range(&self.tree).contains(pos)
&& !self
.environments
Expand All @@ -136,7 +136,7 @@ impl SymbolTable {
.any(|e| e.range(&self.tree).contains(pos))
}

pub fn is_enum_item(&self, enumeration: &Environment, item: Item) -> bool {
pub fn is_enum_item(&self, enumeration: Environment, item: Item) -> bool {
let item_range = self.tree.range(item.parent);
enumeration.range(&self.tree).contains(item_range.start)
&& !self
Expand All @@ -160,7 +160,7 @@ impl SymbolTable {
.find(|label| range.contains(self.tree.range(label.parent).start))
}

pub fn find_label_by_environment(&self, env: &Environment) -> Option<&Label> {
pub fn find_label_by_environment(&self, env: Environment) -> Option<&Label> {
self.labels
.iter()
.filter(|label| label.kind == LatexLabelKind::Definition)
Expand Down
2 changes: 1 addition & 1 deletion src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl TestBedBuilder {
handler: MessageHandler {
client: test_client,
server: test_server,
output: tx1.clone(),
output: tx1,
},
}
}
Expand Down

0 comments on commit f27842b

Please sign in to comment.