1
1
//! Runs completion for testing purposes.
2
2
3
+ use hir:: Semantics ;
4
+ use ra_syntax:: { AstNode , NodeOrToken , SyntaxElement } ;
5
+
3
6
use crate :: {
4
7
completion:: { completion_item:: CompletionKind , CompletionConfig } ,
5
8
mock_analysis:: analysis_and_position,
6
9
CompletionItem ,
7
10
} ;
8
- use hir:: Semantics ;
9
- use ra_syntax:: { AstNode , NodeOrToken , SyntaxElement } ;
10
11
11
12
pub ( crate ) fn do_completion ( code : & str , kind : CompletionKind ) -> Vec < CompletionItem > {
12
13
do_completion_with_options ( code, kind, & CompletionConfig :: default ( ) )
13
14
}
14
15
15
- pub ( crate ) fn completion_list ( code : & str , kind : CompletionKind ) -> String {
16
- completion_list_with_options ( code, kind, & CompletionConfig :: default ( ) )
17
- }
18
-
19
16
pub ( crate ) fn do_completion_with_options (
20
17
code : & str ,
21
18
kind : CompletionKind ,
@@ -29,13 +26,8 @@ pub(crate) fn do_completion_with_options(
29
26
kind_completions
30
27
}
31
28
32
- fn get_all_completion_items ( code : & str , options : & CompletionConfig ) -> Vec < CompletionItem > {
33
- let ( analysis, position) = if code. contains ( "//-" ) {
34
- analysis_and_position ( code)
35
- } else {
36
- analysis_and_position ( code)
37
- } ;
38
- analysis. completions ( options, position) . unwrap ( ) . unwrap ( ) . into ( )
29
+ pub ( crate ) fn completion_list ( code : & str , kind : CompletionKind ) -> String {
30
+ completion_list_with_options ( code, kind, & CompletionConfig :: default ( ) )
39
31
}
40
32
41
33
pub ( crate ) fn completion_list_with_options (
@@ -65,3 +57,8 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -
65
57
} )
66
58
. unwrap ( ) ;
67
59
}
60
+
61
+ fn get_all_completion_items ( code : & str , options : & CompletionConfig ) -> Vec < CompletionItem > {
62
+ let ( analysis, position) = analysis_and_position ( code) ;
63
+ analysis. completions ( options, position) . unwrap ( ) . unwrap ( ) . into ( )
64
+ }
0 commit comments