Skip to content

Commit

Permalink
Pipe information through compiler for simplified resolver generation …
Browse files Browse the repository at this point in the history
…for property lookup resolvers

Summary:
@public
This diff creates the foundation of a new quality of life feature that allows for quickly defining resolvers that just do a property lookup on the base model. The changes in this diff are just piping the information of whether or not the resolver is a regular function or a new property lookup resolver through the compiler. It starts in the schema generation module and must carry the information all the way through to the printer. A stacked diff will actually implement the logic to find and add the resolver information.

Reviewed By: captbaritone

Differential Revision: D66714731

fbshipit-source-id: 4eba405cc590f461339f3f165d9832b52854c75e
  • Loading branch information
evanyeung authored and facebook-github-bot committed Dec 19, 2024
1 parent 743d2a7 commit 28ed217
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions unsupported/hermes/crates/hermes_comments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ use hermes_estree::SourceRange;
use hermes_estree::Visitor;
use hermes_parser::Comment;

pub type AttachedComments<'a> = Vec<(&'a str, SourceRange, Node<'a>, SourceRange)>;
struct CommentAttachmentVisitor<'a> {
comments: &'a [Comment],
idx: usize,
attached_comments: Vec<(&'a str, SourceRange, Node<'a>, SourceRange)>,
attached_comments: AttachedComments<'a>,
}

impl<'a> Visitor<'a> for CommentAttachmentVisitor<'a> {
Expand Down Expand Up @@ -51,7 +52,6 @@ impl<'a> Visitor<'a> for CommentAttachmentVisitor<'a> {
node.as_node_enum(),
node.range(),
));
return true;
}
false
}
Expand All @@ -66,7 +66,7 @@ impl<'a> CommentAttachmentVisitor<'a> {
}
}

fn result(self) -> Vec<(&'a str, SourceRange, Node<'a>, SourceRange)> {
fn result(self) -> AttachedComments<'a> {
self.attached_comments
}
}
Expand All @@ -76,7 +76,7 @@ impl<'a> CommentAttachmentVisitor<'a> {
pub fn find_nodes_after_comments<'a>(
program: &'a Program,
comments: &'a [Comment],
) -> Vec<(&'a str, SourceRange, Node<'a>, SourceRange)> {
) -> AttachedComments<'a> {
let mut comment_attachment_visitor = CommentAttachmentVisitor::new(comments);
comment_attachment_visitor.visit_program(program);
comment_attachment_visitor.result()
Expand Down
2 changes: 1 addition & 1 deletion unsupported/hermes/crates/hermes_estree/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::ser::SerializeTuple;
use serde::Deserialize;
use serde::Serialize;

#[derive(Deserialize, Copy, Clone, Debug, PartialEq, PartialOrd, Hash)]
#[derive(Deserialize, Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
pub struct SourceRange {
pub start: u32,
pub end: u32,
Expand Down

0 comments on commit 28ed217

Please sign in to comment.