diff --git a/src/enum_def.rs b/src/enum_def.rs index 7c550ee4..78e12242 100644 --- a/src/enum_def.rs +++ b/src/enum_def.rs @@ -432,9 +432,7 @@ impl Literal_ { "null_literal" => Self::Null, "int" => Self::Int(n.value()), "string_literal" => Self::Str(n.value()), - "decimal_floating_point_literal" => { - Self::Decimal(n.value().to_lowercase()) - } + "decimal_floating_point_literal" => Self::Decimal(n.value().to_lowercase()), _ => panic_unknown_node(n, "Literal_"), } } @@ -893,7 +891,7 @@ pub enum SelectableExpression { Value(ValueExpression), Alias(AliasExpression), //Type(TypeOfClause), - //Fields(FieldsExpression), + Fields(FieldsExpression), Sub(SubQuery), } @@ -905,6 +903,7 @@ impl SelectableExpression { FunctionExpression::new(node), ))), "alias_expression" => Self::Alias(AliasExpression::new(node)), + "fields_expression" => Self::Fields(FieldsExpression::new(node)), "subquery" => Self::Sub(SubQuery::new(node)), _ => panic_unknown_node(node, "SelectableExpression"), } @@ -920,6 +919,9 @@ impl<'a> DocBuild<'a> for SelectableExpression { Self::Alias(n) => { result.push(n.build(b)); } + Self::Fields(n) => { + result.push(n.build(b)); + } Self::Sub(n) => { result.push(n.build(b)); } @@ -927,6 +929,28 @@ impl<'a> DocBuild<'a> for SelectableExpression { } } +#[derive(Debug)] +pub struct FieldsExpression { + fields_type: String, +} + +impl FieldsExpression { + pub fn new(node: Node) -> Self { + assert_check(node, "fields_expression"); + + let fields_type = node.cvalue_by_k("fields_type").to_uppercase(); + Self { fields_type } + } +} + +impl<'a> DocBuild<'a> for FieldsExpression { + fn build_inner(&self, b: &'a DocBuilder<'a>, result: &mut Vec>) { + result.push(b.txt("FIELDS(")); + result.push(b.txt(&self.fields_type)); + result.push(b.txt(")")); + } +} + #[derive(Debug)] pub struct AliasExpression { value_exp: ValueExpression, @@ -1407,9 +1431,7 @@ impl DateLiteralWithParam { pub fn new(node: Node) -> Self { assert_check(node, "date_literal_with_param"); - let date_literal = node - .cvalue_by_k("date_literal") - .to_uppercase(); + let date_literal = node.cvalue_by_k("date_literal").to_uppercase(); let param = node.cvalue_by_k("int"); Self { diff --git a/test.cls b/test.cls index 9893ed6d..72aa4e68 100644 --- a/test.cls +++ b/test.cls @@ -1,36 +1,5 @@ global class PluginDescribeResult { - global class InputParameter { - global String description; - global String name; - global Process.PluginDescribeResult.ParameterType parameterType; - global Boolean required; - global PluginDescribeResult.InputParameter( - String name, - Process.PluginDescribeResult.ParameterType parameterType, - Boolean required - ) { - } - global Object clone() { - } - } - global class OutputParameter { - global String description; - global String name; - global Process.PluginDescribeResult.ParameterType parameterType; - global Object clone() { - } - } - global enum ParameterType { - BOOLEAN, - DATE, - DATETIME, - DECIMAL, - DOUBLE, - FLOAT, - ID, - INTEGER, - LONG, - STRING + { + [SELECT FIELDS(STANDARd) FROM Organization LIMIT 1]; } } - diff --git a/tests/prettier80/soql19.cls b/tests/prettier80/soql19.cls index f393f05c..fb4c800d 100644 --- a/tests/prettier80/soql19.cls +++ b/tests/prettier80/soql19.cls @@ -7,5 +7,7 @@ class A { [SELECT ID, (SELECT Id, Name, Address FROM RollupOrderBys__r) FROM Account]; [SELECT c.Id, c.Name FROM Contact c]; + + [SELECT FIELDS(STANDARD) FROM Organization LIMIT 1]; } } diff --git a/tests/prettier80/soql19.in b/tests/prettier80/soql19.in index 55a4aef8..5a241693 100644 --- a/tests/prettier80/soql19.in +++ b/tests/prettier80/soql19.in @@ -7,5 +7,7 @@ class A { [SELECT ID, (SELECT Id, Name, Address FROM RollupOrderBys__r) FROM Account]; [SELECT c.Id, c.Name FROM Contact as c]; + + [SELECT FIELDS(STANDARD) FROM Organization LIMIT 1]; } }