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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use std::path::Path;
mod error;
pub use self::error::{Error, Result};
use ::Config;
pub trait SemanticEngine : Send + Sync {
fn initialize(&self, config: &Config) -> Result<()>;
fn find_definition(&self, context: &Context) -> Result<Option<Definition>>;
fn list_completions(&self, context: &Context) -> Result<Option<Vec<Completion>>>;
}
#[derive(Debug)]
pub struct Completion {
pub text: String,
pub context: String,
pub kind: String,
pub file_path: String,
pub position: CursorPosition,
}
#[derive(Debug)]
pub struct Definition {
pub position: CursorPosition,
pub text: String,
pub text_context: String,
pub dtype: String,
pub file_path: String,
}
#[derive(Debug)]
pub struct Context {
pub buffers: Vec<Buffer>,
pub query_cursor: CursorPosition,
pub query_file: String,
}
impl Context {
pub fn new<T>(buffers: Vec<Buffer>, position: CursorPosition,
file_path: T) -> Context where T: Into<String> {
Context {
buffers: buffers,
query_cursor: position,
query_file: file_path.into(),
}
}
pub fn query_path<'a>(&'a self) -> &'a Path {
&Path::new(&self.query_file[..])
}
}
#[derive(Debug)]
pub struct CursorPosition {
pub line: usize,
pub col: usize,
}
pub mod racer;
pub use self::racer::Racer;
#[derive(Debug, RustcDecodable, Clone)]
pub struct Buffer {
pub file_path: String,
pub contents: String,
}
impl Buffer {
pub fn path<'a>(&'a self) -> &'a Path {
&Path::new(&self.file_path[..])
}
}