aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry <[email protected]>2020-08-14 19:43:34 +0100
committerDmitry <[email protected]>2020-08-14 20:37:43 +0100
commit73315c9168901ef6d676f017daaa9b4976380c03 (patch)
tree0fae548ddc8dbf3fdfd553e4020db8e6826c8d84
parent178c3e135a2a249692f7784712492e7884ae0c00 (diff)
synchronizing changes
-rw-r--r--crates/hir/src/has_source.rs2
-rw-r--r--crates/ide/src/completion.rs6
-rw-r--r--crates/ide/src/completion/complete_attribute.rs23
-rw-r--r--crates/ide/src/completion/unstable_feature_descriptor.rs (renamed from crates/ra_ide/src/completion/unstable_feature_descriptor.rs)0
-rw-r--r--xtask/src/codegen.rs8
-rw-r--r--xtask/src/codegen/gen_unstable_future_descriptor.rs3
6 files changed, 28 insertions, 14 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index a50d4ff02..3bad2338a 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -1,4 +1,4 @@
1//! FIXME: write short doc here 1//! Provides set of implementation for hir's objects that allows get back location in file.
2 2
3use either::Either; 3use either::Either;
4use hir_def::{ 4use hir_def::{
diff --git a/crates/ide/src/completion.rs b/crates/ide/src/completion.rs
index 7fb4d687e..51dbac078 100644
--- a/crates/ide/src/completion.rs
+++ b/crates/ide/src/completion.rs
@@ -18,6 +18,7 @@ mod complete_unqualified_path;
18mod complete_postfix; 18mod complete_postfix;
19mod complete_macro_in_item_position; 19mod complete_macro_in_item_position;
20mod complete_trait_impl; 20mod complete_trait_impl;
21mod unstable_feature_descriptor;
21 22
22use ide_db::RootDatabase; 23use ide_db::RootDatabase;
23 24
@@ -29,6 +30,11 @@ use crate::{
29 FilePosition, 30 FilePosition,
30}; 31};
31 32
33//FIXME: cyclic imports caused by xtask generation, this should be better
34use crate::completion::{
35 complete_attribute::LintCompletion, unstable_feature_descriptor::UNSTABLE_FEATURE_DESCRIPTOR,
36};
37
32pub use crate::completion::{ 38pub use crate::completion::{
33 completion_config::CompletionConfig, 39 completion_config::CompletionConfig,
34 completion_item::{CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat}, 40 completion_item::{CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat},
diff --git a/crates/ide/src/completion/complete_attribute.rs b/crates/ide/src/completion/complete_attribute.rs
index 603d935de..b193c6387 100644
--- a/crates/ide/src/completion/complete_attribute.rs
+++ b/crates/ide/src/completion/complete_attribute.rs
@@ -9,6 +9,7 @@ use syntax::{ast, AstNode, SyntaxKind};
9use crate::completion::{ 9use crate::completion::{
10 completion_context::CompletionContext, 10 completion_context::CompletionContext,
11 completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}, 11 completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions},
12 UNSTABLE_FEATURE_DESCRIPTOR,
12}; 13};
13 14
14pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 15pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
@@ -17,12 +18,15 @@ pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
17 (Some(path), Some(token_tree)) if path.to_string() == "derive" => { 18 (Some(path), Some(token_tree)) if path.to_string() == "derive" => {
18 complete_derive(acc, ctx, token_tree) 19 complete_derive(acc, ctx, token_tree)
19 } 20 }
21 (Some(path), Some(token_tree)) if path.to_string() == "feature" => {
22 complete_lint(acc, ctx, token_tree, UNSTABLE_FEATURE_DESCRIPTOR)
23 }
20 (Some(path), Some(token_tree)) 24 (Some(path), Some(token_tree))
21 if ["allow", "warn", "deny", "forbid"] 25 if ["allow", "warn", "deny", "forbid"]
22 .iter() 26 .iter()
23 .any(|lint_level| lint_level == &path.to_string()) => 27 .any(|lint_level| lint_level == &path.to_string()) =>
24 { 28 {
25 complete_lint(acc, ctx, token_tree) 29 complete_lint(acc, ctx, token_tree, DEFAULT_LINT_COMPLETIONS)
26 } 30 }
27 (_, Some(_token_tree)) => {} 31 (_, Some(_token_tree)) => {}
28 _ => complete_attribute_start(acc, ctx, attribute), 32 _ => complete_attribute_start(acc, ctx, attribute),
@@ -162,9 +166,14 @@ fn complete_derive(acc: &mut Completions, ctx: &CompletionContext, derive_input:
162 } 166 }
163} 167}
164 168
165fn complete_lint(acc: &mut Completions, ctx: &CompletionContext, derive_input: ast::TokenTree) { 169fn complete_lint(
170 acc: &mut Completions,
171 ctx: &CompletionContext,
172 derive_input: ast::TokenTree,
173 lints_completions: &[LintCompletion],
174) {
166 if let Ok(existing_lints) = parse_comma_sep_input(derive_input) { 175 if let Ok(existing_lints) = parse_comma_sep_input(derive_input) {
167 for lint_completion in DEFAULT_LINT_COMPLETIONS 176 for lint_completion in lints_completions
168 .into_iter() 177 .into_iter()
169 .filter(|completion| !existing_lints.contains(completion.label)) 178 .filter(|completion| !existing_lints.contains(completion.label))
170 { 179 {
@@ -228,7 +237,7 @@ fn get_derive_names_in_scope(ctx: &CompletionContext) -> FxHashSet<String> {
228 result 237 result
229} 238}
230 239
231struct DeriveCompletion { 240pub(crate) struct DeriveCompletion {
232 label: &'static str, 241 label: &'static str,
233 dependencies: &'static [&'static str], 242 dependencies: &'static [&'static str],
234} 243}
@@ -248,9 +257,9 @@ const DEFAULT_DERIVE_COMPLETIONS: &[DeriveCompletion] = &[
248 DeriveCompletion { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] }, 257 DeriveCompletion { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] },
249]; 258];
250 259
251struct LintCompletion { 260pub(crate) struct LintCompletion {
252 label: &'static str, 261 pub(crate) label: &'static str,
253 description: &'static str, 262 pub(crate) description: &'static str,
254} 263}
255 264
256#[rustfmt::skip] 265#[rustfmt::skip]
diff --git a/crates/ra_ide/src/completion/unstable_feature_descriptor.rs b/crates/ide/src/completion/unstable_feature_descriptor.rs
index 14cd583ea..14cd583ea 100644
--- a/crates/ra_ide/src/completion/unstable_feature_descriptor.rs
+++ b/crates/ide/src/completion/unstable_feature_descriptor.rs
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 950dd61b2..4b2b614fa 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -29,9 +29,9 @@ pub use self::{
29// Directory used by xtask 29// Directory used by xtask
30const STORAGE: &str = ".xtask"; 30const STORAGE: &str = ".xtask";
31 31
32const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; 32const GRAMMAR_DIR: &str = "crates/parser/src/grammar";
33const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok"; 33const OK_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/ok";
34const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err"; 34const ERR_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/err";
35 35
36const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; 36const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs";
37const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs"; 37const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs";
@@ -41,7 +41,7 @@ const ASSISTS_DIR: &str = "crates/assists/src/handlers";
41const ASSISTS_TESTS: &str = "crates/assists/src/tests/generated.rs"; 41const ASSISTS_TESTS: &str = "crates/assists/src/tests/generated.rs";
42 42
43const REPOSITORY_URL: &str = "https://github.com/rust-lang/rust"; 43const REPOSITORY_URL: &str = "https://github.com/rust-lang/rust";
44const UNSTABLE_FEATURE: &str = "crates/ra_ide/src/completion/unstable_feature_descriptor.rs"; 44const UNSTABLE_FEATURE: &str = "crates/ide/src/completion/unstable_feature_descriptor.rs";
45const REPO_PATH: &str = "src/doc/unstable-book/src"; 45const REPO_PATH: &str = "src/doc/unstable-book/src";
46 46
47#[derive(Debug, PartialEq, Eq, Clone, Copy)] 47#[derive(Debug, PartialEq, Eq, Clone, Copy)]
diff --git a/xtask/src/codegen/gen_unstable_future_descriptor.rs b/xtask/src/codegen/gen_unstable_future_descriptor.rs
index 3f3beb591..f220f85d3 100644
--- a/xtask/src/codegen/gen_unstable_future_descriptor.rs
+++ b/xtask/src/codegen/gen_unstable_future_descriptor.rs
@@ -15,8 +15,7 @@ fn generate_descriptor(src_dir: PathBuf) -> Result<TokenStream> {
15 .filter_map(|e| e.ok()) 15 .filter_map(|e| e.ok())
16 .filter(|entry| { 16 .filter(|entry| {
17 // Get all `.md ` files 17 // Get all `.md ` files
18 entry.file_type().is_file() 18 entry.file_type().is_file() && entry.path().extension().unwrap_or_default() == "md"
19 && entry.path().extension().unwrap_or_default() == "md"
20 }) 19 })
21 .collect::<Vec<_>>(); 20 .collect::<Vec<_>>();
22 21