Make sure that imports are always in the same order between runs. This
makes the output more stable for putting it into a versioning system like git
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use log::warn;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use crate::compile::{Compile, CompileContext, FileGenerator};
|
||||
use crate::ir::{BaseType, EnumDefinition, ServiceDefinition, Step, Type, TypeDefinition};
|
||||
@ -46,7 +46,7 @@ impl RustCompiler {
|
||||
fn add_dependencies(
|
||||
&mut self,
|
||||
file: &mut FileGenerator,
|
||||
depends: &HashSet<BaseType>,
|
||||
depends: &BTreeSet<BaseType>,
|
||||
) -> Result<()> {
|
||||
for dep in depends {
|
||||
match dep {
|
||||
@ -409,7 +409,7 @@ impl RustCompiler {
|
||||
}
|
||||
|
||||
impl Compile for RustCompiler {
|
||||
fn new(options: &HashMap<String, String>) -> anyhow::Result<Self> {
|
||||
fn new(options: &BTreeMap<String, String>) -> anyhow::Result<Self> {
|
||||
let crate_name = if let Some(crate_name) = options.get("rust_crate") {
|
||||
crate_name.to_string()
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use anyhow::Result;
|
||||
use log::info;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use crate::compile::{Compile, CompileContext, FileGenerator};
|
||||
use crate::ir::{BaseType, EnumDefinition, ServiceDefinition, Step, Type, TypeDefinition};
|
||||
@ -109,9 +110,6 @@ impl<F: Flavour> TypeScriptCompiler<F> {
|
||||
fn type_to_typescript_ext(typ: &Type) -> String {
|
||||
let mut result = Self::type_to_typescript(&typ.0);
|
||||
let (optional, array, map) = typ.1.get_flags();
|
||||
if optional {
|
||||
result = format!("({} | undefined)", result);
|
||||
}
|
||||
if array {
|
||||
result = format!("({})[]", result);
|
||||
}
|
||||
@ -122,13 +120,17 @@ impl<F: Flavour> TypeScriptCompiler<F> {
|
||||
result
|
||||
);
|
||||
}
|
||||
if optional {
|
||||
// Optional should be the last modifier
|
||||
result = format!("({} | undefined)", result);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn add_dependencies(
|
||||
&mut self,
|
||||
file: &mut FileGenerator,
|
||||
depends: &HashSet<BaseType>,
|
||||
depends: &BTreeSet<BaseType>,
|
||||
) -> Result<()> {
|
||||
let esm = F::ext();
|
||||
file.a0(format!(
|
||||
@ -433,7 +435,7 @@ import {{ VerificationError }} from \"./ts_base{esm}\";
|
||||
}
|
||||
|
||||
impl<F: Flavour> Compile for TypeScriptCompiler<F> {
|
||||
fn new(options: &HashMap<String, String>) -> Result<Self> {
|
||||
fn new(options: &BTreeMap<String, String>) -> Result<Self> {
|
||||
let flavour = options
|
||||
.get("flavour")
|
||||
.cloned()
|
||||
@ -538,7 +540,7 @@ impl<F: Flavour> Compile for TypeScriptCompiler<F> {
|
||||
) -> anyhow::Result<()> {
|
||||
let mut f = FileGenerator::new();
|
||||
|
||||
self.add_dependencies(&mut f, &HashSet::new())?;
|
||||
self.add_dependencies(&mut f, &BTreeSet::new())?;
|
||||
|
||||
f.a0(format!("enum {} {{", definition.name));
|
||||
for value in &definition.values {
|
||||
|
Reference in New Issue
Block a user