diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml
index c10ea2aa..9f600e58 100644
--- a/.github/workflows/github-release.yml
+++ b/.github/workflows/github-release.yml
@@ -23,7 +23,8 @@ jobs:
outputs:
new-ezno-version: ${{ steps.get-version.outputs.new-ezno-version }}
new-ezno-version-name: ${{ steps.get-version.outputs.new-ezno-version-name }}
- sponsors: ${{ steps.get-sponsors.outputs.sponsors }}
+ SPONSORS: ${{ steps.get-data.outputs.SPONSORS }}
+ CONTRIBUTORS: ${{ steps.get-data.outputs.CONTRIBUTORS }}
steps:
- uses: actions/checkout@v4
@@ -55,7 +56,7 @@ jobs:
echo "new-ezno-version-name=${NAME_VERSION}" >> $GITHUB_OUTPUT
fi
- - id: get-sponsors
+ - id: get-data
run: |
SPONSORS=$(gh api graphql -f query='{
user(login: "kaleidawave") {
@@ -71,7 +72,24 @@ jobs:
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")')
- echo "sponsors=$SPONSORS" >> $GITHUB_OUTPUT
+ echo "SPONSORS=$SPONSORS" >> $GITHUB_OUTPUT
+
+ CONTRIBUTORS=$(gh api graphql -f query='{
+ repository(owner: "kaleidawave", name: "ezno") {
+ pullRequests(first: 100, states: 'MERGED') {
+ edges {
+ node {
+ author {
+ login
+ }
+ }
+ }
+ }
+ }
+ }' -q '.data.repository.pullRequests.edges | map(.node.author.login) | unique | join(", ")')
+
+ echo "CONTRIBUTORS=$CONTRIBUTORS"
+
shell: bash
env:
GH_TOKEN: ${{ github.token }}
@@ -103,7 +121,8 @@ jobs:
- name: Build binary
run: cargo build --release
env:
- SPONSORS: ${{ needs.get-build-info.outputs.sponsors }}
+ SPONSORS: ${{ needs.get-build-info.outputs.SPONSORS }}
+ CONTRIBUTORS: ${{ needs.get-build-info.outputs.CONTRIBUTORS }}
- name: Rename and move release assets
run: |
diff --git a/.github/workflows/lines-of-code.yml b/.github/workflows/lines-of-code.yml
index 52364079..6f32723e 100644
--- a/.github/workflows/lines-of-code.yml
+++ b/.github/workflows/lines-of-code.yml
@@ -22,20 +22,26 @@ jobs:
- name: Run update script
run: |
- cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r name version pathInfo ; do
- path=${pathInfo:13:-1}
- if [[ -d "$path/src" ]] ; then
- linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$path/src" | jq '.[] | .Code');
+ function record {
+ cratePath=$1
+ name=$2
+
+ if [ -d "$cratePath/src" ] ; then
+ linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$cratePath/src" | jq '.[] | .Code');
else
- linesOfRustCode=$(scc -c --no-cocomo -f json -i rs $path | jq '.[] | .Code');
+ linesOfRustCode=$(scc -c --no-cocomo -f json -i rs "$cratePath" | jq '.[] | .Code');
fi
-
+
+ echo "\`$name\` has $linesOfRustCode lines of code" # >> $GITHUB_STEP_SUMMARY;
+
curl \
--header "Content-Type: application/json" \
--header "X-POST-ACCESS-KEY: ${{ secrets.PROJECTS_POST_ACCESS_KEY }}" \
--data "{\"project\":\"$name\",\"language\":\"rust\",\"loc\":$linesOfRustCode}" \
-w "\nUpdated-project: \n" \
https://projects.kaleidawave.workers.dev/update-project;
+ }
- echo "\`$name\` has $linesOfRustCode lines of code" >> $GITHUB_STEP_SUMMARY;
- done
\ No newline at end of file
+ record "parser" "ezno-parser"
+ record "checker" "ezno-checker"
+ record "src" "ezno"
\ No newline at end of file
diff --git a/.github/workflows/performance-and-size.yml b/.github/workflows/performance-and-size.yml
index 94cda873..a5236504 100644
--- a/.github/workflows/performance-and-size.yml
+++ b/.github/workflows/performance-and-size.yml
@@ -46,10 +46,6 @@ jobs:
env:
CARGO_PROFILE_RELEASE_DEBUG: true
- - name: Download files
- run: |
- curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js
-
- name: Run checker performance
shell: bash
run: |
@@ -58,12 +54,6 @@ jobs:
# Generate a file which contains everything that Ezno currently implements
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md ./demo.ts
- echo "::group::Generated demo.ts"
- cat ./demo.ts
-
- cargo run -p ezno-parser --example parse demo.ts --timings
- echo "::endgroup::"
-
echo "::info::Finished file generation"
echo "
@@ -89,7 +79,7 @@ jobs:
# Printing diagnostics, so turn colors off for GH Summary (also affects printing perf I think)
NO_COLOR=1
- ./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY
+ (./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY) || true
echo "\`\`\`
@@ -105,6 +95,10 @@ jobs:
echo "::group::Comparing printing of diagnostics"
hyperfine -i './target/release/ezno check demo.ts' './target/release/ezno check demo.ts --count-diagnostics'
echo "::endgroup::"
+
+ - name: Download parser files
+ run: |
+ curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js
- name: Run parser, minfier/stringer performance
shell: bash
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 4bb3ef30..37fde6c6 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -74,7 +74,24 @@ jobs:
}
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")')
- echo "sponsors=$SPONSORS" >> $GITHUB_OUTPUT
+ echo "SPONSORS=$SPONSORS" >> $GITHUB_OUTPUT
+
+ CONTRIBUTORS=$(gh api graphql -f query='{
+ repository(owner: "kaleidawave", name: "ezno") {
+ pullRequests(first: 100, states: 'MERGED') {
+ edges {
+ node {
+ author {
+ login
+ }
+ }
+ }
+ }
+ }
+ }' -q '.data.repository.pullRequests.edges | map(.node.author.login) | unique | join(", ")')
+
+ echo "CONTRIBUTORS=$CONTRIBUTORS"
+
shell: bash
env:
GH_TOKEN: ${{ github.token }}
@@ -86,7 +103,8 @@ jobs:
version: ${{ steps.set-arguments.outputs.publish-json-args }}
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
- SPONSORS: ${{ steps.get-sponsors.outputs.sponsors }}
+ SPONSORS: ${{ steps.get-sponsors.outputs.SPONSORS }}
+ CONTRIBUTORS: ${{ steps.get-sponsors.outputs.CONTRIBUTORS }}
- name: Add WASM to rustup
if: ${{ inputs.ezno-version != 'none' }}
diff --git a/checker/src/synthesis/assignments.rs b/checker/src/synthesis/assignments.rs
index aa15ece3..2107d2f9 100644
--- a/checker/src/synthesis/assignments.rs
+++ b/checker/src/synthesis/assignments.rs
@@ -159,10 +159,10 @@ fn synthesise_object_shorthand_assignable(
fn synthesise_object_property_key(
name: &parser::VariableIdentifier,
- environment: &Environment,
+ _environment: &Environment,
) -> PropertyKey<'static> {
match name {
- parser::VariableIdentifier::Standard(name, pos) => {
+ parser::VariableIdentifier::Standard(name, _pos) => {
PropertyKey::String(Cow::Owned(name.to_owned()))
}
parser::VariableIdentifier::Marker(..) => todo!(),
diff --git a/checker/src/types/calling.rs b/checker/src/types/calling.rs
index 235f31fc..9c9ed92c 100644
--- a/checker/src/types/calling.rs
+++ b/checker/src/types/calling.rs
@@ -963,7 +963,7 @@ impl FunctionType {
match type_is_subtype {
SubTypeResult::IsSubType => {}
- SubTypeResult::IsNotSubType(reason) => {
+ SubTypeResult::IsNotSubType(_reason) => {
errors.errors.push(FunctionCallingError::MismatchedThis {
expected: TypeStringRepresentation::from_type_id(
free_this_id,
diff --git a/checker/src/types/poly_types/generics/generic_structure.rs b/checker/src/types/poly_types/generics/generic_structure.rs
index c9439c98..9c1c721d 100644
--- a/checker/src/types/poly_types/generics/generic_structure.rs
+++ b/checker/src/types/poly_types/generics/generic_structure.rs
@@ -1,15 +1,7 @@
-use super::generic_type_arguments::FunctionTypeArguments;
use crate::TypeId;
-/// A instance of a generic typed object
-#[derive(Clone, Debug)]
-pub struct GenericStructure {
- pub generic_type: TypeId,
- pub arguments: GenericStructureTypeArguments,
-}
-
-#[derive(Clone, Debug, Default)]
-pub struct GenericStructureTypeArguments(pub(crate) Vec);
+// #[derive(Clone, Debug, Default)]
+// pub struct GenericStructureTypeArguments(pub(crate) Vec);
#[derive(Clone, Debug)]
pub enum GenericStructureArgumentValue {
@@ -41,16 +33,16 @@ pub struct GenericStructureTypeArgument {
// pub(crate) constraint: Option>,
}
-impl From for FunctionTypeArguments {
- fn from(_instance_of_generics_arguments: GenericStructureTypeArguments) -> Self {
- todo!()
- // TypeArguments {
- // structure_arguments: todo!(),
- // local_arguments: todo!(),
- // environment: todo!(),
- // }
- // Cow::Owned(
- // instance_of_generics_arguments.into(),
- // ))
- }
-}
+// impl From for FunctionTypeArguments {
+// fn from(_instance_of_generics_arguments: GenericStructureTypeArguments) -> Self {
+// todo!()
+// // TypeArguments {
+// // structure_arguments: todo!(),
+// // local_arguments: todo!(),
+// // environment: todo!(),
+// // }
+// // Cow::Owned(
+// // instance_of_generics_arguments.into(),
+// // ))
+// }
+// }
diff --git a/checker/src/types/poly_types/generics/generic_type_arguments.rs b/checker/src/types/poly_types/generics/generic_type_arguments.rs
index 60e17754..40528333 100644
--- a/checker/src/types/poly_types/generics/generic_type_arguments.rs
+++ b/checker/src/types/poly_types/generics/generic_type_arguments.rs
@@ -11,15 +11,7 @@ use crate::{
use map_vec::Map as SmallMap;
use source_map::{Nullable, SpanWithSource};
-use std::{fmt::Debug, iter::FromIterator};
-
-use super::{GenericStructureTypeArgument, GenericStructureTypeArguments};
-
-impl FromIterator for GenericStructureTypeArguments {
- fn from_iter>(iter: I) -> Self {
- Self(iter.into_iter().collect())
- }
-}
+use std::fmt::Debug;
/// For when a function is called
#[derive(Debug)]
diff --git a/src/ast_explorer.rs b/src/ast_explorer.rs
index fba74cd8..524b5057 100644
--- a/src/ast_explorer.rs
+++ b/src/ast_explorer.rs
@@ -8,7 +8,7 @@ use enum_variants_strings::EnumVariantsStrings;
use parser::{source_map::FileSystem, ASTNode, Expression, Module, ToStringOptions};
use crate::{
- error_handling::emit_ezno_diagnostic,
+ reporting::emit_diagnostics,
utilities::{print_to_cli, print_to_cli_without_newline},
};
@@ -136,7 +136,9 @@ impl ExplorerSubCommand {
}
}
// TODO temp
- Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
+ Err(err) => {
+ emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
+ }
}
}
ExplorerSubCommand::FullAST(cfg) => {
@@ -156,7 +158,9 @@ impl ExplorerSubCommand {
}
}
// TODO temp
- Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
+ Err(err) => {
+ emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
+ }
}
}
ExplorerSubCommand::Prettifier(_) | ExplorerSubCommand::Uglifier(_) => {
@@ -173,7 +177,9 @@ impl ExplorerSubCommand {
};
print_to_cli(format_args!("{}", module.to_string(&options)));
}
- Err(err) => emit_ezno_diagnostic((err, source_id).into(), &fs).unwrap(),
+ Err(err) => {
+ emit_diagnostics(std::iter::once((err, source_id).into()), &fs).unwrap()
+ }
}
}
ExplorerSubCommand::Lexer(_) => {
diff --git a/src/cli.rs b/src/cli.rs
index 7b3a01ab..26aa0b59 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -4,6 +4,7 @@ use std::{
env, fs,
path::{Path, PathBuf},
process::Command,
+ process::ExitCode,
time::Instant,
};
@@ -11,7 +12,7 @@ use crate::{
build::{build, BuildOutput, FailedBuildOutput},
build::{BuildConfig, EznoParsePostCheckVisitors},
check::check,
- error_handling::emit_ezno_diagnostic,
+ reporting::emit_diagnostics,
utilities::print_to_cli,
};
use argh::FromArgs;
@@ -54,6 +55,7 @@ pub(crate) struct ExperimentalArguments {
#[argh(subcommand)]
pub(crate) enum ExperimentalSubcommand {
Build(BuildArguments),
+ Format(FormatArguments),
}
/// Build project
@@ -123,6 +125,15 @@ pub(crate) struct CheckArguments {
pub count_diagnostics: bool,
}
+/// Formats file in-place
+#[derive(FromArgs, PartialEq, Debug)]
+#[argh(subcommand, name = "format")]
+pub(crate) struct FormatArguments {
+ /// path to input file
+ #[argh(positional)]
+ pub path: PathBuf,
+}
+
// /// Run project using Deno
// #[derive(FromArgs, PartialEq, Debug)]
// #[argh(subcommand, name = "run")]
@@ -157,18 +168,19 @@ pub fn run_cli ExitCode {
let command = match FromArgs::from_args(&["ezno-cli"], cli_arguments) {
Ok(TopLevel { nested }) => nested,
Err(err) => {
print_to_cli(format_args!("{}", err.output));
- return;
+ return ExitCode::FAILURE;
}
};
match command {
CompilerSubCommand::Info(_) => {
crate::utilities::print_info();
+ ExitCode::SUCCESS
}
CompilerSubCommand::Check(check_arguments) => {
let CheckArguments { input, watch: _, definition_file, timings, count_diagnostics } =
@@ -189,17 +201,16 @@ pub fn run_cli {
- for diagnostic in diagnostics {
- emit_ezno_diagnostic(diagnostic, &fs).unwrap();
- }
+ emit_diagnostics(diagnostics, &fs).unwrap();
+ ExitCode::FAILURE
}
}
}
- CompilerSubCommand::ASTExplorer(mut repl) => repl.run(read_file, cli_input_resolver),
- CompilerSubCommand::Repl(argument) => crate::repl::run_repl(cli_input_resolver, argument),
- // CompilerSubCommand::Run(run_arguments) => {
- // let build_arguments = BuildArguments {
- // input: run_arguments.input,
- // output: Some(run_arguments.output.clone()),
- // minify: true,
- // no_comments: true,
- // source_maps: false,
- // watch: false,
- // timings: false,
- // };
- // let output = build(build_arguments);
+ CompilerSubCommand::Experimental(ExperimentalArguments {
+ nested: ExperimentalSubcommand::Format(FormatArguments { path }),
+ }) => {
+ use parser::{source_map::FileSystem, ASTNode, Module, ToStringOptions};
- // if output.is_ok() {
- // Command::new("deno")
- // .args(["run", "--allow-all", run_arguments.output.to_str().unwrap()])
- // .spawn()
- // .unwrap()
- // .wait()
- // .unwrap();
- // }
- // }
- // #[cfg(debug_assertions)]
- // CompilerSubCommand::Pack(Pack { input, output }) => {
- // let file = checker::definition_file_to_buffer(
- // &file_system_resolver,
- // &env::current_dir().unwrap(),
- // &input,
- // )
- // .unwrap();
+ let input = match fs::read_to_string(&path) {
+ Ok(string) => string,
+ Err(err) => {
+ print_to_cli(format_args!("{err:?}"));
+ return ExitCode::FAILURE;
+ }
+ };
+ let mut files =
+ parser::source_map::MapFileStore::::default();
+ let source_id = files.new_source_id(path.clone(), input.clone());
+ let res = Module::from_string(input, Default::default());
+ match res {
+ Ok(module) => {
+ let options =
+ ToStringOptions { trailing_semicolon: true, ..Default::default() };
+ let _ = fs::write(path, &module.to_string(&options));
+ ExitCode::SUCCESS
+ }
+ Err(err) => {
+ emit_diagnostics(std::iter::once((err, source_id).into()), &files).unwrap();
+ ExitCode::FAILURE
+ }
+ }
+ }
+ CompilerSubCommand::ASTExplorer(mut repl) => {
+ repl.run(read_file, cli_input_resolver);
+ // TODO not always true
+ ExitCode::SUCCESS
+ }
+ CompilerSubCommand::Repl(argument) => {
+ crate::repl::run_repl(cli_input_resolver, argument);
+ // TODO not always true
+ ExitCode::SUCCESS
+ } // CompilerSubCommand::Run(run_arguments) => {
+ // let build_arguments = BuildArguments {
+ // input: run_arguments.input,
+ // output: Some(run_arguments.output.clone()),
+ // minify: true,
+ // no_comments: true,
+ // source_maps: false,
+ // watch: false,
+ // timings: false,
+ // };
+ // let output = build(build_arguments);
- // std::fs::write(&output, &file).unwrap();
- // // println!("Wrote binary context out to {}", output.display());
+ // if output.is_ok() {
+ // Command::new("deno")
+ // .args(["run", "--allow-all", run_arguments.output.to_str().unwrap()])
+ // .spawn()
+ // .unwrap()
+ // .wait()
+ // .unwrap();
+ // }
+ // }
+ // #[cfg(debug_assertions)]
+ // CompilerSubCommand::Pack(Pack { input, output }) => {
+ // let file = checker::definition_file_to_buffer(
+ // &file_system_resolver,
+ // &env::current_dir().unwrap(),
+ // &input,
+ // )
+ // .unwrap();
- // let _root_ctx = checker::root_context_from_bytes(file);
- // println!("Registered {} types", _root_ctx.types.len());
- // }
+ // let _root_ctx = checker::root_context_from_bytes(file);
+ // println!("Registered {} types", _root_ctx.types.len();
+ // }
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 2d990729..a81c0908 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,8 +1,8 @@
mod ast_explorer;
mod build;
mod check;
-mod error_handling;
mod repl;
+mod reporting;
pub(crate) mod utilities;
diff --git a/src/main.rs b/src/main.rs
index 1752f675..6d50911e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,7 +38,7 @@ pub(crate) fn cli_input_resolver(prompt: &str) -> String {
input
}
-fn main() {
+fn main() -> std::process::ExitCode {
fn read_from_file(path: &std::path::Path) -> Option {
std::fs::read_to_string(path).ok()
}
@@ -50,5 +50,5 @@ fn main() {
let arguments = std::env::args().skip(1).collect::>();
let arguments = arguments.iter().map(String::as_str).collect::>();
- run_cli(&arguments, &read_from_file, write_to_file, |p| Some(cli_input_resolver(p)));
+ run_cli(&arguments, &read_from_file, write_to_file, |p| Some(cli_input_resolver(p)))
}
diff --git a/src/repl.rs b/src/repl.rs
index c8a345a9..0f26e606 100644
--- a/src/repl.rs
+++ b/src/repl.rs
@@ -5,7 +5,7 @@ use argh::FromArgs;
use parser::{visiting::VisitorsMut, ASTNode};
use parser::{Expression, Module, Statement};
-use crate::error_handling::emit_ezno_diagnostic;
+use crate::reporting::emit_diagnostics;
use crate::utilities::print_to_cli;
/// Run project repl using deno. (`deno` command must be in path)
@@ -50,9 +50,7 @@ pub(crate) fn run_repl(
let mut state = match state {
Ok(state) => state,
Err((diagnostics, fs)) => {
- for diagnostic in diagnostics {
- emit_ezno_diagnostic(diagnostic, &fs).unwrap();
- }
+ emit_diagnostics(diagnostics, &fs).unwrap();
return;
}
};
@@ -91,7 +89,8 @@ pub(crate) fn run_repl(
let mut item = match result {
Ok(item) => item,
Err(err) => {
- emit_ezno_diagnostic((err, source).into(), state.get_fs_ref()).unwrap();
+ emit_diagnostics(std::iter::once((err, source).into()), state.get_fs_ref())
+ .unwrap();
continue;
}
};
@@ -112,17 +111,13 @@ pub(crate) fn run_repl(
match result {
Ok((last_ty, diagnostics)) => {
- for diagnostic in diagnostics {
- emit_ezno_diagnostic(diagnostic, state.get_fs_ref()).unwrap();
- }
+ emit_diagnostics(diagnostics, state.get_fs_ref()).unwrap();
if let Some(last_ty) = last_ty {
println!("{last_ty}");
}
}
Err(diagnostics) => {
- for diagnostic in diagnostics {
- emit_ezno_diagnostic(diagnostic, state.get_fs_ref()).unwrap();
- }
+ emit_diagnostics(diagnostics, state.get_fs_ref()).unwrap();
}
}
}
diff --git a/src/error_handling.rs b/src/reporting.rs
similarity index 61%
rename from src/error_handling.rs
rename to src/reporting.rs
index aa31a715..00ae4aac 100644
--- a/src/error_handling.rs
+++ b/src/reporting.rs
@@ -2,16 +2,22 @@ use std::iter;
use codespan_reporting::{
diagnostic::{Diagnostic, Label, Severity},
- files::Files,
term::{emit, Config},
};
-use parser::source_map::FileSystem;
+use parser::{source_map::FileSystem, SourceId};
-pub(crate) fn emit_ezno_diagnostic(
+fn ezno_diagnostic_to_severity(kind: &checker::DiagnosticKind) -> Severity {
+ match kind {
+ checker::DiagnosticKind::Error => Severity::Error,
+ checker::DiagnosticKind::Warning => Severity::Warning,
+ checker::DiagnosticKind::Info => Severity::Note,
+ }
+}
+
+fn checker_diagnostic_to_codespan_diagnostic(
diagnostic: checker::Diagnostic,
- fs: &impl FileSystem,
-) -> Result<(), codespan_reporting::files::Error> {
- let diagnostic = match diagnostic {
+) -> Diagnostic {
+ match diagnostic {
checker::Diagnostic::Global { reason, kind } => Diagnostic {
severity: ezno_diagnostic_to_severity(&kind),
code: None,
@@ -43,46 +49,41 @@ pub(crate) fn emit_ezno_diagnostic(
notes: notes.into_iter().map(|(message, _)| message).collect(),
}
}
- };
-
- emit_diagnostic(&diagnostic, &fs.into_code_span_store())
-}
-
-fn ezno_diagnostic_to_severity(kind: &checker::DiagnosticKind) -> Severity {
- match kind {
- checker::DiagnosticKind::Error => Severity::Error,
- checker::DiagnosticKind::Warning => Severity::Warning,
- checker::DiagnosticKind::Info => Severity::Note,
}
}
-#[cfg(target_family = "wasm")]
-fn emit_diagnostic<'files, F: Files<'files>>(
- diagnostic: &Diagnostic<>::FileId>,
- files: &'files F,
+pub(crate) fn emit_diagnostics(
+ diagnostics: impl IntoIterator- ,
+ fs: &impl FileSystem,
) -> Result<(), codespan_reporting::files::Error> {
- use crate::utilities::print_to_cli;
- use codespan_reporting::term::termcolor::Buffer;
+ use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
+ // TODO custom here
let config = Config::default();
- let mut buffer = Buffer::ansi();
- emit(&mut buffer, &config, files, diagnostic).unwrap();
- let output = String::from_utf8(buffer.into_inner()).expect("invalid string from diagnostic");
- print_to_cli(format_args!("{output}"));
- Ok(())
-}
+ #[cfg(target_family = "wasm")]
+ {}
-#[cfg(not(target_family = "wasm"))]
-fn emit_diagnostic<'files, F: Files<'files>>(
- diagnostic: &Diagnostic<>::FileId>,
- files: &'files F,
-) -> Result<(), codespan_reporting::files::Error> {
- use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
+ #[cfg(not(target_family = "wasm"))]
+ let mut writer = StandardStream::stderr(ColorChoice::Auto);
- let config = Config::default();
+ let files = fs.into_code_span_store();
+
+ for diagnostic in diagnostics {
+ let diagnostic = checker_diagnostic_to_codespan_diagnostic(diagnostic);
+
+ #[cfg(target_family = "wasm")]
+ {
+ let mut buffer = codespan_reporting::term::termcolor::Buffer::ansi();
+ emit(&mut buffer, &config, &files, &diagnostic)?;
+ let output =
+ String::from_utf8(buffer.into_inner()).expect("invalid string from diagnostic");
+ crate::utilities::print_to_cli(format_args!("{output}"));
+ }
- let writer = StandardStream::stderr(ColorChoice::Auto);
- let mut lock = writer.lock();
- emit(&mut lock, &config, files, diagnostic)
+ #[cfg(not(target_family = "wasm"))]
+ emit(&mut writer, &config, &files, &diagnostic)?;
+ }
+
+ Ok(())
}
diff --git a/src/utilities.rs b/src/utilities.rs
index 670a2526..2f6dad4b 100644
--- a/src/utilities.rs
+++ b/src/utilities.rs
@@ -1,8 +1,5 @@
use std::fmt::Arguments;
-const SPONSORS_PATH: &str = "https://github.com/sponsors/kaleidawave";
-const SPONSORS: Option<&'static str> = option_env!("SPONSORS");
-
pub(crate) fn print_info() {
if let Some(run_id) = option_env!("GITHUB_RUN_ID") {
print_to_cli(format_args!(
@@ -19,12 +16,18 @@ pub(crate) fn print_info() {
env!("CARGO_PKG_REPOSITORY"),
env!("CARGO_PKG_LICENSE")
));
- if let Some(sponsors) = SPONSORS {
- print_to_cli(format_args!("Supported by: {sponsors}. Join them @ {SPONSORS_PATH}"));
- } else {
- print_to_cli(format_args!("Support the project @ {SPONSORS_PATH}"));
- }
print_to_cli(format_args!("For help run --help"));
+ if let (Some(sponsors), Some(contributors)) =
+ (option_env!("SPONSORS"), option_env!("CONTRIBUTORS"))
+ {
+ print_to_cli(format_args!("---"));
+ print_to_cli(format_args!("With thanks to"));
+ print_to_cli(format_args!("Contributors: {contributors}"));
+ print_to_cli(format_args!(
+ "Supporters (https://github.com/sponsors/kaleidawave): {sponsors}"
+ ));
+ print_to_cli(format_args!("and all the believers ✨"));
+ }
}
#[cfg(target_family = "wasm")]