File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
crates/ide-completion/src Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,7 @@ impl<'a> CompletionContext<'a> {
326
326
matches ! ( self . completion_location, Some ( ImmediateLocation :: ItemList ) )
327
327
}
328
328
329
+ // FIXME: This shouldn't exist
329
330
pub ( crate ) fn expects_generic_arg ( & self ) -> bool {
330
331
matches ! ( self . completion_location, Some ( ImmediateLocation :: GenericArgList ( _) ) )
331
332
}
@@ -395,10 +396,6 @@ impl<'a> CompletionContext<'a> {
395
396
matches ! ( self . path_context( ) , Some ( PathCompletionCtx { kind: PathKind :: Type , .. } ) )
396
397
}
397
398
398
- pub ( crate ) fn path_is_call ( & self ) -> bool {
399
- self . path_context ( ) . map_or ( false , |it| it. has_call_parens )
400
- }
401
-
402
399
pub ( crate ) fn is_non_trivial_path ( & self ) -> bool {
403
400
matches ! (
404
401
self . path_context( ) ,
@@ -417,10 +414,6 @@ impl<'a> CompletionContext<'a> {
417
414
self . path_context ( ) . map ( |it| it. kind )
418
415
}
419
416
420
- pub ( crate ) fn is_immediately_after_macro_bang ( & self ) -> bool {
421
- self . token . kind ( ) == BANG && self . token . parent ( ) . map_or ( false , |it| it. kind ( ) == MACRO_CALL )
422
- }
423
-
424
417
/// Checks if an item is visible and not `doc(hidden)` at the completion site.
425
418
pub ( crate ) fn is_visible < I > ( & self , item : & I ) -> Visible
426
419
where
Original file line number Diff line number Diff line change @@ -65,6 +65,19 @@ impl<'a> RenderContext<'a> {
65
65
}
66
66
}
67
67
68
+ fn is_immediately_after_macro_bang ( & self ) -> bool {
69
+ self . completion . token . kind ( ) == SyntaxKind :: BANG
70
+ && self
71
+ . completion
72
+ . token
73
+ . parent ( )
74
+ . map_or ( false , |it| it. kind ( ) == SyntaxKind :: MACRO_CALL )
75
+ }
76
+
77
+ pub ( crate ) fn path_is_call ( & self ) -> bool {
78
+ self . completion . path_context ( ) . map_or ( false , |it| it. has_call_parens )
79
+ }
80
+
68
81
fn is_deprecated ( & self , def : impl HasAttrs ) -> bool {
69
82
let attrs = def. attrs ( self . db ( ) ) ;
70
83
attrs. by_key ( "deprecated" ) . exists ( ) || attrs. by_key ( "rustc_deprecated" ) . exists ( )
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ fn render(
20
20
name : hir:: Name ,
21
21
macro_ : hir:: Macro ,
22
22
) -> Builder {
23
- let source_range = if completion . is_immediately_after_macro_bang ( ) {
23
+ let source_range = if ctx . is_immediately_after_macro_bang ( ) {
24
24
cov_mark:: hit!( completes_macro_call_if_cursor_at_bang_token) ;
25
25
completion. token . parent ( ) . map_or_else ( || ctx. source_range ( ) , |it| it. text_range ( ) )
26
26
} else {
@@ -52,7 +52,7 @@ fn render(
52
52
53
53
let name = & * name;
54
54
match ctx. snippet_cap ( ) {
55
- Some ( cap) if needs_bang && !completion . path_is_call ( ) => {
55
+ Some ( cap) if needs_bang && !ctx . path_is_call ( ) => {
56
56
let snippet = format ! ( "{}!{}$0{}" , name, bra, ket) ;
57
57
let lookup = banged_name ( name) ;
58
58
item. insert_snippet ( cap, snippet) . lookup_by ( lookup) ;
You can’t perform that action at this time.
0 commit comments