Skip to content

Commit 835af2f

Browse files
committed
remove allow(dead_code)
1 parent a353aa3 commit 835af2f

8 files changed

Lines changed: 0 additions & 110 deletions

File tree

src/generation/generate.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9048,15 +9048,6 @@ fn gen_for_member_like_expr_item<'a>(item: &MemberLikeExprItem<'a>, context: &mu
90489048
}
90499049
items
90509050
}
9051-
MemberLikeExprItem::Token(token) => {
9052-
// don't bother with intertwined comments as its too much trouble
9053-
let mut items = PrintItems::new();
9054-
if !is_first {
9055-
items.push_sc(sc!("."));
9056-
}
9057-
items.push_string(token.text_fast(context.program).to_string());
9058-
items
9059-
}
90609051
MemberLikeExprItem::CallExpr(node) => {
90619052
let mut items = PrintItems::new();
90629053

src/generation/generate_types.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,6 @@ fn get_inner_range_for_object_like(range: &SourceRange) -> SourceRange {
167167
SourceRange::new(range.start + 1, range.end - 1)
168168
}
169169

170-
pub trait NodeExtensions<'a> {
171-
fn get_type_parameters(&self) -> Option<&'a TSTypeParameterDeclaration<'a>>;
172-
}
173-
174-
impl<'a> NodeExtensions<'a> for Node<'a> {
175-
fn get_type_parameters(&self) -> Option<&'a TSTypeParameterDeclaration<'a>> {
176-
match self {
177-
Node::Class(node) => node.type_parameters.as_deref(),
178-
Node::TSInterfaceDeclaration(node) => node.type_parameters.as_deref(),
179-
Node::Function(node) => node.type_parameters.as_deref(),
180-
Node::MethodDefinition(node) => node.value.type_parameters.as_deref(),
181-
Node::TSTypeAliasDeclaration(node) => node.type_parameters.as_deref(),
182-
Node::ArrowFunctionExpression(node) => node.type_parameters.as_deref(),
183-
Node::TSCallSignatureDeclaration(node) => node.type_parameters.as_deref(),
184-
Node::TSConstructSignatureDeclaration(node) => node.type_parameters.as_deref(),
185-
Node::TSMethodSignature(node) => node.type_parameters.as_deref(),
186-
Node::TSConstructorType(node) => node.type_parameters.as_deref(),
187-
Node::TSFunctionType(node) => node.type_parameters.as_deref(),
188-
_ => None,
189-
}
190-
}
191-
}
192-
193170
/* ParametersRanged */
194171

195172
pub trait ParametersRanged {

src/generation/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,17 @@
33
// commented out (kept on disk as the porting reference) and `generate` is a stub
44
// so the rest of the crate compiles and can be exercised.
55

6-
#[allow(dead_code)]
76
mod comments;
8-
#[allow(dead_code)]
97
mod context;
10-
#[allow(dead_code)]
118
mod oxc_helpers;
12-
#[allow(dead_code)]
139
mod to_node;
14-
#[allow(dead_code)]
1510
mod tokens;
1611

17-
#[allow(dead_code)]
1812
mod swc;
1913

20-
#[allow(dead_code)]
2114
mod sorting;
2215

23-
#[allow(dead_code)]
2416
mod generate_types;
25-
#[allow(dead_code)]
2617
mod node_helpers;
2718

2819
mod generate;

src/generation/node_helpers.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,6 @@ pub fn has_surrounding_different_line_comments<'a>(node: Node<'a>, program: Prog
101101
false
102102
}
103103

104-
pub fn nodes_have_only_spaces_between<'a>(previous_node: Node<'a>, next_node: Node<'a>, program: ProgramInfo<'a>) -> bool {
105-
if let Node::JSXText(previous_node) = previous_node {
106-
let previous_node_text = previous_node.text_fast(program);
107-
crate::utils::has_no_new_lines_in_trailing_whitespace(previous_node_text) && previous_node_text.ends_with(' ')
108-
} else if let Node::JSXText(next_node) = next_node {
109-
let next_node_text = next_node.text_fast(program);
110-
crate::utils::has_no_new_lines_in_leading_whitespace(next_node_text) && next_node_text.starts_with(' ')
111-
} else {
112-
let between_text = &program.text()[previous_node.end() as usize..next_node.start() as usize];
113-
crate::utils::is_not_empty_and_only_spaces(between_text)
114-
}
115-
}
116-
117104
pub fn has_jsx_space_expr_text(node: Node, program: ProgramInfo) -> bool {
118105
get_jsx_space_expr_space_count(node, program) > 0
119106
}

src/generation/oxc_helpers.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ impl<'a> ProgramInfo<'a> {
6969
}
7070
}
7171

72-
#[inline]
73-
pub fn program(&self) -> &'a Program<'a> {
74-
self.program
75-
}
76-
7772
#[inline]
7873
pub fn text_info(&self) -> &'a SourceTextInfo {
7974
self.text_info
@@ -204,11 +199,6 @@ impl<'a> CommentsIterator<'a> {
204199
self.comments.extend(other);
205200
}
206201

207-
/// Remaining comments without consuming the iterator.
208-
pub fn as_slice(&self) -> &[&'a Comment] {
209-
&self.comments[self.index..]
210-
}
211-
212202
/// The last remaining comment without consuming the iterator.
213203
pub fn peek_last_comment(&self) -> Option<&'a Comment> {
214204
self.comments[self.index..].last().copied()
@@ -401,10 +391,8 @@ impl RangeContains for SourceRange {
401391
/// code invoked directly on positions live here. There's no ambiguity with
402392
/// `SourceRanged` because `u32` doesn't implement `GetSpan`.
403393
pub trait PosExt {
404-
fn as_source_pos(&self) -> SourcePos;
405394
fn range(&self) -> SourceRange;
406395
fn start(&self) -> SourcePos;
407-
fn end(&self) -> SourcePos;
408396
fn start_line_fast(&self, program: ProgramInfo) -> usize;
409397
fn end_line_fast(&self, program: ProgramInfo) -> usize;
410398
fn start_column_fast(&self, program: ProgramInfo) -> usize;
@@ -416,11 +404,6 @@ pub trait PosExt {
416404
}
417405

418406
impl PosExt for SourcePos {
419-
#[inline]
420-
fn as_source_pos(&self) -> SourcePos {
421-
*self
422-
}
423-
424407
#[inline]
425408
fn range(&self) -> SourceRange {
426409
SourceRange::new(*self, *self)
@@ -431,11 +414,6 @@ impl PosExt for SourcePos {
431414
*self
432415
}
433416

434-
#[inline]
435-
fn end(&self) -> SourcePos {
436-
*self
437-
}
438-
439417
fn start_line_fast(&self, program: ProgramInfo) -> usize {
440418
self.line_fast(program)
441419
}

src/generation/swc/extensions.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ pub trait BinaryOpExtensions {
44
fn is_add_sub(&self) -> bool;
55
fn is_mul_div(&self) -> bool;
66
fn is_bitwise_or_arithmetic(&self) -> bool;
7-
fn is_logical(&self) -> bool;
87
fn is_bit_logical(&self) -> bool;
98
fn is_bit_shift(&self) -> bool;
109
fn is_equality(&self) -> bool;
1110
}
1211

13-
// Note: SWC's `BinaryOp` unified logical and binary operators; oxc splits them
14-
// into `BinaryOperator` and `LogicalOperator`. Logical operators are therefore
15-
// handled via `LogicalExpression` nodes, and `is_logical` here is always false.
1612
impl BinaryOpExtensions for BinaryOperator {
1713
fn is_add_sub(&self) -> bool {
1814
matches!(self, BinaryOperator::Addition | BinaryOperator::Subtraction)
@@ -39,10 +35,6 @@ impl BinaryOpExtensions for BinaryOperator {
3935
)
4036
}
4137

42-
fn is_logical(&self) -> bool {
43-
false
44-
}
45-
4638
fn is_bit_logical(&self) -> bool {
4739
matches!(self, BinaryOperator::BitwiseOR | BinaryOperator::BitwiseAnd | BinaryOperator::BitwiseXOR)
4840
}

src/generation/swc/flatten_member_like_expr.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use deno_ast::oxc::ast::ast::ChainElement;
2-
use deno_ast::oxc::parser::Token;
32
use deno_ast::oxc::span::GetSpan;
43
use deno_ast::oxc::span::Span;
54

@@ -27,7 +26,6 @@ pub enum MemberLikeExprItem<'a> {
2726
range: Span,
2827
is_optional: bool,
2928
},
30-
Token(&'a Token),
3129
CallExpr(Box<MemberLikeExprItemCallExpr<'a>>),
3230
}
3331

@@ -36,7 +34,6 @@ impl<'a> GetSpan for MemberLikeExprItem<'a> {
3634
match self {
3735
MemberLikeExprItem::Node { node, .. } => node.span(),
3836
MemberLikeExprItem::Computed { range, .. } => *range,
39-
MemberLikeExprItem::Token(token) => Span::new(token.start(), token.end()),
4037
MemberLikeExprItem::CallExpr(call_expr) => Span::new(call_expr.callee.span().start, call_expr.original_call_expr.end()),
4138
}
4239
}
@@ -51,15 +48,6 @@ impl<'a> MemberLikeExprItem<'a> {
5148
match self {
5249
MemberLikeExprItem::Node { is_optional, .. } | MemberLikeExprItem::Computed { is_optional, .. } => *is_optional,
5350
MemberLikeExprItem::CallExpr(call_expr) => call_expr.original_call_expr.is_optional(),
54-
MemberLikeExprItem::Token(_) => false,
55-
}
56-
}
57-
58-
fn get_top_node(&self) -> Option<Node<'a>> {
59-
match self {
60-
MemberLikeExprItem::Node { node, .. } | MemberLikeExprItem::Computed { node, .. } => Some(*node),
61-
MemberLikeExprItem::Token(_) => None,
62-
MemberLikeExprItem::CallExpr(call_expr) => Some(Node::CallExpression(call_expr.original_call_expr.inner())),
6351
}
6452
}
6553
}

src/utils/string_utils.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,6 @@ pub fn has_no_new_lines_in_trailing_whitespace(text: &str) -> bool {
6666
true
6767
}
6868

69-
pub fn is_not_empty_and_only_spaces(text: &str) -> bool {
70-
if text.is_empty() {
71-
return false;
72-
}
73-
74-
for c in text.chars() {
75-
if c != ' ' {
76-
return false;
77-
}
78-
}
79-
80-
true
81-
}
82-
8369
#[derive(Debug, PartialEq, Eq)]
8470
pub struct SplitLinesItem<'a> {
8571
pub text: &'a str,

0 commit comments

Comments
 (0)