1mod classfile;
10mod files;
11pub mod index;
12mod jvm;
13mod macros;
14mod versions;
15
16use yog_data::Diagnostic;
17
18pub use files::FilesBeside;
19pub use jvm::{JvmBuild, build_jar};
20pub use macros::MacroLibrary;
21pub use yog_script_analyze::versions::targeted;
22
23#[must_use]
27pub fn check_source(name: &str, text: &str) -> Vec<Diagnostic> {
28 check_source_with(name, text, index::load)
29}
30
31pub fn check_source_with(
33 name: &str,
34 text: &str,
35 load: impl Fn(&str) -> Result<index::ClassIndex, String>,
36) -> Vec<Diagnostic> {
37 check_source_using(name, text, load, Project::default())
38}
39
40#[derive(Default, Clone, Copy)]
43pub struct Project<'a> {
44 pub macros: Option<&'a MacroLibrary>,
45 pub files: Option<&'a dyn yog_script_analyze::macros::ModFiles>,
47 pub to_server: bool,
48 pub content: Option<&'a [(String, String)]>,
51 pub others: &'a [&'a [yog_script_analyze::ast::Decl]],
53}
54
55pub fn check_source_using(
57 name: &str,
58 text: &str,
59 load: impl Fn(&str) -> Result<index::ClassIndex, String>,
60 project: Project<'_>,
61) -> Vec<Diagnostic> {
62 let env = yog_script_analyze::Env {
63 game: None,
64 macros: project
65 .macros
66 .map(|m| m as &dyn yog_script_analyze::macros::ProcMacros),
67 files: project.files,
68 to_server: project.to_server,
69 content: project.content,
70 others: project.others,
71 };
72 if !yog_script_analyze::is_nanites(name) {
73 return yog_script_analyze::check_in(name, text, env).problems;
74 }
75 versions::check(name, text, load, env)
76}