pub fn get_location(&self, loc: &Loc) -> String {
        if self.code.is_empty() {
            return "(internal)".to_string();
        }
        let mut res_string = String::new();
        let lines = self.get_lines(loc);
        let mut found = false;
        for line in &lines {
            if !found {
                res_string += &format!("{}:{}\n", self.path.to_string_lossy(), line.no);
                found = true;
            };

            let start = line.top;
            let mut end = line.end;
            if self.get_next_char(end) == Some('\n') && end > 0 {
                end -= 1
            }
            res_string += &self.code[start..=end];
            res_string.push('\n');
            use std::cmp::*;
            let lead = if loc.0 <= line.top {
                0
            } else {
                console::measure_text_width(&self.code[start..loc.0])
            };
            let range_start = max(loc.0, line.top);
            let range_end = min(loc.1, line.end);
            let length = console::measure_text_width(&self.code[range_start..=range_end]);
            res_string += &" ".repeat(lead);
            res_string += &"^".repeat(length);
            res_string += "\n";
        }

        if !found {
            res_string += "NOT FOUND\n";
            let line = match lines.last() {
                Some(line) => (line.no + 1, line.end + 1, loc.1),
                None => (1, 0, loc.1),
            };
            let lead = console::measure_text_width(&self.code[line.1..loc.0]);
            let length = console::measure_text_width(&self.code[loc.0..loc.1]);
            let is_cr = loc.1 >= self.code.len() || self.get_next_char(loc.1) == Some('\n');
            res_string += &format!("{}:{}\n", self.path.to_string_lossy(), line.0);
            res_string += if !is_cr {
                &self.code[line.1..=loc.1]
            } else {
                &self.code[line.1..loc.1]
            };
            res_string += &" ".repeat(lead);
            res_string += &"^".repeat(length + 1);
            res_string += "\n";
        }
        res_string
    }
Return a string represents the location of `loc` in the source code using '^^^'.
ruruby-common/src/source_info.rs