diff options
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 24 |
2 files changed, 33 insertions, 3 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 2c119269c..e9e275670 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -62,8 +62,13 @@ register_builtin! { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { | 64 | fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { |
65 | // FIXME: Use expansion info | ||
66 | let file_id = file.original_file(db); | 65 | let file_id = file.original_file(db); |
66 | |||
67 | // FIXME: if the file is coming from macro, we return a dummy value for now. | ||
68 | if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) { | ||
69 | return 0; | ||
70 | } | ||
71 | |||
67 | let text = db.file_text(file_id); | 72 | let text = db.file_text(file_id); |
68 | let mut line_num = 1; | 73 | let mut line_num = 1; |
69 | 74 | ||
@@ -150,8 +155,11 @@ fn option_env_expand( | |||
150 | } | 155 | } |
151 | 156 | ||
152 | fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { | 157 | fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { |
153 | // FIXME: Use expansion info | ||
154 | let file_id = file.original_file(db); | 158 | let file_id = file.original_file(db); |
159 | // FIXME: if the file is coming from macro, we return a dummy value for now. | ||
160 | if file.call_node(db).map(|it| it.file_id != file_id.into()).unwrap_or(true) { | ||
161 | return 0; | ||
162 | } | ||
155 | let text = db.file_text(file_id); | 163 | let text = db.file_text(file_id); |
156 | 164 | ||
157 | let pos = pos.to_usize(); | 165 | let pos = pos.to_usize(); |
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 2e12e126f..af5b22d1c 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -178,6 +178,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, macro_call_id: MacroCallId) -> Fragmen | |||
178 | 178 | ||
179 | match parent.kind() { | 179 | match parent.kind() { |
180 | MACRO_ITEMS | SOURCE_FILE => FragmentKind::Items, | 180 | MACRO_ITEMS | SOURCE_FILE => FragmentKind::Items, |
181 | ITEM_LIST => FragmentKind::Items, | ||
181 | LET_STMT => { | 182 | LET_STMT => { |
182 | // FIXME: Handle Pattern | 183 | // FIXME: Handle Pattern |
183 | FragmentKind::Expr | 184 | FragmentKind::Expr |
@@ -187,7 +188,28 @@ fn to_fragment_kind(db: &dyn AstDatabase, macro_call_id: MacroCallId) -> Fragmen | |||
187 | ARG_LIST => FragmentKind::Expr, | 188 | ARG_LIST => FragmentKind::Expr, |
188 | TRY_EXPR => FragmentKind::Expr, | 189 | TRY_EXPR => FragmentKind::Expr, |
189 | TUPLE_EXPR => FragmentKind::Expr, | 190 | TUPLE_EXPR => FragmentKind::Expr, |
190 | ITEM_LIST => FragmentKind::Items, | 191 | PAREN_EXPR => FragmentKind::Expr, |
192 | |||
193 | FOR_EXPR => FragmentKind::Expr, | ||
194 | PATH_EXPR => FragmentKind::Expr, | ||
195 | LAMBDA_EXPR => FragmentKind::Expr, | ||
196 | CONDITION => FragmentKind::Expr, | ||
197 | BREAK_EXPR => FragmentKind::Expr, | ||
198 | RETURN_EXPR => FragmentKind::Expr, | ||
199 | BLOCK_EXPR => FragmentKind::Expr, | ||
200 | MATCH_EXPR => FragmentKind::Expr, | ||
201 | MATCH_ARM => FragmentKind::Expr, | ||
202 | MATCH_GUARD => FragmentKind::Expr, | ||
203 | RECORD_FIELD => FragmentKind::Expr, | ||
204 | CALL_EXPR => FragmentKind::Expr, | ||
205 | INDEX_EXPR => FragmentKind::Expr, | ||
206 | METHOD_CALL_EXPR => FragmentKind::Expr, | ||
207 | AWAIT_EXPR => FragmentKind::Expr, | ||
208 | CAST_EXPR => FragmentKind::Expr, | ||
209 | REF_EXPR => FragmentKind::Expr, | ||
210 | PREFIX_EXPR => FragmentKind::Expr, | ||
211 | RANGE_EXPR => FragmentKind::Expr, | ||
212 | BIN_EXPR => FragmentKind::Expr, | ||
191 | _ => { | 213 | _ => { |
192 | // Unknown , Just guess it is `Items` | 214 | // Unknown , Just guess it is `Items` |
193 | FragmentKind::Items | 215 | FragmentKind::Items |