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
//! Curated accessors used when indexing the code tree: source positions,
//! fully-qualified names, and the symbol a use site resolves to.
use vala_sys as ffi;
use crate::object::{opt_string, take_string, RawWrapper};
use crate::{CodeNode, Expression, MemberAccess, SourceReference, Symbol};
impl CodeNode {
/// The source location this node was parsed from, if any. Synthetic nodes
/// (inserted by the compiler) may have none.
pub fn source_reference(&self) -> Option<SourceReference> {
unsafe {
SourceReference::from_raw_none(ffi::vala_code_node_get_source_reference(self.as_raw()))
}
}
}
impl Symbol {
/// The fully-qualified name, e.g. `Foo.Bar.method`. Suitable as the basis
/// for a stable SCIP symbol identifier. `None` for the anonymous root.
pub fn full_name(&self) -> Option<String> {
unsafe { take_string(ffi::vala_symbol_get_full_name(self.as_raw())) }
}
}
impl Expression {
/// The symbol this expression resolves to after semantic analysis, if any.
/// This is the link from a *use* site back to its *definition*.
pub fn symbol_reference(&self) -> Option<Symbol> {
unsafe { Symbol::from_raw_none(ffi::vala_expression_get_symbol_reference(self.as_raw())) }
}
}
impl MemberAccess {
/// The accessed member's name as written at the use site.
pub fn member_name(&self) -> Option<String> {
unsafe { opt_string(ffi::vala_member_access_get_member_name(self.as_raw())) }
}
/// The inner expression (the receiver), e.g. `foo` in `foo.bar`.
pub fn inner(&self) -> Option<Expression> {
unsafe { Expression::from_raw_none(ffi::vala_member_access_get_inner(self.as_raw())) }
}
}