mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(codegen): remove some pub APIs
This commit is contained in:
parent
72740b3f78
commit
543cad6370
5 changed files with 13 additions and 13 deletions
|
|
@ -222,6 +222,11 @@ impl<'a> Codegen<'a> {
|
||||||
pub fn print_str(&mut self, s: &str) {
|
pub fn print_str(&mut self, s: &str) {
|
||||||
self.code.extend(s.as_bytes());
|
self.code.extend(s.as_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn print_expression(&mut self, expr: &Expression<'_>) {
|
||||||
|
expr.gen_expr(self, Precedence::Lowest, Context::empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private APIs
|
// Private APIs
|
||||||
|
|
@ -242,7 +247,7 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn print_hard_space(&mut self) {
|
fn print_hard_space(&mut self) {
|
||||||
self.print_char(b' ');
|
self.print_char(b' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,7 +334,7 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn print_colon(&mut self) {
|
fn print_colon(&mut self) {
|
||||||
self.print_char(b':');
|
self.print_char(b':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,11 +421,6 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn print_expression(&mut self, expr: &Expression<'_>) {
|
|
||||||
expr.gen_expr(self, Precedence::Lowest, Context::empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn print_expressions<T: GenExpr>(&mut self, items: &[T], precedence: Precedence, ctx: Context) {
|
fn print_expressions<T: GenExpr>(&mut self, items: &[T], precedence: Precedence, ctx: Context) {
|
||||||
for (index, item) in items.iter().enumerate() {
|
for (index, item) in items.iter().enumerate() {
|
||||||
if index != 0 {
|
if index != 0 {
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ impl PreferExpectResolves {
|
||||||
);
|
);
|
||||||
|
|
||||||
formatter.print_str("await");
|
formatter.print_str("await");
|
||||||
formatter.print_hard_space();
|
formatter.print_char(b' ');
|
||||||
formatter.print_str(&jest_expect_fn_call.local);
|
formatter.print_str(&jest_expect_fn_call.local);
|
||||||
formatter.print_char(b'(');
|
formatter.print_char(b'(');
|
||||||
formatter.print_str(fixer.source_range(arg_span));
|
formatter.print_str(fixer.source_range(arg_span));
|
||||||
|
|
|
||||||
|
|
@ -146,14 +146,14 @@ impl PreferSpyOn {
|
||||||
MemberExpression::ComputedMemberExpression(cmp_mem_expr) => {
|
MemberExpression::ComputedMemberExpression(cmp_mem_expr) => {
|
||||||
formatter.print_expression(&cmp_mem_expr.object);
|
formatter.print_expression(&cmp_mem_expr.object);
|
||||||
formatter.print_char(b',');
|
formatter.print_char(b',');
|
||||||
formatter.print_hard_space();
|
formatter.print_char(b' ');
|
||||||
formatter.print_expression(&cmp_mem_expr.expression);
|
formatter.print_expression(&cmp_mem_expr.expression);
|
||||||
}
|
}
|
||||||
MemberExpression::StaticMemberExpression(static_mem_expr) => {
|
MemberExpression::StaticMemberExpression(static_mem_expr) => {
|
||||||
let name = &static_mem_expr.property.name;
|
let name = &static_mem_expr.property.name;
|
||||||
formatter.print_expression(&static_mem_expr.object);
|
formatter.print_expression(&static_mem_expr.object);
|
||||||
formatter.print_char(b',');
|
formatter.print_char(b',');
|
||||||
formatter.print_hard_space();
|
formatter.print_char(b' ');
|
||||||
formatter.print_str(format!("\'{name}\'").as_str());
|
formatter.print_str(format!("\'{name}\'").as_str());
|
||||||
}
|
}
|
||||||
MemberExpression::PrivateFieldExpression(_) => (),
|
MemberExpression::PrivateFieldExpression(_) => (),
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ fn diagnose_array_in_array_spread<'a>(
|
||||||
codegen.print_expression(el.to_expression());
|
codegen.print_expression(el.to_expression());
|
||||||
if i < n - 1 {
|
if i < n - 1 {
|
||||||
codegen.print_char(b',');
|
codegen.print_char(b',');
|
||||||
codegen.print_hard_space();
|
codegen.print_char(b' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codegen.print_char(b']');
|
codegen.print_char(b']');
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ impl Rule for SwitchCaseBraces {
|
||||||
formatter.print_str("default");
|
formatter.print_str("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
formatter.print_colon();
|
formatter.print_char(b':');
|
||||||
formatter.print_hard_space();
|
formatter.print_char(b' ');
|
||||||
formatter.print_char(b'{');
|
formatter.print_char(b'{');
|
||||||
case.consequent
|
case.consequent
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue