MCPcopy Create free account
hub / github.com/PRQL/prql / write

Method write

prqlc/prqlc/src/codegen/ast.rs:27–48  ·  view source on GitHub ↗
(&self, mut opt: WriteOpt)

Source from the content-addressed store, hash-verified

25
26impl WriteSource for pr::Expr {
27 fn write(&self, mut opt: WriteOpt) -> Option<String> {
28 let mut r = String::new();
29
30 if let Some(alias) = &self.alias {
31 r += opt.consume(&write_ident_part(alias))?;
32 r += opt.consume(" = ")?;
33 opt.unbound_expr = false;
34 }
35
36 if !needs_parenthesis(self, &opt) {
37 r += &self.kind.write(opt.clone())?;
38 } else {
39 let value = self.kind.write_between("(", ")", opt.clone());
40
41 if let Some(value) = value {
42 r += &value;
43 } else {
44 r += &break_line_within_parenthesis(&self.kind, opt)?;
45 }
46 };
47 Some(r)
48 }
49}
50
51fn needs_parenthesis(this: &pr::Expr, opt: &WriteOpt) -> bool {

Callers 5

write_exprFunction · 0.45
write_withinFunction · 0.45
display_interpolationFunction · 0.45
format_single_stmtFunction · 0.45

Calls 15

write_ident_partFunction · 0.85
needs_parenthesisFunction · 0.85
write_withinFunction · 0.85
display_interpolationFunction · 0.85
consumeMethod · 0.80
write_betweenMethod · 0.80
mapMethod · 0.80
iterMethod · 0.80
lenMethod · 0.80
consume_widthMethod · 0.80
reset_lineMethod · 0.80

Tested by

no test coverage detected