rubydex 0.1.0.beta11 → 0.1.0.beta13
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/LICENSE.txt +23 -23
- data/README.md +125 -125
- data/THIRD_PARTY_LICENSES.html +2018 -945
- data/exe/rdx +47 -47
- data/ext/rubydex/declaration.c +453 -388
- data/ext/rubydex/declaration.h +23 -23
- data/ext/rubydex/definition.c +284 -197
- data/ext/rubydex/definition.h +28 -28
- data/ext/rubydex/diagnostic.c +6 -6
- data/ext/rubydex/diagnostic.h +11 -11
- data/ext/rubydex/document.c +97 -98
- data/ext/rubydex/document.h +10 -10
- data/ext/rubydex/extconf.rb +146 -127
- data/ext/rubydex/graph.c +701 -512
- data/ext/rubydex/graph.h +10 -10
- data/ext/rubydex/handle.h +44 -44
- data/ext/rubydex/location.c +22 -22
- data/ext/rubydex/location.h +15 -15
- data/ext/rubydex/reference.c +123 -104
- data/ext/rubydex/reference.h +15 -16
- data/ext/rubydex/rubydex.c +22 -22
- data/ext/rubydex/utils.c +108 -86
- data/ext/rubydex/utils.h +34 -28
- data/lib/rubydex/comment.rb +17 -17
- data/lib/rubydex/declaration.rb +11 -0
- data/lib/rubydex/diagnostic.rb +21 -21
- data/lib/rubydex/failures.rb +15 -15
- data/lib/rubydex/graph.rb +98 -92
- data/lib/rubydex/keyword.rb +17 -0
- data/lib/rubydex/keyword_parameter.rb +13 -0
- data/lib/rubydex/location.rb +90 -90
- data/lib/rubydex/mixin.rb +22 -0
- data/lib/rubydex/version.rb +5 -5
- data/lib/rubydex.rb +24 -20
- data/rbi/rubydex.rbi +425 -310
- data/rust/Cargo.lock +1851 -1851
- data/rust/Cargo.toml +29 -29
- data/rust/about.toml +10 -10
- data/rust/{about.hbs → about_templates/about.hbs} +81 -78
- data/rust/about_templates/mingw_licenses.hbs +1071 -0
- data/rust/rubydex/Cargo.toml +42 -42
- data/rust/rubydex/src/compile_assertions.rs +13 -13
- data/rust/rubydex/src/diagnostic.rs +110 -109
- data/rust/rubydex/src/errors.rs +28 -28
- data/rust/rubydex/src/indexing/local_graph.rs +224 -224
- data/rust/rubydex/src/indexing/rbs_indexer.rs +1551 -1554
- data/rust/rubydex/src/indexing/ruby_indexer.rs +2329 -6753
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +4962 -0
- data/rust/rubydex/src/indexing.rs +210 -210
- data/rust/rubydex/src/integrity.rs +279 -278
- data/rust/rubydex/src/job_queue.rs +199 -205
- data/rust/rubydex/src/lib.rs +17 -17
- data/rust/rubydex/src/listing.rs +371 -272
- data/rust/rubydex/src/main.rs +160 -160
- data/rust/rubydex/src/model/built_in.rs +83 -0
- data/rust/rubydex/src/model/comment.rs +24 -24
- data/rust/rubydex/src/model/declaration.rs +679 -588
- data/rust/rubydex/src/model/definitions.rs +1682 -1602
- data/rust/rubydex/src/model/document.rs +222 -252
- data/rust/rubydex/src/model/encoding.rs +22 -22
- data/rust/rubydex/src/model/graph.rs +3782 -3556
- data/rust/rubydex/src/model/id.rs +110 -110
- data/rust/rubydex/src/model/identity_maps.rs +58 -58
- data/rust/rubydex/src/model/ids.rs +60 -38
- data/rust/rubydex/src/model/keywords.rs +256 -256
- data/rust/rubydex/src/model/name.rs +298 -298
- data/rust/rubydex/src/model/references.rs +111 -111
- data/rust/rubydex/src/model/string_ref.rs +50 -50
- data/rust/rubydex/src/model/visibility.rs +41 -41
- data/rust/rubydex/src/model.rs +15 -14
- data/rust/rubydex/src/offset.rs +147 -147
- data/rust/rubydex/src/position.rs +6 -6
- data/rust/rubydex/src/query.rs +1841 -1700
- data/rust/rubydex/src/resolution.rs +1852 -5895
- data/rust/rubydex/src/resolution_tests.rs +4701 -0
- data/rust/rubydex/src/stats/memory.rs +71 -71
- data/rust/rubydex/src/stats/orphan_report.rs +264 -263
- data/rust/rubydex/src/stats/timer.rs +127 -127
- data/rust/rubydex/src/stats.rs +11 -11
- data/rust/rubydex/src/test_utils/context.rs +226 -226
- data/rust/rubydex/src/test_utils/graph_test.rs +730 -679
- data/rust/rubydex/src/test_utils/local_graph_test.rs +602 -602
- data/rust/rubydex/src/test_utils.rs +52 -52
- data/rust/rubydex/src/visualization/dot.rs +192 -176
- data/rust/rubydex/src/visualization.rs +6 -6
- data/rust/rubydex/tests/cli.rs +185 -167
- data/rust/rubydex-mcp/Cargo.toml +28 -28
- data/rust/rubydex-mcp/src/main.rs +48 -48
- data/rust/rubydex-mcp/src/server.rs +1145 -1145
- data/rust/rubydex-mcp/src/tools.rs +49 -49
- data/rust/rubydex-mcp/tests/mcp.rs +302 -302
- data/rust/rubydex-sys/Cargo.toml +20 -20
- data/rust/rubydex-sys/build.rs +14 -14
- data/rust/rubydex-sys/cbindgen.toml +12 -12
- data/rust/rubydex-sys/src/declaration_api.rs +485 -469
- data/rust/rubydex-sys/src/definition_api.rs +443 -352
- data/rust/rubydex-sys/src/diagnostic_api.rs +99 -99
- data/rust/rubydex-sys/src/document_api.rs +85 -54
- data/rust/rubydex-sys/src/graph_api.rs +1017 -700
- data/rust/rubydex-sys/src/lib.rs +79 -9
- data/rust/rubydex-sys/src/location_api.rs +79 -79
- data/rust/rubydex-sys/src/name_api.rs +187 -135
- data/rust/rubydex-sys/src/reference_api.rs +267 -195
- data/rust/rubydex-sys/src/utils.rs +70 -70
- data/rust/rustfmt.toml +2 -2
- metadata +16 -9
- data/lib/rubydex/librubydex_sys.so +0 -0
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
use std::collections::hash_map::Entry;
|
|
2
|
-
|
|
3
|
-
use crate::diagnostic::{Diagnostic, Rule};
|
|
4
|
-
use crate::model::definitions::Definition;
|
|
5
|
-
use crate::model::document::Document;
|
|
6
|
-
use crate::model::graph::NameDependent;
|
|
7
|
-
use crate::model::identity_maps::IdentityHashMap;
|
|
8
|
-
use crate::model::ids::{DefinitionId,
|
|
9
|
-
use crate::model::name::{Name, NameRef};
|
|
10
|
-
use crate::model::references::{ConstantReference, MethodRef};
|
|
11
|
-
use crate::model::string_ref::StringRef;
|
|
12
|
-
use crate::offset::Offset;
|
|
13
|
-
|
|
14
|
-
type LocalGraphParts = (
|
|
15
|
-
UriId,
|
|
16
|
-
Document,
|
|
17
|
-
IdentityHashMap<DefinitionId, Definition>,
|
|
18
|
-
IdentityHashMap<StringId, StringRef>,
|
|
19
|
-
IdentityHashMap<NameId, NameRef>,
|
|
20
|
-
IdentityHashMap<
|
|
21
|
-
IdentityHashMap<
|
|
22
|
-
IdentityHashMap<NameId, Vec<NameDependent>>,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
#[derive(Debug)]
|
|
26
|
-
pub struct LocalGraph {
|
|
27
|
-
uri_id: UriId,
|
|
28
|
-
document: Document,
|
|
29
|
-
definitions: IdentityHashMap<DefinitionId, Definition>,
|
|
30
|
-
strings: IdentityHashMap<StringId, StringRef>,
|
|
31
|
-
names: IdentityHashMap<NameId, NameRef>,
|
|
32
|
-
constant_references: IdentityHashMap<
|
|
33
|
-
method_references: IdentityHashMap<
|
|
34
|
-
name_dependents: IdentityHashMap<NameId, Vec<NameDependent>>,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
impl LocalGraph {
|
|
38
|
-
#[must_use]
|
|
39
|
-
pub fn new(uri_id: UriId, document: Document) -> Self {
|
|
40
|
-
Self {
|
|
41
|
-
uri_id,
|
|
42
|
-
document,
|
|
43
|
-
definitions: IdentityHashMap::default(),
|
|
44
|
-
strings: IdentityHashMap::default(),
|
|
45
|
-
names: IdentityHashMap::default(),
|
|
46
|
-
constant_references: IdentityHashMap::default(),
|
|
47
|
-
method_references: IdentityHashMap::default(),
|
|
48
|
-
name_dependents: IdentityHashMap::default(),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
#[must_use]
|
|
53
|
-
pub fn uri_id(&self) -> UriId {
|
|
54
|
-
self.uri_id
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#[must_use]
|
|
58
|
-
pub fn document(&self) -> &Document {
|
|
59
|
-
&self.document
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Definitions
|
|
63
|
-
|
|
64
|
-
#[must_use]
|
|
65
|
-
pub fn definitions(&self) -> &IdentityHashMap<DefinitionId, Definition> {
|
|
66
|
-
&self.definitions
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#[must_use]
|
|
70
|
-
pub fn get_definition_mut(&mut self, definition_id: DefinitionId) -> Option<&mut Definition> {
|
|
71
|
-
self.definitions.get_mut(&definition_id)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
pub fn add_definition(&mut self, definition: Definition) -> DefinitionId {
|
|
75
|
-
let definition_id = definition.id();
|
|
76
|
-
|
|
77
|
-
if let Some(name_id) = definition.name_id() {
|
|
78
|
-
self.name_dependents
|
|
79
|
-
.entry(*name_id)
|
|
80
|
-
.or_default()
|
|
81
|
-
.push(NameDependent::Definition(definition_id));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if self.definitions.insert(definition_id, definition).is_some() {
|
|
85
|
-
debug_assert!(false, "DefinitionId collision in local graph");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
self.document.add_definition(definition_id);
|
|
89
|
-
definition_id
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Strings
|
|
93
|
-
|
|
94
|
-
#[must_use]
|
|
95
|
-
pub fn strings(&self) -> &IdentityHashMap<StringId, StringRef> {
|
|
96
|
-
&self.strings
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
pub fn intern_string(&mut self, string: String) -> StringId {
|
|
100
|
-
let string_id = StringId::from(&string);
|
|
101
|
-
|
|
102
|
-
match self.strings.entry(string_id) {
|
|
103
|
-
Entry::Occupied(mut entry) => {
|
|
104
|
-
debug_assert!(string == **entry.get(), "StringId collision in local graph");
|
|
105
|
-
entry.get_mut().increment_ref_count(1);
|
|
106
|
-
}
|
|
107
|
-
Entry::Vacant(entry) => {
|
|
108
|
-
entry.insert(StringRef::new(string));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
string_id
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Names
|
|
116
|
-
|
|
117
|
-
#[must_use]
|
|
118
|
-
pub fn names(&self) -> &IdentityHashMap<NameId, NameRef> {
|
|
119
|
-
&self.names
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
pub fn add_name(&mut self, name: Name) -> NameId {
|
|
123
|
-
let name_id = name.id();
|
|
124
|
-
|
|
125
|
-
match self.names.entry(name_id) {
|
|
126
|
-
Entry::Occupied(mut entry) => {
|
|
127
|
-
debug_assert!(*entry.get() == name, "NameId collision in local graph");
|
|
128
|
-
entry.get_mut().increment_ref_count(1);
|
|
129
|
-
}
|
|
130
|
-
Entry::Vacant(entry) => {
|
|
131
|
-
if let Some(&parent_scope) = name.parent_scope().as_ref() {
|
|
132
|
-
self.name_dependents
|
|
133
|
-
.entry(parent_scope)
|
|
134
|
-
.or_default()
|
|
135
|
-
.push(NameDependent::ChildName(name_id));
|
|
136
|
-
}
|
|
137
|
-
if let Some(&nesting_id) = name.nesting().as_ref() {
|
|
138
|
-
self.name_dependents
|
|
139
|
-
.entry(nesting_id)
|
|
140
|
-
.or_default()
|
|
141
|
-
.push(NameDependent::NestedName(name_id));
|
|
142
|
-
}
|
|
143
|
-
entry.insert(NameRef::Unresolved(Box::new(name)));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
name_id
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Constant references
|
|
151
|
-
|
|
152
|
-
#[must_use]
|
|
153
|
-
pub fn constant_references(&self) -> &IdentityHashMap<
|
|
154
|
-
&self.constant_references
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
pub fn add_constant_reference(&mut self, reference: ConstantReference) ->
|
|
158
|
-
let reference_id = reference.id();
|
|
159
|
-
self.name_dependents
|
|
160
|
-
.entry(*reference.name_id())
|
|
161
|
-
.or_default()
|
|
162
|
-
.push(NameDependent::Reference(reference_id));
|
|
163
|
-
|
|
164
|
-
if self.constant_references.insert(reference_id, reference).is_some() {
|
|
165
|
-
debug_assert!(false, "ReferenceId collision in local graph");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
self.document.add_constant_reference(reference_id);
|
|
169
|
-
reference_id
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Method references
|
|
173
|
-
|
|
174
|
-
#[must_use]
|
|
175
|
-
pub fn method_references(&self) -> &IdentityHashMap<
|
|
176
|
-
&self.method_references
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
pub fn add_method_reference(&mut self, reference: MethodRef) ->
|
|
180
|
-
let reference_id = reference.id();
|
|
181
|
-
|
|
182
|
-
if self.method_references.insert(reference_id, reference).is_some() {
|
|
183
|
-
debug_assert!(false, "ReferenceId collision in local graph");
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
self.document.add_method_reference(reference_id);
|
|
187
|
-
reference_id
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Diagnostics
|
|
191
|
-
|
|
192
|
-
#[must_use]
|
|
193
|
-
pub fn diagnostics(&self) -> &[Diagnostic] {
|
|
194
|
-
self.document.diagnostics()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
pub fn add_diagnostic(&mut self, rule: Rule, offset: Offset, message: String) {
|
|
198
|
-
let diagnostic = Diagnostic::new(rule, self.uri_id, offset, message);
|
|
199
|
-
self.document.add_diagnostic(diagnostic);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Name dependents
|
|
203
|
-
|
|
204
|
-
#[must_use]
|
|
205
|
-
pub fn name_dependents(&self) -> &IdentityHashMap<NameId, Vec<NameDependent>> {
|
|
206
|
-
&self.name_dependents
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Into parts
|
|
210
|
-
|
|
211
|
-
#[must_use]
|
|
212
|
-
pub fn into_parts(self) -> LocalGraphParts {
|
|
213
|
-
(
|
|
214
|
-
self.uri_id,
|
|
215
|
-
self.document,
|
|
216
|
-
self.definitions,
|
|
217
|
-
self.strings,
|
|
218
|
-
self.names,
|
|
219
|
-
self.constant_references,
|
|
220
|
-
self.method_references,
|
|
221
|
-
self.name_dependents,
|
|
222
|
-
)
|
|
223
|
-
}
|
|
224
|
-
}
|
|
1
|
+
use std::collections::hash_map::Entry;
|
|
2
|
+
|
|
3
|
+
use crate::diagnostic::{Diagnostic, Rule};
|
|
4
|
+
use crate::model::definitions::Definition;
|
|
5
|
+
use crate::model::document::Document;
|
|
6
|
+
use crate::model::graph::NameDependent;
|
|
7
|
+
use crate::model::identity_maps::IdentityHashMap;
|
|
8
|
+
use crate::model::ids::{ConstantReferenceId, DefinitionId, MethodReferenceId, NameId, StringId, UriId};
|
|
9
|
+
use crate::model::name::{Name, NameRef};
|
|
10
|
+
use crate::model::references::{ConstantReference, MethodRef};
|
|
11
|
+
use crate::model::string_ref::StringRef;
|
|
12
|
+
use crate::offset::Offset;
|
|
13
|
+
|
|
14
|
+
type LocalGraphParts = (
|
|
15
|
+
UriId,
|
|
16
|
+
Document,
|
|
17
|
+
IdentityHashMap<DefinitionId, Definition>,
|
|
18
|
+
IdentityHashMap<StringId, StringRef>,
|
|
19
|
+
IdentityHashMap<NameId, NameRef>,
|
|
20
|
+
IdentityHashMap<ConstantReferenceId, ConstantReference>,
|
|
21
|
+
IdentityHashMap<MethodReferenceId, MethodRef>,
|
|
22
|
+
IdentityHashMap<NameId, Vec<NameDependent>>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
#[derive(Debug)]
|
|
26
|
+
pub struct LocalGraph {
|
|
27
|
+
uri_id: UriId,
|
|
28
|
+
document: Document,
|
|
29
|
+
definitions: IdentityHashMap<DefinitionId, Definition>,
|
|
30
|
+
strings: IdentityHashMap<StringId, StringRef>,
|
|
31
|
+
names: IdentityHashMap<NameId, NameRef>,
|
|
32
|
+
constant_references: IdentityHashMap<ConstantReferenceId, ConstantReference>,
|
|
33
|
+
method_references: IdentityHashMap<MethodReferenceId, MethodRef>,
|
|
34
|
+
name_dependents: IdentityHashMap<NameId, Vec<NameDependent>>,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
impl LocalGraph {
|
|
38
|
+
#[must_use]
|
|
39
|
+
pub fn new(uri_id: UriId, document: Document) -> Self {
|
|
40
|
+
Self {
|
|
41
|
+
uri_id,
|
|
42
|
+
document,
|
|
43
|
+
definitions: IdentityHashMap::default(),
|
|
44
|
+
strings: IdentityHashMap::default(),
|
|
45
|
+
names: IdentityHashMap::default(),
|
|
46
|
+
constant_references: IdentityHashMap::default(),
|
|
47
|
+
method_references: IdentityHashMap::default(),
|
|
48
|
+
name_dependents: IdentityHashMap::default(),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#[must_use]
|
|
53
|
+
pub fn uri_id(&self) -> UriId {
|
|
54
|
+
self.uri_id
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[must_use]
|
|
58
|
+
pub fn document(&self) -> &Document {
|
|
59
|
+
&self.document
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Definitions
|
|
63
|
+
|
|
64
|
+
#[must_use]
|
|
65
|
+
pub fn definitions(&self) -> &IdentityHashMap<DefinitionId, Definition> {
|
|
66
|
+
&self.definitions
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#[must_use]
|
|
70
|
+
pub fn get_definition_mut(&mut self, definition_id: DefinitionId) -> Option<&mut Definition> {
|
|
71
|
+
self.definitions.get_mut(&definition_id)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
pub fn add_definition(&mut self, definition: Definition) -> DefinitionId {
|
|
75
|
+
let definition_id = definition.id();
|
|
76
|
+
|
|
77
|
+
if let Some(name_id) = definition.name_id() {
|
|
78
|
+
self.name_dependents
|
|
79
|
+
.entry(*name_id)
|
|
80
|
+
.or_default()
|
|
81
|
+
.push(NameDependent::Definition(definition_id));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if self.definitions.insert(definition_id, definition).is_some() {
|
|
85
|
+
debug_assert!(false, "DefinitionId collision in local graph");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
self.document.add_definition(definition_id);
|
|
89
|
+
definition_id
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Strings
|
|
93
|
+
|
|
94
|
+
#[must_use]
|
|
95
|
+
pub fn strings(&self) -> &IdentityHashMap<StringId, StringRef> {
|
|
96
|
+
&self.strings
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
pub fn intern_string(&mut self, string: String) -> StringId {
|
|
100
|
+
let string_id = StringId::from(&string);
|
|
101
|
+
|
|
102
|
+
match self.strings.entry(string_id) {
|
|
103
|
+
Entry::Occupied(mut entry) => {
|
|
104
|
+
debug_assert!(string == **entry.get(), "StringId collision in local graph");
|
|
105
|
+
entry.get_mut().increment_ref_count(1);
|
|
106
|
+
}
|
|
107
|
+
Entry::Vacant(entry) => {
|
|
108
|
+
entry.insert(StringRef::new(string));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
string_id
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Names
|
|
116
|
+
|
|
117
|
+
#[must_use]
|
|
118
|
+
pub fn names(&self) -> &IdentityHashMap<NameId, NameRef> {
|
|
119
|
+
&self.names
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
pub fn add_name(&mut self, name: Name) -> NameId {
|
|
123
|
+
let name_id = name.id();
|
|
124
|
+
|
|
125
|
+
match self.names.entry(name_id) {
|
|
126
|
+
Entry::Occupied(mut entry) => {
|
|
127
|
+
debug_assert!(*entry.get() == name, "NameId collision in local graph");
|
|
128
|
+
entry.get_mut().increment_ref_count(1);
|
|
129
|
+
}
|
|
130
|
+
Entry::Vacant(entry) => {
|
|
131
|
+
if let Some(&parent_scope) = name.parent_scope().as_ref() {
|
|
132
|
+
self.name_dependents
|
|
133
|
+
.entry(parent_scope)
|
|
134
|
+
.or_default()
|
|
135
|
+
.push(NameDependent::ChildName(name_id));
|
|
136
|
+
}
|
|
137
|
+
if let Some(&nesting_id) = name.nesting().as_ref() {
|
|
138
|
+
self.name_dependents
|
|
139
|
+
.entry(nesting_id)
|
|
140
|
+
.or_default()
|
|
141
|
+
.push(NameDependent::NestedName(name_id));
|
|
142
|
+
}
|
|
143
|
+
entry.insert(NameRef::Unresolved(Box::new(name)));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
name_id
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Constant references
|
|
151
|
+
|
|
152
|
+
#[must_use]
|
|
153
|
+
pub fn constant_references(&self) -> &IdentityHashMap<ConstantReferenceId, ConstantReference> {
|
|
154
|
+
&self.constant_references
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
pub fn add_constant_reference(&mut self, reference: ConstantReference) -> ConstantReferenceId {
|
|
158
|
+
let reference_id = reference.id();
|
|
159
|
+
self.name_dependents
|
|
160
|
+
.entry(*reference.name_id())
|
|
161
|
+
.or_default()
|
|
162
|
+
.push(NameDependent::Reference(reference_id));
|
|
163
|
+
|
|
164
|
+
if self.constant_references.insert(reference_id, reference).is_some() {
|
|
165
|
+
debug_assert!(false, "ReferenceId collision in local graph");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
self.document.add_constant_reference(reference_id);
|
|
169
|
+
reference_id
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Method references
|
|
173
|
+
|
|
174
|
+
#[must_use]
|
|
175
|
+
pub fn method_references(&self) -> &IdentityHashMap<MethodReferenceId, MethodRef> {
|
|
176
|
+
&self.method_references
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
pub fn add_method_reference(&mut self, reference: MethodRef) -> MethodReferenceId {
|
|
180
|
+
let reference_id = reference.id();
|
|
181
|
+
|
|
182
|
+
if self.method_references.insert(reference_id, reference).is_some() {
|
|
183
|
+
debug_assert!(false, "ReferenceId collision in local graph");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
self.document.add_method_reference(reference_id);
|
|
187
|
+
reference_id
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Diagnostics
|
|
191
|
+
|
|
192
|
+
#[must_use]
|
|
193
|
+
pub fn diagnostics(&self) -> &[Diagnostic] {
|
|
194
|
+
self.document.diagnostics()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
pub fn add_diagnostic(&mut self, rule: Rule, offset: Offset, message: String) {
|
|
198
|
+
let diagnostic = Diagnostic::new(rule, self.uri_id, offset, message);
|
|
199
|
+
self.document.add_diagnostic(diagnostic);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Name dependents
|
|
203
|
+
|
|
204
|
+
#[must_use]
|
|
205
|
+
pub fn name_dependents(&self) -> &IdentityHashMap<NameId, Vec<NameDependent>> {
|
|
206
|
+
&self.name_dependents
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Into parts
|
|
210
|
+
|
|
211
|
+
#[must_use]
|
|
212
|
+
pub fn into_parts(self) -> LocalGraphParts {
|
|
213
|
+
(
|
|
214
|
+
self.uri_id,
|
|
215
|
+
self.document,
|
|
216
|
+
self.definitions,
|
|
217
|
+
self.strings,
|
|
218
|
+
self.names,
|
|
219
|
+
self.constant_references,
|
|
220
|
+
self.method_references,
|
|
221
|
+
self.name_dependents,
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
}
|