Clean up
This commit is contained in:
parent
c721164d99
commit
b6b427b2f2
2
build.rs
2
build.rs
@ -2,7 +2,7 @@ fn main() {
|
|||||||
let src_dir = std::path::Path::new("tree-sitter-dust/src");
|
let src_dir = std::path::Path::new("tree-sitter-dust/src");
|
||||||
|
|
||||||
let mut c_config = cc::Build::new();
|
let mut c_config = cc::Build::new();
|
||||||
c_config.include(&src_dir);
|
c_config.include(src_dir);
|
||||||
c_config
|
c_config
|
||||||
.flag_if_supported("-Wno-unused-parameter")
|
.flag_if_supported("-Wno-unused-parameter")
|
||||||
.flag_if_supported("-Wno-unused-but-set-variable")
|
.flag_if_supported("-Wno-unused-but-set-variable")
|
||||||
|
@ -65,7 +65,7 @@ impl AbstractTree for IfElse {
|
|||||||
} else {
|
} else {
|
||||||
let expressions = &self.else_if_expressions;
|
let expressions = &self.else_if_expressions;
|
||||||
|
|
||||||
for (index, expression) in expressions.into_iter().enumerate() {
|
for (index, expression) in expressions.iter().enumerate() {
|
||||||
let if_boolean = expression.run(source, context)?.as_boolean()?;
|
let if_boolean = expression.run(source, context)?.as_boolean()?;
|
||||||
|
|
||||||
if if_boolean {
|
if if_boolean {
|
||||||
|
@ -63,7 +63,7 @@ impl AbstractTree for Index {
|
|||||||
|
|
||||||
Ok(Value::String(item.to_string()))
|
Ok(Value::String(item.to_string()))
|
||||||
}
|
}
|
||||||
_ => return Err(Error::ExpectedCollection { actual: value }),
|
_ => Err(Error::ExpectedCollection { actual: value }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ impl AbstractTree for Select {
|
|||||||
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||||
let value = self.expression.run(source, context)?;
|
let value = self.expression.run(source, context)?;
|
||||||
let old_table = value.as_table()?;
|
let old_table = value.as_table()?;
|
||||||
let column_names = if self.identifiers.len() > 0 {
|
let column_names = if !self.identifiers.is_empty() {
|
||||||
self.identifiers
|
self.identifiers
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
|
@ -604,7 +604,7 @@ impl AbstractTree for Tool {
|
|||||||
.headers()
|
.headers()
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|column_name| Value::String(column_name))
|
.map(Value::String)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(Value::List(List::with_items(column_names)))
|
Ok(Value::List(List::with_items(column_names)))
|
||||||
|
@ -32,7 +32,7 @@ pub fn language() -> Language {
|
|||||||
/// The content of the [`node-types.json`][] file for this grammar.
|
/// The content of the [`node-types.json`][] file for this grammar.
|
||||||
///
|
///
|
||||||
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
||||||
pub const NODE_TYPES: &'static str = include_str!("../tree-sitter-dust/src/node-types.json");
|
pub const NODE_TYPES: &str = include_str!("../tree-sitter-dust/src/node-types.json");
|
||||||
|
|
||||||
// Uncomment these to include any queries that this grammar contains
|
// Uncomment these to include any queries that this grammar contains
|
||||||
|
|
||||||
|
@ -105,12 +105,12 @@ impl PartialOrd for Map {
|
|||||||
|
|
||||||
impl Display for Map {
|
impl Display for Map {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{{\n")?;
|
writeln!(f, "{{")?;
|
||||||
|
|
||||||
let variables = self.variables.read().unwrap().clone().into_iter();
|
let variables = self.variables.read().unwrap().clone().into_iter();
|
||||||
|
|
||||||
for (key, value) in variables {
|
for (key, value) in variables {
|
||||||
write!(f, " {key} = {value}\n")?;
|
writeln!(f, " {key} = {value}")?;
|
||||||
}
|
}
|
||||||
write!(f, "}}")
|
write!(f, "}}")
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ impl Display for Table {
|
|||||||
string.push_str(&value.to_string());
|
string.push_str(&value.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
string.push_str(")");
|
string.push(')');
|
||||||
|
|
||||||
string
|
string
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ impl Display for ValueType {
|
|||||||
ValueType::Boolean => write!(f, "boolean"),
|
ValueType::Boolean => write!(f, "boolean"),
|
||||||
ValueType::List(list) => {
|
ValueType::List(list) => {
|
||||||
write!(f, "(")?;
|
write!(f, "(")?;
|
||||||
for (index, item) in list.into_iter().enumerate() {
|
for (index, item) in list.iter().enumerate() {
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user