This commit is contained in:
Aleksey Kladov 2020-06-27 12:07:48 +02:00
parent 18a6dd4635
commit 4e3e8d1ab2

View file

@ -1,21 +1,18 @@
//! Runs completion for testing purposes. //! Runs completion for testing purposes.
use hir::Semantics;
use ra_syntax::{AstNode, NodeOrToken, SyntaxElement};
use crate::{ use crate::{
completion::{completion_item::CompletionKind, CompletionConfig}, completion::{completion_item::CompletionKind, CompletionConfig},
mock_analysis::analysis_and_position, mock_analysis::analysis_and_position,
CompletionItem, CompletionItem,
}; };
use hir::Semantics;
use ra_syntax::{AstNode, NodeOrToken, SyntaxElement};
pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
do_completion_with_options(code, kind, &CompletionConfig::default()) do_completion_with_options(code, kind, &CompletionConfig::default())
} }
pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String {
completion_list_with_options(code, kind, &CompletionConfig::default())
}
pub(crate) fn do_completion_with_options( pub(crate) fn do_completion_with_options(
code: &str, code: &str,
kind: CompletionKind, kind: CompletionKind,
@ -29,13 +26,8 @@ pub(crate) fn do_completion_with_options(
kind_completions kind_completions
} }
fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> { pub(crate) fn completion_list(code: &str, kind: CompletionKind) -> String {
let (analysis, position) = if code.contains("//-") { completion_list_with_options(code, kind, &CompletionConfig::default())
analysis_and_position(code)
} else {
analysis_and_position(code)
};
analysis.completions(options, position).unwrap().unwrap().into()
} }
pub(crate) fn completion_list_with_options( pub(crate) fn completion_list_with_options(
@ -65,3 +57,8 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -
}) })
.unwrap(); .unwrap();
} }
fn get_all_completion_items(code: &str, options: &CompletionConfig) -> Vec<CompletionItem> {
let (analysis, position) = analysis_and_position(code);
analysis.completions(options, position).unwrap().unwrap().into()
}