From 36ba9127799960d64bd7fb0f07564af2a77e2fcc Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 19 Apr 2023 00:11:49 +0200 Subject: [PATCH] Make some names public --- fish-rust/src/ast.rs | 11 ++++++++++- fish-rust/src/common.rs | 2 +- fish-rust/src/parse_constants.rs | 11 ++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fish-rust/src/ast.rs b/fish-rust/src/ast.rs index d06248f3f..584b78054 100644 --- a/fish-rust/src/ast.rs +++ b/fish-rust/src/ast.rs @@ -1898,7 +1898,7 @@ define_keyword_node!(KeywordWhile, ParseKeyword::kw_while); impl DecoratedStatement { /// \return the decoration for this statement. - fn decoration(&self) -> StatementDecoration { + pub fn decoration(&self) -> StatementDecoration { let Some(decorator) = &self.opt_decoration else { return StatementDecoration::none; }; @@ -1942,6 +1942,9 @@ impl AcceptorMut for ArgumentOrRedirectionVariant { } impl ArgumentOrRedirectionVariant { + pub fn typ(&self) -> Type { + self.embedded_node().typ() + } fn embedded_node(&self) -> &dyn NodeMut { match self { ArgumentOrRedirectionVariant::Argument(node) => node, @@ -2032,6 +2035,9 @@ impl AcceptorMut for StatementVariant { } impl StatementVariant { + pub fn typ(&self) -> Type { + self.embedded_node().typ() + } fn embedded_node(&self) -> &dyn NodeMut { match self { StatementVariant::None => panic!("cannot visit null statement"), @@ -2113,6 +2119,9 @@ impl AcceptorMut for BlockStatementHeaderVariant { } impl BlockStatementHeaderVariant { + pub fn typ(&self) -> Type { + self.embedded_node().typ() + } fn embedded_node(&self) -> &dyn NodeMut { match self { BlockStatementHeaderVariant::None => panic!("cannot visit null block header"), diff --git a/fish-rust/src/common.rs b/fish-rust/src/common.rs index 8cf775ec8..02efe4ba2 100644 --- a/fish-rust/src/common.rs +++ b/fish-rust/src/common.rs @@ -1725,7 +1725,7 @@ pub fn valid_var_name_char(chr: char) -> bool { } /// Test if the given string is a valid variable name. -fn valid_var_name(s: &wstr) -> bool { +pub fn valid_var_name(s: &wstr) -> bool { // Note do not use c_str(), we want to fail on embedded nul bytes. !s.is_empty() && s.chars().all(valid_var_name_char) } diff --git a/fish-rust/src/parse_constants.rs b/fish-rust/src/parse_constants.rs index beab14c84..32783d7b0 100644 --- a/fish-rust/src/parse_constants.rs +++ b/fish-rust/src/parse_constants.rs @@ -79,7 +79,7 @@ mod parse_constants_ffi { /// A range of source code. #[derive(PartialEq, Eq, Clone, Copy, Debug)] - struct SourceRange { + pub struct SourceRange { start: u32, length: u32, } @@ -94,7 +94,7 @@ mod parse_constants_ffi { /// IMPORTANT: If the following enum table is modified you must also update token_type_description below. /// TODO above comment can be removed when we drop the FFI and get real enums. #[derive(Clone, Copy, Debug)] - enum ParseTokenType { + pub enum ParseTokenType { invalid = 1, // Terminal types. @@ -115,7 +115,7 @@ mod parse_constants_ffi { #[repr(u8)] #[derive(Clone, Copy, Debug)] - enum ParseKeyword { + pub enum ParseKeyword { // 'none' is not a keyword, it is a sentinel indicating nothing. none, @@ -235,7 +235,7 @@ mod parse_constants_ffi { } // The location of a pipeline. - enum PipelinePosition { + pub enum PipelinePosition { none, // not part of a pipeline first, // first command in a pipeline subsequent, // second or further command in a pipeline @@ -243,7 +243,8 @@ mod parse_constants_ffi { } pub use parse_constants_ffi::{ - parse_error_t, ParseErrorCode, ParseKeyword, ParseTokenType, SourceRange, StatementDecoration, + parse_error_t, ParseErrorCode, ParseKeyword, ParseTokenType, PipelinePosition, SourceRange, + StatementDecoration, }; impl SourceRange {