From 0e1cda3079eb9936dcf8acec3e47bad48c5ccc58 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 18:06:14 +0200 Subject: Minor --- crates/ide/src/completion/completion_context.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 047ecd9d7..09440334d 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -9,15 +9,21 @@ use syntax::{ SyntaxKind::*, SyntaxNode, SyntaxToken, TextRange, TextSize, }; +use test_utils::mark; use text_edit::Indel; -use super::patterns::{ - has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, - has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, - has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, +use crate::{ + call_info::ActiveParameter, + completion::{ + patterns::{ + has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, + has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, + has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, + }, + CompletionConfig, + }, + FilePosition, }; -use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition}; -use test_utils::mark; /// `CompletionContext` is created early during completion to figure out, where /// exactly is the cursor, syntax-wise. -- cgit v1.2.3 From ef462ed6af7ae8e0d30894baefe6ba1ff49aab8f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 18:28:23 +0200 Subject: Better recovery in `use foo::;` --- crates/parser/src/grammar/items.rs | 16 ++++++++++++++-- .../test_data/parser/inline/err/0015_empty_segment.rast | 8 +++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index b2f7cc21f..8fd8f3b80 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -27,8 +27,20 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { } pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ - FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, - CRATE_KW, USE_KW, MACRO_KW + FN_KW, + STRUCT_KW, + ENUM_KW, + IMPL_KW, + TRAIT_KW, + CONST_KW, + STATIC_KW, + LET_KW, + MOD_KW, + PUB_KW, + CRATE_KW, + USE_KW, + MACRO_KW, + T![;], ]; pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { diff --git a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast index 2f59d0606..e872526d9 100644 --- a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast +++ b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast @@ -2,14 +2,12 @@ SOURCE_FILE@0..13 USE@0..12 USE_KW@0..3 "use" WHITESPACE@3..4 " " - USE_TREE@4..12 - PATH@4..12 + USE_TREE@4..11 + PATH@4..11 PATH@4..9 PATH_SEGMENT@4..9 CRATE_KW@4..9 "crate" COLON2@9..11 "::" - ERROR@11..12 - SEMICOLON@11..12 ";" + SEMICOLON@11..12 ";" WHITESPACE@12..13 "\n" error 11..11: expected identifier -error 12..12: expected SEMICOLON -- cgit v1.2.3