Restructure nu-protocol in more meaningful units (#11917)

This is partially "feng-shui programming" of moving things to new
separate places.

The later commits include "`git blame` tollbooths" by moving out chunks
of code into new files, which requires an extra step to track things
with `git blame`. We can negiotiate if you want to keep particular
things in their original place.

If egregious I tried to add a bit of documentation. If I see something
that is unused/unnecessarily `pub` I will try to remove that.


- Move `nu_protocol::Exportable` to `nu-parser`
- Guess doccomment for `Exportable`
- Move `Unit` enum from `value` to `AST`
- Move engine state `Variable` def into its folder
- Move error-related files in `nu-protocol` subdir
- Move `pipeline_data` module into its own folder
- Move `stream.rs` over into the `pipeline_data` mod
- Move `PipelineMetadata` into its own file
- Doccomment `PipelineMetadata`
- Remove unused `is_leap_year` in `value/mod`
- Note about criminal `type_compatible` helper
- Move duration fmting into new `value/duration.rs`
- Move filesize fmting logic to new `value/filesize`
- Split reexports from standard imports in `value/mod`
- Doccomment trait `CustomValue`
- Polish doccomments and intradoc links
This commit is contained in:
Stefan Holderbach
2024-03-10 18:45:45 +01:00
committed by GitHub
parent 067ceedf79
commit f695ba408a
26 changed files with 392 additions and 358 deletions

View File

@ -0,0 +1,8 @@
use nu_protocol::{DeclId, ModuleId, VarId};
/// Symbol that can be exported with its associated name and ID
pub enum Exportable {
Decl { name: Vec<u8>, id: DeclId },
Module { name: Vec<u8>, id: ModuleId },
VarDecl { name: Vec<u8>, id: VarId },
}

View File

@ -1,4 +1,5 @@
mod deparse;
mod exportable;
mod flatten;
mod known_external;
mod lex;

View File

@ -1,4 +1,5 @@
use crate::{
exportable::Exportable,
parse_block,
parser_path::ParserPath,
type_check::{check_block_input_output, type_compatible},
@ -13,7 +14,7 @@ use nu_protocol::{
},
engine::{StateWorkingSet, DEFAULT_OVERLAY_NAME},
eval_const::eval_constant,
span, Alias, BlockId, DeclId, Exportable, Module, ModuleId, ParseError, PositionalArg,
span, Alias, BlockId, DeclId, Module, ModuleId, ParseError, PositionalArg,
ResolvedImportPattern, Span, Spanned, SyntaxShape, Type, Value, VarId,
};
use std::collections::{HashMap, HashSet};