aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-02 20:20:24 +0100
committerGitHub <[email protected]>2019-09-02 20:20:24 +0100
commit7faec1c30046769d4ae490e15cf5405bcfbdeef8 (patch)
tree6d268b721027a5350928a6c5a0ec227b5fde8ebc /crates/ra_ide_api/src
parenta8397deab914240aca8f015fb3736689919c0a5b (diff)
parente94587e3153b52684fd3f6b82c8e7efc09ff5c8d (diff)
Merge #1752
1752: Always wrap blocks into block expressions r=flodiebold a=matklad This way, things like function bodies are expressions, and we don't have to single them out Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/join_lines.rs2
-rw-r--r--crates/ra_ide_api/src/syntax_tree.rs91
2 files changed, 50 insertions, 43 deletions
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs
index a2e4b6f3c..a71e4ed7d 100644
--- a/crates/ra_ide_api/src/join_lines.rs
+++ b/crates/ra_ide_api/src/join_lines.rs
@@ -123,7 +123,7 @@ fn has_comma_after(node: &SyntaxNode) -> bool {
123fn join_single_expr_block(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Option<()> { 123fn join_single_expr_block(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Option<()> {
124 let block = ast::Block::cast(token.parent())?; 124 let block = ast::Block::cast(token.parent())?;
125 let block_expr = ast::BlockExpr::cast(block.syntax().parent()?)?; 125 let block_expr = ast::BlockExpr::cast(block.syntax().parent()?)?;
126 let expr = extract_trivial_expression(&block)?; 126 let expr = extract_trivial_expression(&block_expr)?;
127 127
128 let block_range = block_expr.syntax().text_range(); 128 let block_range = block_expr.syntax().text_range();
129 let mut buf = expr.syntax().text().to_string(); 129 let mut buf = expr.syntax().text().to_string();
diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide_api/src/syntax_tree.rs
index dd31b9093..914759709 100644
--- a/crates/ra_ide_api/src/syntax_tree.rs
+++ b/crates/ra_ide_api/src/syntax_tree.rs
@@ -116,9 +116,10 @@ SOURCE_FILE@[0; 11)
116 L_PAREN@[6; 7) "(" 116 L_PAREN@[6; 7) "("
117 R_PAREN@[7; 8) ")" 117 R_PAREN@[7; 8) ")"
118 WHITESPACE@[8; 9) " " 118 WHITESPACE@[8; 9) " "
119 BLOCK@[9; 11) 119 BLOCK_EXPR@[9; 11)
120 L_CURLY@[9; 10) "{" 120 BLOCK@[9; 11)
121 R_CURLY@[10; 11) "}" 121 L_CURLY@[9; 10) "{"
122 R_CURLY@[10; 11) "}"
122"# 123"#
123 .trim() 124 .trim()
124 ); 125 );
@@ -148,26 +149,27 @@ SOURCE_FILE@[0; 60)
148 L_PAREN@[7; 8) "(" 149 L_PAREN@[7; 8) "("
149 R_PAREN@[8; 9) ")" 150 R_PAREN@[8; 9) ")"
150 WHITESPACE@[9; 10) " " 151 WHITESPACE@[9; 10) " "
151 BLOCK@[10; 60) 152 BLOCK_EXPR@[10; 60)
152 L_CURLY@[10; 11) "{" 153 BLOCK@[10; 60)
153 WHITESPACE@[11; 16) "\n " 154 L_CURLY@[10; 11) "{"
154 EXPR_STMT@[16; 58) 155 WHITESPACE@[11; 16) "\n "
155 MACRO_CALL@[16; 57) 156 EXPR_STMT@[16; 58)
156 PATH@[16; 22) 157 MACRO_CALL@[16; 57)
157 PATH_SEGMENT@[16; 22) 158 PATH@[16; 22)
158 NAME_REF@[16; 22) 159 PATH_SEGMENT@[16; 22)
159 IDENT@[16; 22) "assert" 160 NAME_REF@[16; 22)
160 EXCL@[22; 23) "!" 161 IDENT@[16; 22) "assert"
161 TOKEN_TREE@[23; 57) 162 EXCL@[22; 23) "!"
162 L_PAREN@[23; 24) "(" 163 TOKEN_TREE@[23; 57)
163 STRING@[24; 52) "\"\n fn foo() {\n ..." 164 L_PAREN@[23; 24) "("
164 COMMA@[52; 53) "," 165 STRING@[24; 52) "\"\n fn foo() {\n ..."
165 WHITESPACE@[53; 54) " " 166 COMMA@[52; 53) ","
166 STRING@[54; 56) "\"\"" 167 WHITESPACE@[53; 54) " "
167 R_PAREN@[56; 57) ")" 168 STRING@[54; 56) "\"\""
168 SEMI@[57; 58) ";" 169 R_PAREN@[56; 57) ")"
169 WHITESPACE@[58; 59) "\n" 170 SEMI@[57; 58) ";"
170 R_CURLY@[59; 60) "}" 171 WHITESPACE@[58; 59) "\n"
172 R_CURLY@[59; 60) "}"
171"# 173"#
172 .trim() 174 .trim()
173 ); 175 );
@@ -190,9 +192,10 @@ FN_DEF@[0; 11)
190 L_PAREN@[6; 7) "(" 192 L_PAREN@[6; 7) "("
191 R_PAREN@[7; 8) ")" 193 R_PAREN@[7; 8) ")"
192 WHITESPACE@[8; 9) " " 194 WHITESPACE@[8; 9) " "
193 BLOCK@[9; 11) 195 BLOCK_EXPR@[9; 11)
194 L_CURLY@[9; 10) "{" 196 BLOCK@[9; 11)
195 R_CURLY@[10; 11) "}" 197 L_CURLY@[9; 10) "{"
198 R_CURLY@[10; 11) "}"
196"# 199"#
197 .trim() 200 .trim()
198 ); 201 );
@@ -258,10 +261,11 @@ SOURCE_FILE@[0; 12)
258 L_PAREN@[6; 7) "(" 261 L_PAREN@[6; 7) "("
259 R_PAREN@[7; 8) ")" 262 R_PAREN@[7; 8) ")"
260 WHITESPACE@[8; 9) " " 263 WHITESPACE@[8; 9) " "
261 BLOCK@[9; 12) 264 BLOCK_EXPR@[9; 12)
262 L_CURLY@[9; 10) "{" 265 BLOCK@[9; 12)
263 WHITESPACE@[10; 11) "\n" 266 L_CURLY@[9; 10) "{"
264 R_CURLY@[11; 12) "}" 267 WHITESPACE@[10; 11) "\n"
268 R_CURLY@[11; 12) "}"
265"# 269"#
266 .trim() 270 .trim()
267 ); 271 );
@@ -292,10 +296,11 @@ SOURCE_FILE@[0; 12)
292 L_PAREN@[6; 7) "(" 296 L_PAREN@[6; 7) "("
293 R_PAREN@[7; 8) ")" 297 R_PAREN@[7; 8) ")"
294 WHITESPACE@[8; 9) " " 298 WHITESPACE@[8; 9) " "
295 BLOCK@[9; 12) 299 BLOCK_EXPR@[9; 12)
296 L_CURLY@[9; 10) "{" 300 BLOCK@[9; 12)
297 WHITESPACE@[10; 11) "\n" 301 L_CURLY@[9; 10) "{"
298 R_CURLY@[11; 12) "}" 302 WHITESPACE@[10; 11) "\n"
303 R_CURLY@[11; 12) "}"
299"# 304"#
300 .trim() 305 .trim()
301 ); 306 );
@@ -325,10 +330,11 @@ SOURCE_FILE@[0; 25)
325 L_PAREN@[6; 7) "(" 330 L_PAREN@[6; 7) "("
326 R_PAREN@[7; 8) ")" 331 R_PAREN@[7; 8) ")"
327 WHITESPACE@[8; 9) " " 332 WHITESPACE@[8; 9) " "
328 BLOCK@[9; 12) 333 BLOCK_EXPR@[9; 12)
329 L_CURLY@[9; 10) "{" 334 BLOCK@[9; 12)
330 WHITESPACE@[10; 11) "\n" 335 L_CURLY@[9; 10) "{"
331 R_CURLY@[11; 12) "}" 336 WHITESPACE@[10; 11) "\n"
337 R_CURLY@[11; 12) "}"
332 WHITESPACE@[12; 13) "\n" 338 WHITESPACE@[12; 13) "\n"
333 FN_DEF@[13; 25) 339 FN_DEF@[13; 25)
334 FN_KW@[13; 15) "fn" 340 FN_KW@[13; 15) "fn"
@@ -339,10 +345,11 @@ SOURCE_FILE@[0; 25)
339 L_PAREN@[19; 20) "(" 345 L_PAREN@[19; 20) "("
340 R_PAREN@[20; 21) ")" 346 R_PAREN@[20; 21) ")"
341 WHITESPACE@[21; 22) " " 347 WHITESPACE@[21; 22) " "
342 BLOCK@[22; 25) 348 BLOCK_EXPR@[22; 25)
343 L_CURLY@[22; 23) "{" 349 BLOCK@[22; 25)
344 WHITESPACE@[23; 24) "\n" 350 L_CURLY@[22; 23) "{"
345 R_CURLY@[24; 25) "}" 351 WHITESPACE@[23; 24) "\n"
352 R_CURLY@[24; 25) "}"
346"# 353"#
347 .trim() 354 .trim()
348 ); 355 );