Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rust/rubydex-sys/src/definition_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub enum DefinitionKind {
ClassVariable = 11,
MethodAlias = 12,
GlobalVariableAlias = 13,
Dsl = 14,
DynamicClass = 15,
DynamicModule = 16,
}

pub(crate) fn map_definition_to_kind(defn: &Definition) -> DefinitionKind {
Expand All @@ -44,6 +47,9 @@ pub(crate) fn map_definition_to_kind(defn: &Definition) -> DefinitionKind {
Definition::ClassVariable(_) => DefinitionKind::ClassVariable,
Definition::MethodAlias(_) => DefinitionKind::MethodAlias,
Definition::GlobalVariableAlias(_) => DefinitionKind::GlobalVariableAlias,
Definition::Dsl(_) => DefinitionKind::Dsl,
Definition::DynamicClass(_) => DefinitionKind::DynamicClass,
Definition::DynamicModule(_) => DefinitionKind::DynamicModule,
}
}

Expand Down
1 change: 1 addition & 0 deletions rust/rubydex-sys/src/graph_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ mod tests {
BAR = 1
end
",
vec![],
);
indexer.index();

Expand Down
13 changes: 11 additions & 2 deletions rust/rubydex/src/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ pub struct IndexingRubyFileJob {
path: PathBuf,
local_graph_tx: Sender<LocalGraph>,
errors_tx: Sender<Errors>,
dsl_method_names: Vec<&'static str>,
}

impl IndexingRubyFileJob {
#[must_use]
pub fn new(path: PathBuf, local_graph_tx: Sender<LocalGraph>, errors_tx: Sender<Errors>) -> Self {
pub fn new(
path: PathBuf,
local_graph_tx: Sender<LocalGraph>,
errors_tx: Sender<Errors>,
dsl_method_names: Vec<&'static str>,
) -> Self {
Self {
path,
local_graph_tx,
errors_tx,
dsl_method_names,
}
}

Expand Down Expand Up @@ -55,7 +62,7 @@ impl Job for IndexingRubyFileJob {
return;
};

let mut ruby_indexer = RubyIndexer::new(url.to_string(), &source);
let mut ruby_indexer = RubyIndexer::new(url.to_string(), &source, self.dsl_method_names.clone());
ruby_indexer.index();

self.local_graph_tx
Expand All @@ -73,12 +80,14 @@ pub fn index_files(graph: &mut Graph, paths: Vec<PathBuf>) -> Vec<Errors> {
let queue = Arc::new(JobQueue::new());
let (local_graphs_tx, local_graphs_rx) = unbounded();
let (errors_tx, errors_rx) = unbounded();
let dsl_method_names = graph.dsl_method_names();

for path in paths {
queue.push(Box::new(IndexingRubyFileJob::new(
path,
local_graphs_tx.clone(),
errors_tx.clone(),
dsl_method_names.clone(),
)));
}

Expand Down
1,166 changes: 765 additions & 401 deletions rust/rubydex/src/indexing/ruby_indexer.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions rust/rubydex/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pub mod comment;
pub mod declaration;
pub mod definitions;
pub mod document;
pub mod dsl;
pub mod dsl_processors;
pub mod encoding;
pub mod graph;
pub mod id;
Expand Down
Loading
Loading