mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Don't render ()
in calls to assoc functions
This commit is contained in:
parent
982f72c022
commit
e503ffe9ff
3 changed files with 42 additions and 6 deletions
|
@ -137,6 +137,13 @@ impl<'a> CompletionContext<'a> {
|
||||||
};
|
};
|
||||||
if let Some(segment) = ast::PathSegment::cast(parent) {
|
if let Some(segment) = ast::PathSegment::cast(parent) {
|
||||||
let path = segment.parent_path();
|
let path = segment.parent_path();
|
||||||
|
self.is_call = path
|
||||||
|
.syntax()
|
||||||
|
.parent()
|
||||||
|
.and_then(ast::PathExpr::cast)
|
||||||
|
.and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast))
|
||||||
|
.is_some();
|
||||||
|
|
||||||
if let Some(mut path) = hir::Path::from_ast(path) {
|
if let Some(mut path) = hir::Path::from_ast(path) {
|
||||||
if !path.is_ident() {
|
if !path.is_ident() {
|
||||||
path.segments.pop().unwrap();
|
path.segments.pop().unwrap();
|
||||||
|
@ -176,12 +183,6 @@ impl<'a> CompletionContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.is_call = path
|
|
||||||
.syntax()
|
|
||||||
.parent()
|
|
||||||
.and_then(ast::PathExpr::cast)
|
|
||||||
.and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast))
|
|
||||||
.is_some()
|
|
||||||
}
|
}
|
||||||
if let Some(field_expr) = ast::FieldExpr::cast(parent) {
|
if let Some(field_expr) = ast::FieldExpr::cast(parent) {
|
||||||
// The receiver comes before the point of insertion of the fake
|
// The receiver comes before the point of insertion of the fake
|
||||||
|
|
|
@ -427,6 +427,17 @@ mod tests {
|
||||||
frob<|>();
|
frob<|>();
|
||||||
}
|
}
|
||||||
",
|
",
|
||||||
|
);
|
||||||
|
check_reference_completion(
|
||||||
|
"dont_render_function_parens_if_already_call_assoc_fn",
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
struct Foo {}
|
||||||
|
impl Foo { fn new() -> Foo {} }
|
||||||
|
fn main() {
|
||||||
|
Foo::ne<|>();
|
||||||
|
}
|
||||||
|
",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
created: "2019-02-17T18:29:14.513213526Z"
|
||||||
|
creator: insta@0.6.2
|
||||||
|
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||||
|
expression: kind_completions
|
||||||
|
---
|
||||||
|
[
|
||||||
|
CompletionItem {
|
||||||
|
completion_kind: Reference,
|
||||||
|
label: "new",
|
||||||
|
kind: Some(
|
||||||
|
Method
|
||||||
|
),
|
||||||
|
detail: Some(
|
||||||
|
"fn new() -> Foo"
|
||||||
|
),
|
||||||
|
documentation: None,
|
||||||
|
lookup: None,
|
||||||
|
insert_text: None,
|
||||||
|
insert_text_format: PlainText,
|
||||||
|
source_range: [67; 69),
|
||||||
|
text_edit: None
|
||||||
|
}
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue