Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions crates/oxc_allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
//! * `disable_track_allocations` - Disables `track_allocations` feature.
//! Purpose is to prevent `--all-features` enabling allocation tracking.

#![warn(missing_docs)]

mod accessor;
mod address;
mod alloc;
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/ast/comment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![warn(missing_docs)]
use bitflags::bitflags;

use oxc_allocator::{Allocator, CloneIn};
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_ast/src/ast_builder_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![warn(missing_docs)]

use std::borrow::Cow;

use oxc_allocator::{Allocator, AllocatorAccessor, Box, FromIn, IntoIn, Vec};
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![warn(missing_docs)]
use std::{
borrow::Cow,
fmt::{self, Display},
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/ast_impl/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//!
//! [AST Spec](https://github.com/typescript-eslint/typescript-eslint/tree/v8.9.0/packages/ast-spec)
//! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)
#![warn(missing_docs)]

use std::fmt;

Expand Down
3 changes: 0 additions & 3 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Auto-generated code, DO NOT EDIT DIRECTLY!
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/ast_kind.rs`.

#![expect(missing_docs)]
// FIXME (in ast_tools/src/generators/ast_kind.rs)

use std::ptr;

use oxc_allocator::{Address, GetAddress, UnstableAddress};
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
//! [`Visit`]: <http://docs.rs/oxc_ast_visit>
//! [`VisitMut`]: <http://docs.rs/oxc_ast_visit>

#![warn(missing_docs)]

#[cfg(feature = "serialize")]
mod serialize;

Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//! Code adapted from
//! * [esbuild](https://github.com/evanw/esbuild/blob/v0.24.0/internal/js_printer/js_printer.go)

#![warn(missing_docs)]

use std::{borrow::Cow, cmp, slice};

use cow_utils::CowUtils;
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Data structures used across other oxc crates.

#![warn(missing_docs)]

#[cfg(feature = "assert_unchecked")]
mod assert_unchecked;

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_isolated_declarations/src/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum ConstantValue {
}

impl<'a> IsolatedDeclarations<'a> {
/// Transform a TypeScript enum declaration into its declaration output form.
pub fn transform_ts_enum_declaration(&self, decl: &TSEnumDeclaration<'a>) -> Declaration<'a> {
let mut members = self.ast.vec();
let mut prev_initializer_value = Some(ConstantValue::Number(-1.0));
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_isolated_declarations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod signatures;
mod types;

#[derive(Debug, Default, Clone, Copy)]
/// Options for isolated declarations generation.
pub struct IsolatedDeclarationsOptions {
/// Do not emit declarations for code that has an `@internal` annotation in its JSDoc comment.
/// This is an internal compiler option; use at your own risk, because the compiler does not
Expand All @@ -45,11 +46,15 @@ pub struct IsolatedDeclarationsOptions {
}

#[non_exhaustive]
/// Result of an isolated declarations transform.
pub struct IsolatedDeclarationsReturn<'a> {
/// Generated declaration program (`.d.ts` AST).
pub program: Program<'a>,
/// Diagnostics collected while generating declarations.
pub errors: Vec<OxcDiagnostic>,
}

/// Transformer that emits declaration-only AST from TypeScript source AST.
pub struct IsolatedDeclarations<'a> {
ast: AstBuilder<'a>,

Expand All @@ -65,6 +70,7 @@ pub struct IsolatedDeclarations<'a> {
}

impl<'a> IsolatedDeclarations<'a> {
/// Create a new isolated declarations transformer.
pub fn new(allocator: &'a Allocator, options: IsolatedDeclarationsOptions) -> Self {
let strip_internal = options.strip_internal;
Self {
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Macros for declaring lints and secret scanners.
#![warn(missing_docs)]
use proc_macro::TokenStream;
use syn::parse_macro_input;

Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
//!
//! See [full linter example](https://github.com/Boshen/oxc/blob/ab2ef4f89ba3ca50c68abb2ca43e36b7793f3673/crates/oxc_linter/examples/linter.rs#L38-L39)

#![warn(missing_docs)]

mod context;
mod cursor;
mod error_handler;
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ pub struct SemanticBuilder<'a> {

/// Data returned by [`SemanticBuilder::build`].
pub struct SemanticBuilderReturn<'a> {
/// Built semantic model.
pub semantic: Semantic<'a>,
/// Diagnostics collected during semantic analysis.
pub errors: Vec<OxcDiagnostic>,
}

Expand All @@ -128,6 +130,7 @@ impl Default for SemanticBuilder<'_> {
}

impl<'a> SemanticBuilder<'a> {
/// Create a new semantic builder with default settings.
pub fn new() -> Self {
let scoping = Scoping::default();
let current_scope_id = scoping.root_scope_id();
Expand Down Expand Up @@ -187,6 +190,7 @@ impl<'a> SemanticBuilder<'a> {

#[cfg(not(feature = "cfg"))]
#[must_use]
/// No-op when `cfg` feature is disabled.
pub fn with_cfg(self, _cfg: bool) -> Self {
self
}
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_semantic/src/is_global_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::{ReferenceId, Scoping};
///
/// See: <https://github.com/oxc-project/oxc/issues/8365>
pub trait IsGlobalReference {
/// Returns `true` when this reference has no local symbol binding.
fn is_global_reference(&self, scoping: &Scoping) -> bool;
/// Returns `true` when this reference matches `name` and is global.
fn is_global_reference_name(&self, name: Ident<'_>, scoping: &Scoping) -> bool;
}

Expand Down
18 changes: 18 additions & 0 deletions crates/oxc_semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,27 @@ impl<'a> Semantic<'a> {
&self.nodes
}

/// Scoping data collected for this program.
pub fn scoping(&self) -> &Scoping {
&self.scoping
}

/// Mutable access to scoping data.
pub fn scoping_mut(&mut self) -> &mut Scoping {
&mut self.scoping
}

/// Mutable access to scoping data together with read-only AST nodes.
pub fn scoping_mut_and_nodes(&mut self) -> (&mut Scoping, &AstNodes<'a>) {
(&mut self.scoping, &self.nodes)
}

/// Class metadata collected during semantic analysis.
pub fn classes(&self) -> &ClassTable<'_> {
&self.classes
}

/// Set recorded spans for irregular unicode whitespace in source text.
pub fn set_irregular_whitespaces(&mut self, irregular_whitespaces: Box<[Span]>) {
self.irregular_whitespaces = irregular_whitespaces;
}
Expand All @@ -149,17 +154,20 @@ impl<'a> Semantic<'a> {
self.comments
}

/// Iterate comments within a byte range.
pub fn comments_range<R>(&self, range: R) -> CommentsRange<'_>
where
R: RangeBounds<u32>,
{
comments_range(self.comments, range)
}

/// Returns `true` if any comment lies between `span.start` and `span.end`.
pub fn has_comments_between(&self, span: Span) -> bool {
has_comments_between(self.comments, span)
}

/// Returns `true` if `pos` is inside a parsed comment.
pub fn is_inside_comment(&self, pos: u32) -> bool {
is_inside_comment(self.comments, pos)
}
Expand All @@ -169,6 +177,7 @@ impl<'a> Semantic<'a> {
get_comment_at(self.comments, pos)
}

/// Spans of irregular whitespace discovered by the parser.
pub fn irregular_whitespaces(&self) -> &[Span] {
&self.irregular_whitespaces
}
Expand All @@ -181,6 +190,7 @@ impl<'a> Semantic<'a> {
&self.jsdoc
}

/// Labels that were declared but never used.
pub fn unused_labels(&self) -> &Vec<NodeId> {
&self.unused_labels
}
Expand All @@ -194,6 +204,9 @@ impl<'a> Semantic<'a> {
self.cfg.as_ref()
}

/// Control flow graph.
///
/// Always returns `None` when the `cfg` feature is disabled.
#[cfg(not(feature = "cfg"))]
#[expect(clippy::unused_self)]
pub fn cfg(&self) -> Option<&()> {
Expand All @@ -211,6 +224,7 @@ impl<'a> Semantic<'a> {
)
}

/// Returns `true` if `node_id` points to an unresolved identifier reference.
pub fn is_unresolved_reference(&self, node_id: NodeId) -> bool {
let reference_node = self.nodes.get_node(node_id);
let AstKind::IdentifierReference(id) = reference_node.kind() else {
Expand All @@ -232,14 +246,17 @@ impl<'a> Semantic<'a> {
self.scoping.get_resolved_references(symbol_id)
}

/// Get the AST node that declares `symbol_id`.
pub fn symbol_declaration(&self, symbol_id: SymbolId) -> &AstNode<'a> {
self.nodes.get_node(self.scoping.symbol_declaration(symbol_id))
}

/// Returns `true` if `ident` resolves to a global (unbound) reference.
pub fn is_reference_to_global_variable(&self, ident: &IdentifierReference) -> bool {
self.scoping.root_unresolved_references().contains_key(&ident.name)
}

/// Get the textual name for a semantic reference.
pub fn reference_name(&self, reference: &Reference) -> &str {
let node = self.nodes.get_node(reference.node_id());
match node.kind() {
Expand All @@ -248,6 +265,7 @@ impl<'a> Semantic<'a> {
}
}

/// Get the source span for a semantic reference.
pub fn reference_span(&self, reference: &Reference) -> Span {
let node = self.nodes.get_node(reference.node_id());
node.kind().span()
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_semantic/src/node/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ impl<'a> AstNodes<'a> {
}

#[inline]
/// Get a node by [`NodeId`].
pub fn get_node(&self, node_id: NodeId) -> &AstNode<'a> {
&self.nodes[node_id]
}

#[inline]
/// Get a mutable node by [`NodeId`].
pub fn get_node_mut(&mut self, node_id: NodeId) -> &mut AstNode<'a> {
&mut self.nodes[node_id]
}
Expand Down
Loading
Loading