1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std::io;
use symbolic_common::byteview::{ByteView, ByteViewHandle};
use uuid::Uuid;
pub struct ProguardMappingView<'a> {
mv: ByteViewHandle<'a, proguard::MappingView<'a>>,
}
impl<'a> ProguardMappingView<'a> {
pub fn parse(byteview: ByteView<'a>) -> Result<ProguardMappingView<'a>, io::Error> {
Ok(ProguardMappingView {
mv: ByteViewHandle::from_byteview(byteview, |bytes| -> Result<_, io::Error> {
Ok(proguard::MappingView::from_slice(bytes)?)
})?,
})
}
pub fn uuid(&self) -> uuid::Uuid {
Uuid::from_slice(&self.mv.uuid().as_bytes()[..]).unwrap()
}
pub fn has_line_info(&self) -> bool {
self.mv.has_line_info()
}
pub fn convert_dotted_path(&self, path: &str, lineno: u32) -> String {
let mut iter = path.splitn(2, ':');
let cls_name = iter.next().unwrap_or("");
let meth_name = iter.next();
if let Some(cls) = self.mv.find_class(cls_name) {
let class_name = cls.class_name();
if let Some(meth_name) = meth_name {
let lineno = if lineno == 0 {
None
} else {
Some(lineno as u32)
};
let methods = cls.get_methods(meth_name, lineno);
if !methods.is_empty() {
format!("{}:{}", class_name, methods[0].name())
} else {
format!("{}:{}", class_name, meth_name)
}
} else {
class_name.to_string()
}
} else {
path.to_string()
}
}
}