Span ID Refactor - Step 1 (#12960)

# Description
First part of SpanID refactoring series. This PR adds a `SpanId` type
and a corresponding `span_id` field to `Expression`. Parser creating
expressions will now add them to an array in `StateWorkingSet`,
generates a corresponding ID and saves the ID to the Expression. The IDs
are not used anywhere yet.

For the rough overall plan, see
https://github.com/nushell/nushell/issues/12963.

# User-Facing Changes
Hopefully none. This is only a refactor of Nushell's internals that
shouldn't have visible side effects.

# Tests + Formatting

# After Submitting
This commit is contained in:
Jakub Žádník
2024-06-05 04:57:14 +03:00
committed by GitHub
parent b10325dff1
commit e4104d0792
14 changed files with 1029 additions and 1050 deletions

View File

@ -56,12 +56,12 @@ pub fn from_nuon(input: &str, span: Option<Span>) -> Result<Value, ShellError> {
}
let expr = if block.pipelines.is_empty() {
Expression {
expr: Expr::Nothing,
span: span.unwrap_or(Span::unknown()),
custom_completion: None,
ty: Type::Nothing,
}
Expression::new(
&mut working_set,
Expr::Nothing,
span.unwrap_or(Span::unknown()),
Type::Nothing,
)
} else {
let mut pipeline = Arc::make_mut(&mut block).pipelines.remove(0);
@ -81,12 +81,12 @@ pub fn from_nuon(input: &str, span: Option<Span>) -> Result<Value, ShellError> {
}
if pipeline.elements.is_empty() {
Expression {
expr: Expr::Nothing,
span: span.unwrap_or(Span::unknown()),
custom_completion: None,
ty: Type::Nothing,
}
Expression::new(
&mut working_set,
Expr::Nothing,
span.unwrap_or(Span::unknown()),
Type::Nothing,
)
} else {
pipeline.elements.remove(0).expr
}