pub struct AstProgram {
pub body: Vec<BodyItem>,
pub non_code_meta: NonCodeMeta,
pub shebang: Option<Node<Shebang>>,
pub inner_attrs: NodeList<Annotation>,
pub digest: Option<[u8; 32]>,
}Expand description
A KCL program top level, or function body.
Fields§
§body: Vec<BodyItem>§non_code_meta: NonCodeMeta§shebang: Option<Node<Shebang>>§inner_attrs: NodeList<Annotation>§digest: Option<[u8; 32]>Implementations§
Source§impl Program
impl Program
Sourcepub fn ends_with_expr(&self) -> bool
pub fn ends_with_expr(&self) -> bool
Is the last body item an expression?
Sourcepub fn get_body_item_for_position(&self, pos: usize) -> Option<&BodyItem>
pub fn get_body_item_for_position(&self, pos: usize) -> Option<&BodyItem>
Returns the body item that includes the given character position.
Sourcepub fn get_mut_body_item_for_position(
&mut self,
pos: usize,
) -> Option<&mut BodyItem>
pub fn get_mut_body_item_for_position( &mut self, pos: usize, ) -> Option<&mut BodyItem>
Returns the body item that includes the given character position.
Sourcepub fn get_expr_for_position(&self, pos: usize) -> Option<&Expr>
pub fn get_expr_for_position(&self, pos: usize) -> Option<&Expr>
Returns an Expr that includes the given character position.
This is a bit more recursive than get_body_item_for_position.
Sourcepub fn has_import_statements(&self) -> bool
pub fn has_import_statements(&self) -> bool
Checks if the ast has any import statements.
pub fn in_comment(&self, pos: usize) -> bool
pub fn get_lsp_folding_ranges(&self) -> Vec<FoldingRange>
Sourcepub fn rename_symbol(&mut self, new_name: &str, pos: usize) -> bool
pub fn rename_symbol(&mut self, new_name: &str, pos: usize) -> bool
Rename the variable declaration at the given position.
Returns whether anything was actually renamed. Only top-level declarations, import aliases, and parameters of top-level functions are supported; a position inside a nested declaration (e.g. a local in a function body or an if-expression arm) renames nothing and returns false.
Sourcepub fn replace_variable(
&mut self,
name: &str,
declarator: Node<VariableDeclarator>,
)
pub fn replace_variable( &mut self, name: &str, declarator: Node<VariableDeclarator>, )
Replace a variable declaration with the given name with a new one.
Sourcepub fn replace_value(&mut self, source_range: SourceRange, new_value: Expr)
pub fn replace_value(&mut self, source_range: SourceRange, new_value: Expr)
Replace a value with the new value, use the source range for matching the exact value.
Sourcepub fn get_variable(&self, name: &str) -> Option<Definition<'_>>
pub fn get_variable(&self, name: &str) -> Option<Definition<'_>>
Get the variable declaration with the given name.
Source§impl Program
impl Program
pub fn recast_top( &self, options: &FormatOptions, indentation_level: usize, ) -> String
pub fn recast( &self, buf: &mut String, options: &FormatOptions, indentation_level: usize, )
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Program
impl<'de> Deserialize<'de> for Program
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Program
Source§impl TS for Program
impl TS for Program
Source§type WithoutGenerics = Program
type WithoutGenerics = Program
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that
EXPORT_TO must be None. Read moreSource§type OptionInnerType = Program
type OptionInnerType = Program
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete(cfg: &Config) -> String
fn decl_concrete(cfg: &Config) -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl(cfg: &Config) -> String
fn decl(cfg: &Config) -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline(cfg: &Config) -> String
fn inline(cfg: &Config) -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened(cfg: &Config) -> String
fn inline_flattened(cfg: &Config) -> String
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported, relative to the output directory.
The returned path does not include any base directory. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
Source§fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export. Read moreSource§fn export_to_string(cfg: &Config) -> Result<String, ExportError>where
Self: 'static,
fn export_to_string(cfg: &Config) -> Result<String, ExportError>where
Self: 'static,
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = !
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.