Get the source file offset of the begin and the end of this VarDecl. This source file range is used to delete a VarDecl.
(vd: &VarDecl, src_file: &Path)
| 135 | /// Get the source file offset of the begin and the end of this VarDecl. |
| 136 | /// This source file range is used to delete a VarDecl. |
| 137 | pub fn get_var_uninit_loc(vd: &VarDecl, src_file: &Path) -> Result<(usize, usize)> { |
| 138 | if let Some(vd_loc) = get_bare_loc(&vd.loc) { |
| 139 | let vd_begin = get_sr_begin_loc(&vd.range)?; |
| 140 | let vd_end = get_sr_end_loc(&vd.range)?; |
| 141 | // if var before has other vd |
| 142 | if has_other_before_vd(vd_begin, vd_loc, src_file) { |
| 143 | let begin = get_pre_vd_begin(vd_loc, src_file)?; |
| 144 | let end = vd_end.offset + vd_end.tok_len; |
| 145 | return Ok((begin, end)); |
| 146 | } else { |
| 147 | // if var after has other vd |
| 148 | if has_other_after_vd(vd_end, src_file) { |
| 149 | let begin = get_post_vd_begin(vd_loc, src_file)?; |
| 150 | let end = get_vd_end_offset(vd_end, src_file)? + 1; |
| 151 | return Ok((begin, end)); |
| 152 | } else { |
| 153 | let begin = vd_begin.offset; |
| 154 | let end = get_vd_end_offset(vd_end, src_file)? + 1; |
| 155 | return Ok((begin, end)); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | eyre::bail!("cannot get loction for variable: {vd:?}") |
| 160 | } |
| 161 | |
| 162 | pub fn get_source_code_range(sr: &SourceRange) -> Result<(usize, usize)> { |
| 163 | let begin = get_sr_begin_loc(sr)?; |
nothing calls this directly
no test coverage detected