rubydex 0.2.1-aarch64-linux → 0.2.2-aarch64-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/definition.c +27 -0
- data/ext/rubydex/rubydex.c +2 -0
- data/ext/rubydex/signature.c +83 -0
- data/ext/rubydex/signature.h +23 -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/signature.rb +130 -0
- data/lib/rubydex/version.rb +1 -1
- data/lib/rubydex.rb +1 -0
- data/rust/rubydex/src/indexing/ruby_indexer.rs +73 -10
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +2818 -2656
- data/rust/rubydex/src/model/definitions.rs +23 -0
- data/rust/rubydex/src/model/graph.rs +40 -12
- data/rust/rubydex/src/query.rs +598 -1
- data/rust/rubydex/src/resolution.rs +30 -11
- data/rust/rubydex/src/resolution_tests.rs +155 -1
- data/rust/rubydex-sys/src/declaration_api.rs +10 -33
- data/rust/rubydex-sys/src/lib.rs +1 -0
- data/rust/rubydex-sys/src/signature_api.rs +209 -0
- metadata +6 -2
|
@@ -40,6 +40,7 @@ bitflags! {
|
|
|
40
40
|
pub struct DefinitionFlags: u8 {
|
|
41
41
|
const DEPRECATED = 0b0001;
|
|
42
42
|
const PROMOTABLE = 0b0010;
|
|
43
|
+
const SINGLETON_METHOD_VISIBILITY = 0b0100;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -53,6 +54,11 @@ impl DefinitionFlags {
|
|
|
53
54
|
pub fn is_promotable(&self) -> bool {
|
|
54
55
|
self.contains(Self::PROMOTABLE)
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
#[must_use]
|
|
59
|
+
pub fn is_singleton_method_visibility(&self) -> bool {
|
|
60
|
+
self.contains(Self::SINGLETON_METHOD_VISIBILITY)
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
#[derive(Debug)]
|
|
@@ -1033,6 +1039,23 @@ pub enum Parameter {
|
|
|
1033
1039
|
}
|
|
1034
1040
|
assert_mem_size!(Parameter, 24);
|
|
1035
1041
|
|
|
1042
|
+
impl Parameter {
|
|
1043
|
+
#[must_use]
|
|
1044
|
+
pub fn inner(&self) -> &ParameterStruct {
|
|
1045
|
+
match self {
|
|
1046
|
+
Parameter::RequiredPositional(s)
|
|
1047
|
+
| Parameter::OptionalPositional(s)
|
|
1048
|
+
| Parameter::RestPositional(s)
|
|
1049
|
+
| Parameter::Post(s)
|
|
1050
|
+
| Parameter::RequiredKeyword(s)
|
|
1051
|
+
| Parameter::OptionalKeyword(s)
|
|
1052
|
+
| Parameter::RestKeyword(s)
|
|
1053
|
+
| Parameter::Forward(s)
|
|
1054
|
+
| Parameter::Block(s) => s,
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1036
1059
|
#[derive(Debug, Clone)]
|
|
1037
1060
|
pub struct ParameterStruct {
|
|
1038
1061
|
offset: Offset,
|
|
@@ -6,7 +6,7 @@ use crate::diagnostic::Diagnostic;
|
|
|
6
6
|
use crate::indexing::local_graph::LocalGraph;
|
|
7
7
|
use crate::model::built_in::{OBJECT_ID, add_built_in_data};
|
|
8
8
|
use crate::model::declaration::{Ancestor, Declaration, Namespace};
|
|
9
|
-
use crate::model::definitions::{Definition, Receiver};
|
|
9
|
+
use crate::model::definitions::{Definition, MethodVisibilityDefinition, Receiver};
|
|
10
10
|
use crate::model::document::Document;
|
|
11
11
|
use crate::model::encoding::Encoding;
|
|
12
12
|
use crate::model::identity_maps::{IdentityHashMap, IdentityHashSet};
|
|
@@ -333,10 +333,15 @@ impl Graph {
|
|
|
333
333
|
.or_else(|| self.find_enclosing_namespace_name_id(it.lexical_nesting_id().as_ref())),
|
|
334
334
|
it.target(),
|
|
335
335
|
),
|
|
336
|
-
Definition::MethodVisibility(it) =>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
Definition::MethodVisibility(it) => {
|
|
337
|
+
if it.flags().is_singleton_method_visibility() {
|
|
338
|
+
return self.find_singleton_method_visibility_declaration(it);
|
|
339
|
+
}
|
|
340
|
+
(
|
|
341
|
+
self.find_enclosing_namespace_name_id(it.lexical_nesting_id().as_ref()),
|
|
342
|
+
it.str_id(),
|
|
343
|
+
)
|
|
344
|
+
}
|
|
340
345
|
Definition::GlobalVariable(it) => (
|
|
341
346
|
self.find_enclosing_namespace_name_id(it.lexical_nesting_id().as_ref()),
|
|
342
347
|
it.str_id(),
|
|
@@ -375,13 +380,15 @@ impl Graph {
|
|
|
375
380
|
)
|
|
376
381
|
}
|
|
377
382
|
Definition::MethodAlias(it) => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
it.
|
|
384
|
-
|
|
383
|
+
let nesting_name_id = match it.receiver() {
|
|
384
|
+
Some(Receiver::SelfReceiver(def_id)) => {
|
|
385
|
+
return self.find_self_receiver_declaration(*def_id, *it.new_name_str_id());
|
|
386
|
+
}
|
|
387
|
+
Some(Receiver::ConstantReceiver(name_id)) => Some(name_id),
|
|
388
|
+
None => self.find_enclosing_namespace_name_id(it.lexical_nesting_id().as_ref()),
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
(nesting_name_id, it.new_name_str_id())
|
|
385
392
|
}
|
|
386
393
|
};
|
|
387
394
|
|
|
@@ -413,6 +420,27 @@ impl Graph {
|
|
|
413
420
|
None
|
|
414
421
|
}
|
|
415
422
|
|
|
423
|
+
/// Looks up the declaration for a singleton method visibility through the singleton class.
|
|
424
|
+
fn find_singleton_method_visibility_declaration(
|
|
425
|
+
&self,
|
|
426
|
+
definition: &MethodVisibilityDefinition,
|
|
427
|
+
) -> Option<&DeclarationId> {
|
|
428
|
+
let nesting_name_id = self.find_enclosing_namespace_name_id(definition.lexical_nesting_id().as_ref());
|
|
429
|
+
let nesting_declaration_id = match nesting_name_id {
|
|
430
|
+
Some(name_id) => self.name_id_to_declaration_id(*name_id),
|
|
431
|
+
None => Some(&*OBJECT_ID),
|
|
432
|
+
}?;
|
|
433
|
+
let singleton_id = self
|
|
434
|
+
.declarations
|
|
435
|
+
.get(nesting_declaration_id)?
|
|
436
|
+
.as_namespace()?
|
|
437
|
+
.singleton_class()?;
|
|
438
|
+
self.declarations
|
|
439
|
+
.get(singleton_id)?
|
|
440
|
+
.as_namespace()?
|
|
441
|
+
.member(definition.str_id())
|
|
442
|
+
}
|
|
443
|
+
|
|
416
444
|
/// Looks up the declaration for a `SelfReceiver` method/alias through the singleton class.
|
|
417
445
|
fn find_self_receiver_declaration(&self, def_id: DefinitionId, member_str_id: StringId) -> Option<&DeclarationId> {
|
|
418
446
|
let owner_decl_id = self.definition_id_to_declaration_id(def_id)?;
|