Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
finxxi committed Dec 14, 2024
1 parent c6ca457 commit 9af4d81
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 40 deletions.
36 changes: 29 additions & 7 deletions src/enum_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_"),
}
}
Expand Down Expand Up @@ -893,7 +891,7 @@ pub enum SelectableExpression {
Value(ValueExpression),
Alias(AliasExpression),
//Type(TypeOfClause),
//Fields(FieldsExpression),
Fields(FieldsExpression),
Sub(SubQuery),
}

Expand All @@ -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"),
}
Expand All @@ -920,13 +919,38 @@ 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));
}
}
}
}

#[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<DocRef<'a>>) {
result.push(b.txt("FIELDS("));
result.push(b.txt(&self.fields_type));
result.push(b.txt(")"));
}
}

#[derive(Debug)]
pub struct AliasExpression {
value_exp: ValueExpression,
Expand Down Expand Up @@ -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 {
Expand Down
35 changes: 2 additions & 33 deletions test.cls
Original file line number Diff line number Diff line change
@@ -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];
}
}

2 changes: 2 additions & 0 deletions tests/prettier80/soql19.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
2 changes: 2 additions & 0 deletions tests/prettier80/soql19.in
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

0 comments on commit 9af4d81

Please sign in to comment.