From 28ed217412f0336b67b083b32f5544fc69c48450 Mon Sep 17 00:00:00 2001 From: Evan Yeung Date: Thu, 19 Dec 2024 10:56:04 -0800 Subject: [PATCH] Pipe information through compiler for simplified resolver generation 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 --- unsupported/hermes/crates/hermes_comments/src/lib.rs | 8 ++++---- unsupported/hermes/crates/hermes_estree/src/range.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unsupported/hermes/crates/hermes_comments/src/lib.rs b/unsupported/hermes/crates/hermes_comments/src/lib.rs index bd0a429716e..ccdd42db45a 100644 --- a/unsupported/hermes/crates/hermes_comments/src/lib.rs +++ b/unsupported/hermes/crates/hermes_comments/src/lib.rs @@ -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> { @@ -51,7 +52,6 @@ impl<'a> Visitor<'a> for CommentAttachmentVisitor<'a> { node.as_node_enum(), node.range(), )); - return true; } false } @@ -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 } } @@ -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() diff --git a/unsupported/hermes/crates/hermes_estree/src/range.rs b/unsupported/hermes/crates/hermes_estree/src/range.rs index 503118ea7bd..123f03137dd 100644 --- a/unsupported/hermes/crates/hermes_estree/src/range.rs +++ b/unsupported/hermes/crates/hermes_estree/src/range.rs @@ -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,