rubydex 0.3.0 → 0.4.1
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/README.md +29 -7
- data/THIRD_PARTY_LICENSES.html +238 -2
- data/exe/rdx +2 -149
- data/ext/rubydex/config.c +140 -0
- data/ext/rubydex/config.h +16 -0
- data/ext/rubydex/definition.c +34 -0
- data/ext/rubydex/definition.h +3 -0
- data/ext/rubydex/diagnostic.c +28 -1
- data/ext/rubydex/diagnostic.h +2 -0
- data/ext/rubydex/extconf.rb +4 -2
- data/ext/rubydex/graph.c +71 -55
- data/ext/rubydex/graph.h +6 -0
- data/ext/rubydex/query.c +398 -16
- data/ext/rubydex/rubydex.c +2 -0
- data/ext/rubydex/utils.c +11 -4
- data/lib/ruby_lsp/rubydex/addon.rb +211 -0
- data/lib/rubydex/cli/command/console.rb +55 -0
- data/lib/rubydex/cli/command/lint/explain.rb +76 -0
- data/lib/rubydex/cli/command/lint.rb +208 -0
- data/lib/rubydex/cli/command/mcp.rb +30 -0
- data/lib/rubydex/cli/command/query.rb +70 -0
- data/lib/rubydex/cli/command/skill.rb +69 -0
- data/lib/rubydex/cli/command.rb +168 -0
- data/lib/rubydex/cli.rb +93 -0
- data/lib/rubydex/config.rb +59 -0
- data/lib/rubydex/diagnostic.rb +12 -3
- data/lib/rubydex/errors.rb +42 -1
- data/lib/rubydex/graph.rb +10 -3
- data/lib/rubydex/linter/custom_rule.rb +97 -0
- data/lib/rubydex/linter/helpers/path_helpers.rb +78 -0
- data/lib/rubydex/linter/helpers/source_access_helpers.rb +31 -0
- data/lib/rubydex/linter/rule_loader.rb +36 -0
- data/lib/rubydex/linter/rule_test_case.rb +343 -0
- data/lib/rubydex/linter/runner.rb +56 -0
- data/lib/rubydex/linter.rb +19 -0
- data/lib/rubydex/location.rb +3 -0
- data/lib/rubydex/mcp_server.rb +1 -2
- data/lib/rubydex/related_information.rb +17 -0
- data/lib/rubydex/rule.rb +33 -0
- data/lib/rubydex/rules/dynamic_ancestor.rb +29 -0
- data/lib/rubydex/rules/dynamic_constant_reference.rb +25 -0
- data/lib/rubydex/rules/dynamic_singleton_definition.rb +30 -0
- data/lib/rubydex/rules/invalid_constant_visibility.rb +28 -0
- data/lib/rubydex/rules/invalid_method_visibility.rb +28 -0
- data/lib/rubydex/rules/parse_error.rb +25 -0
- data/lib/rubydex/rules/parse_warning.rb +28 -0
- data/lib/rubydex/rules/top_level_mixin_self.rb +27 -0
- data/lib/rubydex/rules/undefined_constant_visibility_target.rb +27 -0
- data/lib/rubydex/rules/undefined_method_visibility_target.rb +27 -0
- data/lib/rubydex/severity.rb +70 -0
- data/lib/rubydex/skill.rb +89 -0
- data/lib/rubydex/skill_registry.rb +62 -0
- data/lib/rubydex/version.rb +1 -1
- data/lib/rubydex.rb +8 -0
- data/lib/rubydex_linter/rules/rule_structure.rb +140 -0
- data/rbi/rubydex.rbi +464 -21
- data/rust/Cargo.lock +2 -2
- data/rust/rubydex/Cargo.toml +5 -1
- data/rust/rubydex/benches/graph_memory.rs +3 -5
- data/rust/rubydex/src/bin/generate_ruby_rules.rs +94 -0
- data/rust/rubydex/src/config.rs +538 -157
- data/rust/rubydex/src/diagnostic.rs +162 -45
- data/rust/rubydex/src/errors.rs +0 -1
- data/rust/rubydex/src/indexing/local_graph.rs +6 -5
- data/rust/rubydex/src/indexing/rbs_indexer.rs +270 -6
- data/rust/rubydex/src/indexing/ruby_indexer.rs +10 -12
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +134 -81
- data/rust/rubydex/src/lib.rs +1 -0
- data/rust/rubydex/src/listing.rs +26 -1
- data/rust/rubydex/src/main.rs +7 -4
- data/rust/rubydex/src/model/declaration.rs +302 -219
- data/rust/rubydex/src/model/graph.rs +27 -40
- data/rust/rubydex/src/model/name.rs +58 -17
- data/rust/rubydex/src/operation/ruby_builder.rs +30 -45
- data/rust/rubydex/src/path_helpers.rs +77 -0
- data/rust/rubydex/src/query/cypher/schema.rs +63 -0
- data/rust/rubydex/src/query/cypher/tests.rs +26 -1
- data/rust/rubydex/src/query/cypher.rs +8 -11
- data/rust/rubydex/src/query.rs +314 -44
- data/rust/rubydex/src/resolution.rs +139 -187
- data/rust/rubydex/src/resolution_tests.rs +247 -19
- data/rust/rubydex/src/test_utils/context.rs +2 -1
- data/rust/rubydex/src/test_utils/graph_test.rs +26 -12
- data/rust/rubydex/src/test_utils/local_graph_test.rs +19 -0
- data/rust/rubydex/tests/cli.rs +4 -4
- data/rust/rubydex-sys/src/config_api.rs +205 -0
- data/rust/rubydex-sys/src/cypher_api.rs +791 -0
- data/rust/rubydex-sys/src/definition_api.rs +68 -1
- data/rust/rubydex-sys/src/diagnostic_api.rs +42 -8
- data/rust/rubydex-sys/src/graph_api.rs +125 -205
- data/rust/rubydex-sys/src/lib.rs +2 -0
- data/rust/rubydex-sys/src/name_api.rs +49 -17
- data/rust/rubydex-sys/src/utils.rs +37 -0
- data/skills/send-private-method/SKILL.md +133 -0
- metadata +42 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
use super::run_query;
|
|
2
1
|
use super::schema::RelType;
|
|
2
|
+
use super::{render, run_query};
|
|
3
3
|
use crate::model::graph::Graph;
|
|
4
4
|
use crate::test_utils::GraphTest;
|
|
5
5
|
use cypher_parser::{CypherValue, OutputFormat, ResultSet, execute, parse};
|
|
@@ -197,6 +197,31 @@ fn run_query_json_output() {
|
|
|
197
197
|
assert_eq!(output, "[{\"c.name\":\"Dog\"}]");
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
#[test]
|
|
201
|
+
fn render_formats_one_result_set_in_both_formats() {
|
|
202
|
+
// `execute` runs the query once; `render` formats that same result set as often as needed.
|
|
203
|
+
let graph = fixture_graph();
|
|
204
|
+
let result = run(&graph, "MATCH (c:Class {name: 'Dog'}) RETURN c.name");
|
|
205
|
+
|
|
206
|
+
assert_eq!(render(&result, OutputFormat::Json), "[{\"c.name\":\"Dog\"}]");
|
|
207
|
+
|
|
208
|
+
let table = render(&result, OutputFormat::Table);
|
|
209
|
+
assert!(table.contains("c.name"));
|
|
210
|
+
assert!(table.contains("Dog"));
|
|
211
|
+
assert!(table.contains("1 row"));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#[test]
|
|
215
|
+
fn incoming_declares_and_defines_reach_the_document() {
|
|
216
|
+
// Exercises `expand_in`: walk the Document -> Definition -> Declaration spine backwards.
|
|
217
|
+
let graph = fixture_graph();
|
|
218
|
+
let result = run(
|
|
219
|
+
&graph,
|
|
220
|
+
"MATCH (decl:Class {name: 'Dog'})<-[:DECLARES]-(def:Definition)<-[:DEFINES]-(d:Document) RETURN DISTINCT d.name",
|
|
221
|
+
);
|
|
222
|
+
assert_eq!(column_strings(&result, 0), vec!["zoo.rb".to_string()]);
|
|
223
|
+
}
|
|
224
|
+
|
|
200
225
|
#[test]
|
|
201
226
|
fn unknown_relationship_type_errors() {
|
|
202
227
|
let graph = fixture_graph();
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
// `Graph` (in `schema`) and the static schema description (in `schema_info`).
|
|
19
19
|
//
|
|
20
20
|
// `Query` is the opaque parsed-query object: callers can `parse` a query string once (failing fast
|
|
21
|
-
// on syntax errors),
|
|
22
|
-
|
|
21
|
+
// on syntax errors), `execute` it against a graph that was built afterwards, and `render` the
|
|
22
|
+
// resulting [`ResultSet`] without running the query again.
|
|
23
|
+
pub use cypher_parser::{CypherError, CypherValue, OutputFormat, Query, ResultSet, execute, parse};
|
|
23
24
|
|
|
24
25
|
pub mod schema;
|
|
25
26
|
pub mod schema_info;
|
|
@@ -35,15 +36,11 @@ pub fn run_query(graph: &Graph, query: &str, output_format: OutputFormat) -> Res
|
|
|
35
36
|
cypher_parser::run_query(graph, query, output_format)
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
///
|
|
39
|
-
///
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/// Returns a [`CypherError`] if the query cannot be executed.
|
|
44
|
-
pub fn run_parsed(graph: &Graph, query: &Query, output_format: OutputFormat) -> Result<String, CypherError> {
|
|
45
|
-
let result = cypher_parser::execute(graph, query)?;
|
|
46
|
-
Ok(cypher_parser::format::format(&result, output_format))
|
|
39
|
+
/// Renders an already-executed [`ResultSet`] in the requested format. Pair with [`execute`] to run a
|
|
40
|
+
/// parsed query once and render its result set as often as needed.
|
|
41
|
+
#[must_use]
|
|
42
|
+
pub fn render(result: &ResultSet, output_format: OutputFormat) -> String {
|
|
43
|
+
cypher_parser::format::format(result, output_format)
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/// Returns a description of the queryable schema (node labels, relationship types, and properties)
|