1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Build-side helpers for publishing grammar data into a Gritpack resolver snapshot.
//!
//! This module is intentionally narrow. It does not expose package installation,
//! refresh, or reconciliation. It only lets a compiler or driver attach grammar
//! specifications and external-driver payloads to an existing Gritpack project state.
//!
//! # Example
//!
//! ```no_run
//! use gritpack_searchlib::build::{persist_project_grammar_data, ResolverBuildInputs};
//! use gritpack_searchlib::grammar::{
//! CompletenessRules, DeclarationRules, ExternalDriverFilePayload,
//! ExternalDriverPayload, ExternalDriverRule, GrammarCapabilities, GrammarId,
//! GrammarSpec,
//! };
//!
//! # async fn demo() -> Result<(), gritpack_searchlib::CliError> {
//! let grammar = GrammarSpec {
//! id: GrammarId {
//! dialect: "lumen/1.0.0".to_string(),
//! name: "modules".to_string(),
//! version: 1,
//! },
//! capabilities: GrammarCapabilities {
//! authoritative_negative_lookup: true,
//! supports_prefix_queries: true,
//! supports_child_enumeration: true,
//! supports_multi_file_modules: false,
//! },
//! source_files: Default::default(),
//! namespace: Default::default(),
//! declarations: DeclarationRules::ExternalDriver(ExternalDriverRule {
//! name: "lumen/modules".to_string(),
//! }),
//! completeness: CompletenessRules {
//! negative_lookup_authoritative: true,
//! prefix_authoritative: true,
//! child_enumeration_authoritative: true,
//! },
//! };
//!
//! let inputs = ResolverBuildInputs {
//! grammar_specs: vec![grammar],
//! external_driver_payloads: vec![ExternalDriverPayload {
//! driver_name: "lumen/modules".to_string(),
//! files: vec![ExternalDriverFilePayload {
//! file_path: "/workspace/project/.gritpack/packages/dep/1.0.0/lumen_1.0.0/generic/src/lib.zing"
//! .to_string(),
//! declared_names: vec!["demo::thing".to_string()],
//! }],
//! }],
//! };
//!
//! persist_project_grammar_data(std::path::Path::new("/workspace/project"), &inputs).await?;
//! # Ok(())
//! # }
//! ```
use Path;
use crate;
use crateproject_packages_root;
use crate;
use crateCliError;
pub async