pub struct ExtractionPlan {Show 15 fields
pub lang: Lang,
pub enclosing_function: String,
pub parameters: Vec<String>,
pub parameter_spellings: Vec<String>,
pub returns: Vec<String>,
pub return_type: Option<String>,
pub returns_declared_mut: bool,
pub local_declarations: Vec<String>,
pub returns_need_declaration: bool,
pub start_byte: usize,
pub end_byte: usize,
pub indent: String,
pub insert_byte: usize,
pub enclosing_indent: String,
pub indent_unit: String,
}Expand description
A derived extraction, ready to be spelled by a language emitter.
Fields§
§lang: LangThe language the plan was derived from; the emitter reads it back so a plan cannot be rendered with another language’s spelling.
enclosing_function: StringThe function the range was taken out of.
parameters: Vec<String>Names read in the range before the range assigns them, that are bound in the enclosing function outside the range. Sorted, so the signature and the call site cannot disagree about argument order.
parameter_spellings: Vec<String>How each parameter is spelled in the new signature, positionally paired
with parameters. Identical to parameters in the untyped languages;
in TypeScript each entry carries the annotation copied from the name’s
existing binding, because a parameter list is the one place a derived
signature cannot stay silent about types.
returns: Vec<String>Names assigned in the range and read after it, in the same order rule.
return_type: Option<String>The new function’s declared return type, where the language requires
one. None everywhere the return is inferred.
returns_declared_mut: boolWhether a call site that declares what it receives has to declare it mutable, because something after the range assigns it.
local_declarations: Vec<String>Names the range only assigns, whose declaration stayed behind in the enclosing function. In a language where a bare assignment does not declare, the new function has to declare them itself or its body reads a name that is not there. Empty in Python, where assignment declares.
returns_need_declaration: boolWhether the call site must declare the returned names rather than assign them: true when the range carried their declaration away with it. Always false where declarations do not exist (Python).
start_byte: usizeByte range of the statements being hoisted.
end_byte: usize§indent: StringIndentation of the hoisted statements, so the emitter can re-indent the body and place the call at the same depth.
insert_byte: usizeByte offset where the new function is inserted: immediately after the enclosing function, at its own indentation.
enclosing_indent: StringIndentation of the enclosing function’s own declaration.
indent_unit: StringOne level of indentation as this file actually writes it, measured from the enclosing function’s own body rather than assumed. A file indented with tabs or two spaces gets a new function indented the same way.
Trait Implementations§
Source§impl Clone for ExtractionPlan
impl Clone for ExtractionPlan
Source§fn clone(&self) -> ExtractionPlan
fn clone(&self) -> ExtractionPlan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more