nushell/crates/nu-parser/src
Wind def36865ef
Enable reloading changes to a submodule (#13170)
# Description

Fixes: https://github.com/nushell/nushell/issues/12099

Currently if user run `use voice.nu`, and file is unchanged, then run
`use voice.nu` again. nushell will use the module directly, even if
submodule inside `voice.nu` is changed.

After discussed with @kubouch, I think it's ok to re-parse the module
file when:
1. It exports sub modules which are defined by a file
2. It uses other modules which are defined by a file

## About the change:
To achieve the behavior, we need to add 2 attributes to `Module`:
1. `imported_modules`: it tracks the other modules is imported by the
givem `module`, e.g: `use foo.nu`
2. `file`: the path of a module, if a module is defined by a file, it
will be `Some(path)`, or else it will be `None`.

After the change:

    use voice.nu always read the file and parse it.
    use voice will still use the module which is saved in EngineState.

# User-Facing Changes

use `xxx.nu` will read the file and parse it if it exports submodules or
uses submodules

# Tests + Formatting

Done

---------

Co-authored-by: Jakub Žádník <kubouch@gmail.com>
2024-06-25 18:33:37 -07:00
..
deparse.rs update deps calamine and quick-xml (#11582) 2024-01-19 12:23:51 -06:00
exportable.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
flatten.rs Move most of the peculiar argument handling for external calls into the parser (#13089) 2024-06-19 21:00:03 -07:00
known_external.rs Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00
lex.rs make better messages for incomplete string (#12868) 2024-05-15 01:14:11 +00:00
lib.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
lite_parser.rs Fix panic when redirecting nothing (#12970) 2024-05-27 10:03:06 +08:00
parse_keywords.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
parse_patterns.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parse_shape_specs.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parser.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
type_check.rs Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00