Skip to content

Commit

Permalink
Remove BindingsError as any graph builder errors should be internal
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Jul 8, 2024
1 parent 6010ffd commit 5810536
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 35 deletions.
1 change: 0 additions & 1 deletion crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use semver::Version;

use crate::cst::KindTypes;

pub type BindingsError = metaslang_bindings::BindingsError;
pub type Bindings = metaslang_bindings::Bindings<KindTypes>;
pub type Handle<'a> = metaslang_bindings::Handle<'a, KindTypes>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn execute(file_path_string: &str, version: Version) -> Result<(), CommandEr
let parse_output = super::parse::parse_source_file(file_path_string, version, |_| ())?;
let tree_cursor = parse_output.create_tree_cursor();

bindings.add_file(file_path_string, tree_cursor)?;
bindings.add_file(file_path_string, tree_cursor);

print_definitions(&bindings);
print_references(&bindings);
Expand Down
4 changes: 0 additions & 4 deletions crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ pub enum CommandError {

#[error("Parsing failed: {0}")]
ParseFailed(String),

#[cfg(feature = "__experimental_bindings_api")]
#[error(transparent)]
BindingsError(#[from] crate::bindings::BindingsError),
}
23 changes: 6 additions & 17 deletions crates/metaslang/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ use semver::Version;
use stack_graphs::graph::StackGraph;
use stack_graphs::partial::PartialPaths;
use stack_graphs::stitching::{ForwardPartialPathStitcher, GraphEdgeCandidates, StitcherConfig};
use thiserror::Error;

type Builder<'a, KT> = builder::Builder<'a, KT>;
type GraphHandle = stack_graphs::arena::Handle<stack_graphs::graph::Node>;

#[derive(Error, Debug)]
pub enum BindingsError {
#[error(transparent)]
BuildError(#[from] builder::BuildError),
}

pub struct Bindings<KT: KindTypes + 'static> {
version: Version,
graph_builder_file: File<KT>,
Expand All @@ -49,11 +42,7 @@ impl<KT: KindTypes + 'static> Bindings<KT> {
}
}

pub fn add_file(
&mut self,
file_path: &str,
tree_cursor: Cursor<KT>,
) -> Result<(), BindingsError> {
pub fn add_file(&mut self, file_path: &str, tree_cursor: Cursor<KT>) {
let globals = builder::Globals {
version: &self.version,
file_path,
Expand All @@ -67,11 +56,11 @@ impl<KT: KindTypes + 'static> Bindings<KT> {
file,
tree_cursor,
);
builder.build(&globals, &builder::NoCancellation, |handle, cursor| {
self.cursors.insert(handle, cursor.clone());
})?;

Ok(())
builder
.build(&globals, &builder::NoCancellation, |handle, cursor| {
self.cursors.insert(handle, cursor.clone());
})
.expect("Internal error while building bindings");
}

pub fn all_definitions(&self) -> impl Iterator<Item = Handle<'_, KT>> + '_ {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5810536

Please sign in to comment.