rubydex 0.1.0.beta1-x86_64-linux → 0.1.0.beta2-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rubydex/declaration.c +146 -0
- data/ext/rubydex/declaration.h +10 -0
- data/ext/rubydex/definition.c +234 -0
- data/ext/rubydex/definition.h +28 -0
- data/ext/rubydex/diagnostic.c +6 -0
- data/ext/rubydex/diagnostic.h +11 -0
- data/ext/rubydex/document.c +98 -0
- data/ext/rubydex/document.h +10 -0
- data/ext/rubydex/extconf.rb +36 -15
- data/ext/rubydex/graph.c +405 -0
- data/ext/rubydex/graph.h +10 -0
- data/ext/rubydex/handle.h +44 -0
- data/ext/rubydex/location.c +22 -0
- data/ext/rubydex/location.h +15 -0
- data/ext/rubydex/reference.c +104 -0
- data/ext/rubydex/reference.h +16 -0
- data/ext/rubydex/rubydex.c +22 -0
- data/ext/rubydex/utils.c +27 -0
- data/ext/rubydex/utils.h +13 -0
- data/lib/rubydex/3.2/rubydex.so +0 -0
- data/lib/rubydex/3.3/rubydex.so +0 -0
- data/lib/rubydex/3.4/rubydex.so +0 -0
- data/lib/rubydex/4.0/rubydex.so +0 -0
- data/lib/rubydex/librubydex_sys.so +0 -0
- data/lib/rubydex/version.rb +1 -1
- data/rust/Cargo.lock +1275 -0
- data/rust/Cargo.toml +23 -0
- data/rust/about.hbs +78 -0
- data/rust/about.toml +9 -0
- data/rust/rubydex/Cargo.toml +41 -0
- data/rust/rubydex/src/diagnostic.rs +108 -0
- data/rust/rubydex/src/errors.rs +28 -0
- data/rust/rubydex/src/indexing/local_graph.rs +172 -0
- data/rust/rubydex/src/indexing/ruby_indexer.rs +5397 -0
- data/rust/rubydex/src/indexing.rs +128 -0
- data/rust/rubydex/src/job_queue.rs +186 -0
- data/rust/rubydex/src/lib.rs +15 -0
- data/rust/rubydex/src/listing.rs +249 -0
- data/rust/rubydex/src/main.rs +116 -0
- data/rust/rubydex/src/model/comment.rs +24 -0
- data/rust/rubydex/src/model/declaration.rs +541 -0
- data/rust/rubydex/src/model/definitions.rs +1475 -0
- data/rust/rubydex/src/model/document.rs +111 -0
- data/rust/rubydex/src/model/encoding.rs +22 -0
- data/rust/rubydex/src/model/graph.rs +1387 -0
- data/rust/rubydex/src/model/id.rs +90 -0
- data/rust/rubydex/src/model/identity_maps.rs +54 -0
- data/rust/rubydex/src/model/ids.rs +32 -0
- data/rust/rubydex/src/model/name.rs +188 -0
- data/rust/rubydex/src/model/references.rs +129 -0
- data/rust/rubydex/src/model/string_ref.rs +44 -0
- data/rust/rubydex/src/model/visibility.rs +41 -0
- data/rust/rubydex/src/model.rs +13 -0
- data/rust/rubydex/src/offset.rs +70 -0
- data/rust/rubydex/src/position.rs +6 -0
- data/rust/rubydex/src/query.rs +103 -0
- data/rust/rubydex/src/resolution.rs +4421 -0
- data/rust/rubydex/src/stats/memory.rs +71 -0
- data/rust/rubydex/src/stats/timer.rs +126 -0
- data/rust/rubydex/src/stats.rs +9 -0
- data/rust/rubydex/src/test_utils/context.rs +226 -0
- data/rust/rubydex/src/test_utils/graph_test.rs +229 -0
- data/rust/rubydex/src/test_utils/local_graph_test.rs +166 -0
- data/rust/rubydex/src/test_utils.rs +52 -0
- data/rust/rubydex/src/visualization/dot.rs +176 -0
- data/rust/rubydex/src/visualization.rs +6 -0
- data/rust/rubydex/tests/cli.rs +167 -0
- data/rust/rubydex-sys/Cargo.toml +20 -0
- data/rust/rubydex-sys/build.rs +14 -0
- data/rust/rubydex-sys/cbindgen.toml +12 -0
- data/rust/rubydex-sys/src/declaration_api.rs +114 -0
- data/rust/rubydex-sys/src/definition_api.rs +350 -0
- data/rust/rubydex-sys/src/diagnostic_api.rs +99 -0
- data/rust/rubydex-sys/src/document_api.rs +54 -0
- data/rust/rubydex-sys/src/graph_api.rs +493 -0
- data/rust/rubydex-sys/src/lib.rs +9 -0
- data/rust/rubydex-sys/src/location_api.rs +79 -0
- data/rust/rubydex-sys/src/name_api.rs +81 -0
- data/rust/rubydex-sys/src/reference_api.rs +191 -0
- data/rust/rubydex-sys/src/utils.rs +50 -0
- data/rust/rustfmt.toml +2 -0
- metadata +77 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
use line_index::LineIndex;
|
|
2
|
+
|
|
3
|
+
use crate::diagnostic::Diagnostic;
|
|
4
|
+
use crate::model::ids::{DefinitionId, ReferenceId};
|
|
5
|
+
|
|
6
|
+
// Represents a document currently loaded into memory. Identified by its unique URI, it holds the edges to all
|
|
7
|
+
// definitions and references discovered in it
|
|
8
|
+
#[derive(Debug)]
|
|
9
|
+
pub struct Document {
|
|
10
|
+
uri: String,
|
|
11
|
+
line_index: LineIndex,
|
|
12
|
+
definition_ids: Vec<DefinitionId>,
|
|
13
|
+
method_reference_ids: Vec<ReferenceId>,
|
|
14
|
+
constant_reference_ids: Vec<ReferenceId>,
|
|
15
|
+
diagnostics: Vec<Diagnostic>,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
impl Document {
|
|
19
|
+
#[must_use]
|
|
20
|
+
pub fn new(uri: String, source: &str) -> Self {
|
|
21
|
+
Self {
|
|
22
|
+
uri,
|
|
23
|
+
line_index: LineIndex::new(source),
|
|
24
|
+
definition_ids: Vec::new(),
|
|
25
|
+
method_reference_ids: Vec::new(),
|
|
26
|
+
constant_reference_ids: Vec::new(),
|
|
27
|
+
diagnostics: Vec::new(),
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[must_use]
|
|
32
|
+
pub fn uri(&self) -> &str {
|
|
33
|
+
&self.uri
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#[must_use]
|
|
37
|
+
pub fn line_index(&self) -> &LineIndex {
|
|
38
|
+
&self.line_index
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[must_use]
|
|
42
|
+
pub fn definitions(&self) -> &[DefinitionId] {
|
|
43
|
+
&self.definition_ids
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
pub fn add_definition(&mut self, definition_id: DefinitionId) {
|
|
47
|
+
debug_assert!(
|
|
48
|
+
!self.definition_ids.contains(&definition_id),
|
|
49
|
+
"Cannot add the same exact definition to a document twice. Duplicate definition IDs"
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
self.definition_ids.push(definition_id);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#[must_use]
|
|
56
|
+
pub fn method_references(&self) -> &[ReferenceId] {
|
|
57
|
+
&self.method_reference_ids
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
pub fn add_method_reference(&mut self, reference_id: ReferenceId) {
|
|
61
|
+
self.method_reference_ids.push(reference_id);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#[must_use]
|
|
65
|
+
pub fn constant_references(&self) -> &[ReferenceId] {
|
|
66
|
+
&self.constant_reference_ids
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
pub fn add_constant_reference(&mut self, reference_id: ReferenceId) {
|
|
70
|
+
self.constant_reference_ids.push(reference_id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#[must_use]
|
|
74
|
+
pub fn diagnostics(&self) -> &[Diagnostic] {
|
|
75
|
+
&self.diagnostics
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
pub fn add_diagnostic(&mut self, diagnostic: Diagnostic) {
|
|
79
|
+
self.diagnostics.push(diagnostic);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[cfg(test)]
|
|
84
|
+
mod tests {
|
|
85
|
+
use super::*;
|
|
86
|
+
|
|
87
|
+
#[test]
|
|
88
|
+
#[should_panic(expected = "Cannot add the same exact definition to a document twice. Duplicate definition IDs")]
|
|
89
|
+
fn inserting_duplicate_definitions() {
|
|
90
|
+
let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
|
|
91
|
+
let def_id = DefinitionId::new(123);
|
|
92
|
+
|
|
93
|
+
document.add_definition(def_id);
|
|
94
|
+
document.add_definition(def_id);
|
|
95
|
+
|
|
96
|
+
assert_eq!(document.definitions().len(), 1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#[test]
|
|
100
|
+
fn tracking_references() {
|
|
101
|
+
let mut document = Document::new("file:///foo.rb".to_string(), "class Foo; end");
|
|
102
|
+
let method_ref = ReferenceId::new(1);
|
|
103
|
+
let constant_ref = ReferenceId::new(2);
|
|
104
|
+
|
|
105
|
+
document.add_method_reference(method_ref);
|
|
106
|
+
document.add_constant_reference(constant_ref);
|
|
107
|
+
|
|
108
|
+
assert_eq!(document.method_references(), &[method_ref]);
|
|
109
|
+
assert_eq!(document.constant_references(), &[constant_ref]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use line_index::WideEncoding;
|
|
2
|
+
|
|
3
|
+
#[derive(Default, Debug)]
|
|
4
|
+
pub enum Encoding {
|
|
5
|
+
#[default]
|
|
6
|
+
Utf8,
|
|
7
|
+
Utf16,
|
|
8
|
+
Utf32,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
impl Encoding {
|
|
12
|
+
/// Transform the LSP selected encoding into the expected `WideEncoding` for converting code units with the
|
|
13
|
+
/// `line_index` crate
|
|
14
|
+
#[must_use]
|
|
15
|
+
pub fn to_wide(&self) -> Option<WideEncoding> {
|
|
16
|
+
match self {
|
|
17
|
+
Encoding::Utf8 => None,
|
|
18
|
+
Encoding::Utf16 => Some(WideEncoding::Utf16),
|
|
19
|
+
Encoding::Utf32 => Some(WideEncoding::Utf32),
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|