-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmappings.rs
More file actions
65 lines (59 loc) · 1.64 KB
/
mappings.rs
File metadata and controls
65 lines (59 loc) · 1.64 KB
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
60
61
62
63
64
65
use crate::trap::{Label, TrapClass};
use ra_ap_syntax::{AstNode, ast, ast::RangeItem};
pub(crate) trait HasTrapClass: AstNode {
type TrapClass: TrapClass;
}
pub(crate) trait Emission<T: HasTrapClass> {
fn pre_emit(&mut self, _node: &T) -> Option<Label<T::TrapClass>> {
None
}
fn post_emit(&mut self, _node: &T, _label: Label<T::TrapClass>) {}
}
pub(crate) trait TextValue {
fn try_get_text(&self) -> Option<String>;
}
impl TextValue for ast::Lifetime {
fn try_get_text(&self) -> Option<String> {
self.text().to_string().into()
}
}
impl TextValue for ast::Name {
fn try_get_text(&self) -> Option<String> {
self.text().to_string().into()
}
}
impl TextValue for ast::Literal {
fn try_get_text(&self) -> Option<String> {
self.token().text().to_string().into()
}
}
impl TextValue for ast::NameRef {
fn try_get_text(&self) -> Option<String> {
self.text().to_string().into()
}
}
impl TextValue for ast::Abi {
fn try_get_text(&self) -> Option<String> {
self.abi_string().map(|x| x.to_string())
}
}
impl TextValue for ast::BinExpr {
fn try_get_text(&self) -> Option<String> {
self.op_token().map(|x| x.text().to_string())
}
}
impl TextValue for ast::PrefixExpr {
fn try_get_text(&self) -> Option<String> {
self.op_token().map(|x| x.text().to_string())
}
}
impl TextValue for ast::RangeExpr {
fn try_get_text(&self) -> Option<String> {
self.op_token().map(|x| x.text().to_string())
}
}
impl TextValue for ast::RangePat {
fn try_get_text(&self) -> Option<String> {
self.op_token().map(|x| x.text().to_string())
}
}