aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-10 09:11:05 +0100
committerAleksey Kladov <[email protected]>2020-04-10 15:10:28 +0100
commitc8b4c36f8161d34c8145a49965efee4514275989 (patch)
tree3b0a50994d76571cdfb2318f2799e6161962974c /crates
parentf89f2e38855f5b47f68758e98139aa962cb7a01d (diff)
Semicolon token
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/handlers/introduce_variable.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs2
-rw-r--r--crates/ra_ide/src/typing.rs2
-rw-r--r--crates/ra_syntax/src/ast/edit.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs44
5 files changed, 38 insertions, 16 deletions
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs
index ab6bdf6bb..8d0f7e922 100644
--- a/crates/ra_assists/src/handlers/introduce_variable.rs
+++ b/crates/ra_assists/src/handlers/introduce_variable.rs
@@ -61,7 +61,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> {
61 }; 61 };
62 if is_full_stmt { 62 if is_full_stmt {
63 tested_by!(test_introduce_var_expr_stmt); 63 tested_by!(test_introduce_var_expr_stmt);
64 if full_stmt.unwrap().semi_token().is_none() { 64 if full_stmt.unwrap().semicolon_token().is_none() {
65 buf.push_str(";"); 65 buf.push_str(";");
66 } 66 }
67 edit.replace(expr.syntax().text_range(), buf); 67 edit.replace(expr.syntax().text_range(), buf);
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index e72ba52cf..afd538e4a 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -287,7 +287,7 @@ impl RawItemsCollector {
287 let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene); 287 let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene);
288 288
289 let ast_id = self.source_ast_id_map.ast_id(&module); 289 let ast_id = self.source_ast_id_map.ast_id(&module);
290 if module.semi_token().is_some() { 290 if module.semicolon_token().is_some() {
291 let item = 291 let item =
292 self.raw_items.modules.alloc(ModuleData::Declaration { name, visibility, ast_id }); 292 self.raw_items.modules.alloc(ModuleData::Declaration { name, visibility, ast_id });
293 self.push_item(current_module, attrs, RawItemKind::Module(item)); 293 self.push_item(current_module, attrs, RawItemKind::Module(item));
diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs
index 71d2bcb04..f55cd3bf5 100644
--- a/crates/ra_ide/src/typing.rs
+++ b/crates/ra_ide/src/typing.rs
@@ -63,7 +63,7 @@ fn on_char_typed_inner(
63fn on_eq_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> { 63fn on_eq_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> {
64 assert_eq!(file.syntax().text().char_at(offset), Some('=')); 64 assert_eq!(file.syntax().text().char_at(offset), Some('='));
65 let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?; 65 let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?;
66 if let_stmt.semi_token().is_some() { 66 if let_stmt.semicolon_token().is_some() {
67 return None; 67 return None;
68 } 68 }
69 if let Some(expr) = let_stmt.initializer() { 69 if let Some(expr) = let_stmt.initializer() {
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 3d428fab3..a01f6487d 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -32,9 +32,9 @@ impl ast::FnDef {
32 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 32 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
33 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 33 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
34 old_body.syntax().clone().into() 34 old_body.syntax().clone().into()
35 } else if let Some(semi) = self.semi_token() { 35 } else if let Some(semi) = self.semicolon_token() {
36 to_insert.push(make::tokens::single_space().into()); 36 to_insert.push(make::tokens::single_space().into());
37 semi.syntax.clone().into() 37 semi.into()
38 } else { 38 } else {
39 to_insert.push(make::tokens::single_space().into()); 39 to_insert.push(make::tokens::single_space().into());
40 to_insert.push(body.syntax().clone().into()); 40 to_insert.push(body.syntax().clone().into());
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 3b014e312..214e12918 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -58,7 +58,9 @@ impl FnDef {
58 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 58 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
59 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 59 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
60 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 60 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
61 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 61 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
62 support::token2(&self.syntax, T ! [ ; ])
63 }
62} 64}
63#[derive(Debug, Clone, PartialEq, Eq, Hash)] 65#[derive(Debug, Clone, PartialEq, Eq, Hash)]
64pub struct RetType { 66pub struct RetType {
@@ -102,7 +104,9 @@ impl ast::DocCommentsOwner for StructDef {}
102impl StructDef { 104impl StructDef {
103 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) } 105 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) }
104 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 106 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
105 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 107 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
108 support::token2(&self.syntax, T ! [ ; ])
109 }
106} 110}
107#[derive(Debug, Clone, PartialEq, Eq, Hash)] 111#[derive(Debug, Clone, PartialEq, Eq, Hash)]
108pub struct UnionDef { 112pub struct UnionDef {
@@ -328,7 +332,9 @@ impl ast::DocCommentsOwner for Module {}
328impl Module { 332impl Module {
329 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) } 333 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) }
330 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 334 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
331 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 335 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
336 support::token2(&self.syntax, T ! [ ; ])
337 }
332} 338}
333#[derive(Debug, Clone, PartialEq, Eq, Hash)] 339#[derive(Debug, Clone, PartialEq, Eq, Hash)]
334pub struct ItemList { 340pub struct ItemList {
@@ -379,7 +385,9 @@ impl ConstDef {
379 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) } 385 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
380 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 386 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
381 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 387 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
382 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 388 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
389 support::token2(&self.syntax, T ! [ ; ])
390 }
383} 391}
384#[derive(Debug, Clone, PartialEq, Eq, Hash)] 392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
385pub struct StaticDef { 393pub struct StaticDef {
@@ -407,7 +415,9 @@ impl StaticDef {
407 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) } 415 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
408 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 416 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
409 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 417 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
410 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 418 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
419 support::token2(&self.syntax, T ! [ ; ])
420 }
411} 421}
412#[derive(Debug, Clone, PartialEq, Eq, Hash)] 422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
413pub struct TypeAliasDef { 423pub struct TypeAliasDef {
@@ -437,7 +447,9 @@ impl TypeAliasDef {
437 pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) } 447 pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) }
438 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 448 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
439 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 449 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
440 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 450 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
451 support::token2(&self.syntax, T ! [ ; ])
452 }
441} 453}
442#[derive(Debug, Clone, PartialEq, Eq, Hash)] 454#[derive(Debug, Clone, PartialEq, Eq, Hash)]
443pub struct ImplDef { 455pub struct ImplDef {
@@ -582,7 +594,9 @@ impl AstNode for ArrayType {
582impl ArrayType { 594impl ArrayType {
583 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } 595 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
584 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 596 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
585 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 597 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
598 support::token2(&self.syntax, T ! [ ; ])
599 }
586 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 600 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
587 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } 601 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
588} 602}
@@ -765,7 +779,9 @@ impl ast::AttrsOwner for ArrayExpr {}
765impl ArrayExpr { 779impl ArrayExpr {
766 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) } 780 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
767 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 781 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
768 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 782 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
783 support::token2(&self.syntax, T ! [ ; ])
784 }
769 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) } 785 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
770} 786}
771#[derive(Debug, Clone, PartialEq, Eq, Hash)] 787#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1859,7 +1875,9 @@ impl MacroCall {
1859 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1875 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1860 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 1876 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
1861 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1877 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1862 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 1878 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
1879 support::token2(&self.syntax, T ! [ ; ])
1880 }
1863} 1881}
1864#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1882#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1865pub struct Attr { 1883pub struct Attr {
@@ -2100,7 +2118,9 @@ impl AstNode for ExprStmt {
2100impl ast::AttrsOwner for ExprStmt {} 2118impl ast::AttrsOwner for ExprStmt {}
2101impl ExprStmt { 2119impl ExprStmt {
2102 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2120 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2103 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 2121 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
2122 support::token2(&self.syntax, T ! [ ; ])
2123 }
2104} 2124}
2105#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2125#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2106pub struct LetStmt { 2126pub struct LetStmt {
@@ -2124,7 +2144,9 @@ impl LetStmt {
2124 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2144 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2125 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2145 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2126 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 2146 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2127 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 2147 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
2148 support::token2(&self.syntax, T ! [ ; ])
2149 }
2128} 2150}
2129#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2151#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2130pub struct Condition { 2152pub struct Condition {