diff options
author | Dmitry <[email protected]> | 2020-08-14 19:43:34 +0100 |
---|---|---|
committer | Dmitry <[email protected]> | 2020-08-14 20:37:43 +0100 |
commit | 73315c9168901ef6d676f017daaa9b4976380c03 (patch) | |
tree | 0fae548ddc8dbf3fdfd553e4020db8e6826c8d84 | |
parent | 178c3e135a2a249692f7784712492e7884ae0c00 (diff) |
synchronizing changes
-rw-r--r-- | crates/hir/src/has_source.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/completion.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/completion/complete_attribute.rs | 23 | ||||
-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.rs | 8 | ||||
-rw-r--r-- | xtask/src/codegen/gen_unstable_future_descriptor.rs | 3 |
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 | ||
3 | use either::Either; | 3 | use either::Either; |
4 | use hir_def::{ | 4 | use 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; | |||
18 | mod complete_postfix; | 18 | mod complete_postfix; |
19 | mod complete_macro_in_item_position; | 19 | mod complete_macro_in_item_position; |
20 | mod complete_trait_impl; | 20 | mod complete_trait_impl; |
21 | mod unstable_feature_descriptor; | ||
21 | 22 | ||
22 | use ide_db::RootDatabase; | 23 | use 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 | ||
34 | use crate::completion::{ | ||
35 | complete_attribute::LintCompletion, unstable_feature_descriptor::UNSTABLE_FEATURE_DESCRIPTOR, | ||
36 | }; | ||
37 | |||
32 | pub use crate::completion::{ | 38 | pub 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}; | |||
9 | use crate::completion::{ | 9 | use 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 | ||
14 | pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { | 15 | pub(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 | ||
165 | fn complete_lint(acc: &mut Completions, ctx: &CompletionContext, derive_input: ast::TokenTree) { | 169 | fn 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 | ||
231 | struct DeriveCompletion { | 240 | pub(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 | ||
251 | struct LintCompletion { | 260 | pub(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 |
30 | const STORAGE: &str = ".xtask"; | 30 | const STORAGE: &str = ".xtask"; |
31 | 31 | ||
32 | const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; | 32 | const GRAMMAR_DIR: &str = "crates/parser/src/grammar"; |
33 | const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok"; | 33 | const OK_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/ok"; |
34 | const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err"; | 34 | const ERR_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/err"; |
35 | 35 | ||
36 | const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; | 36 | const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; |
37 | const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs"; | 37 | const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs"; |
@@ -41,7 +41,7 @@ const ASSISTS_DIR: &str = "crates/assists/src/handlers"; | |||
41 | const ASSISTS_TESTS: &str = "crates/assists/src/tests/generated.rs"; | 41 | const ASSISTS_TESTS: &str = "crates/assists/src/tests/generated.rs"; |
42 | 42 | ||
43 | const REPOSITORY_URL: &str = "https://github.com/rust-lang/rust"; | 43 | const REPOSITORY_URL: &str = "https://github.com/rust-lang/rust"; |
44 | const UNSTABLE_FEATURE: &str = "crates/ra_ide/src/completion/unstable_feature_descriptor.rs"; | 44 | const UNSTABLE_FEATURE: &str = "crates/ide/src/completion/unstable_feature_descriptor.rs"; |
45 | const REPO_PATH: &str = "src/doc/unstable-book/src"; | 45 | const 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 | ||