Skip to content

Commit 83d9c2f

Browse files
committed
fix: update from upstream
1 parent f6d3ab6 commit 83d9c2f

8 files changed

Lines changed: 57 additions & 29 deletions

File tree

crates/oxc_linter/src/service/runtime.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,11 @@ impl Runtime {
11201120
if !ret.errors.is_empty() {
11211121
let section_source = JavaScriptSource::new(source_text, source_type);
11221122
if let Some(sections) = &mut out_sections {
1123-
sections.push(SectionContent { source: section_source, semantic: None });
1123+
sections.push(SectionContent {
1124+
source: section_source,
1125+
semantic: None,
1126+
parser_tokens: None,
1127+
});
11241128
}
11251129
return smallvec::smallvec![Err(ret.errors)];
11261130
}
@@ -1146,7 +1150,11 @@ impl Runtime {
11461150
if !semantic_ret.errors.is_empty() {
11471151
let section_source = JavaScriptSource::new(source_text, source_type);
11481152
if let Some(sections) = &mut out_sections {
1149-
sections.push(SectionContent { source: section_source, semantic: None });
1153+
sections.push(SectionContent {
1154+
source: section_source,
1155+
semantic: None,
1156+
parser_tokens: None,
1157+
});
11501158
}
11511159
return smallvec::smallvec![Err(semantic_ret.errors)];
11521160
}
@@ -1178,7 +1186,11 @@ impl Runtime {
11781186

11791187
let section_source = JavaScriptSource::new(source_text, source_type);
11801188
if let Some(sections) = &mut out_sections {
1181-
sections.push(SectionContent { source: section_source, semantic: Some(semantic) });
1189+
sections.push(SectionContent {
1190+
source: section_source,
1191+
semantic: Some(semantic),
1192+
parser_tokens: None,
1193+
});
11821194
}
11831195

11841196
smallvec::smallvec![Ok(ResolvedModuleRecord { module_record, resolved_module_requests })]

crates/oxc_parser/src/astro/jsx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use oxc_allocator::{Allocator, Box, Dummy, Vec};
1212
use oxc_ast::ast::*;
1313
use oxc_span::{Atom, GetSpan, Span};
1414

15-
use crate::{ParserImpl, diagnostics, lexer::Kind};
15+
use crate::{ParserImpl, config::ParserConfig, diagnostics, lexer::Kind};
1616

1717
/// Represents either a closing JSX element or fragment (Astro copy).
1818
enum JSXClosing<'a> {
@@ -28,7 +28,7 @@ impl<'a> Dummy<'a> for JSXClosing<'a> {
2828
}
2929
}
3030

31-
impl<'a> ParserImpl<'a> {
31+
impl<'a, C: ParserConfig> ParserImpl<'a, C> {
3232
// ==================== Astro-specific JSX entry points ====================
3333
//
3434
// These are Astro-specific versions of the core JSX parsing functions.

crates/oxc_parser/src/astro/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ pub use scripts::parse_astro_scripts;
2727
use oxc_allocator::{Box, Vec};
2828
use oxc_ast::ast::*;
2929

30-
use crate::{ParserImpl, lexer::Kind};
30+
use crate::{ParserImpl, config::ParserConfig, lexer::Kind};
3131

3232
type NoTypeArgs<'a> = Option<Box<'a, TSTypeParameterInstantiation<'a>>>;
3333
type NoClosingElement<'a> = Option<Box<'a, JSXClosingElement<'a>>>;
3434

35-
impl<'a> ParserImpl<'a> {
35+
impl<'a, C: ParserConfig> ParserImpl<'a, C> {
3636
/// Parse the HTML body of an Astro file.
3737
///
3838
/// The body is essentially JSX children in an implicit fragment.
@@ -74,7 +74,7 @@ impl<'a> ParserImpl<'a> {
7474
let after_script =
7575
self.source_text.get((self.cur_token().span().start as usize) + 6..);
7676
if let Some(rest) = after_script {
77-
let next_char = rest.chars().next();
77+
let next_char: Option<char> = rest.chars().next();
7878
if matches!(
7979
next_char,
8080
Some(' ' | '>' | '/' | '\n' | '\r' | '\t') | None

crates/oxc_parser/src/astro/parse.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use oxc_ast::AstBuilder;
55
use oxc_diagnostics::OxcDiagnostic;
66
use oxc_span::{SourceType, Span};
77

8-
use crate::{ParseOptions, ParserImpl, parser_parse::UniquePromise};
8+
use crate::{ParseOptions, ParserImpl, config::NoTokensParserConfig, parser_parse::UniquePromise};
99

1010
use super::parse_astro_scripts;
1111

@@ -285,7 +285,8 @@ pub fn parse_astro<'a>(
285285

286286
// Parse the body JSX
287287
let unique = UniquePromise::new_for_astro();
288-
let parser = ParserImpl::new(allocator, source_text, source_type, options, unique);
288+
let parser =
289+
ParserImpl::new(allocator, source_text, source_type, options, NoTokensParserConfig, unique);
289290
let (mut body, body_errors, body_panicked) =
290291
parser.parse_astro_body_only(frontmatter_info.as_ref().map(|f| f.body_start));
291292

@@ -305,8 +306,14 @@ pub fn parse_astro<'a>(
305306
// Enable allow_return_outside_function for Astro frontmatter per spec §2.1
306307
let frontmatter_options = ParseOptions { allow_return_outside_function: true, ..options };
307308
let unique = UniquePromise::new_for_astro();
308-
let parser =
309-
ParserImpl::new(allocator, padded_source, ts_source_type, frontmatter_options, unique);
309+
let parser = ParserImpl::new(
310+
allocator,
311+
padded_source,
312+
ts_source_type,
313+
frontmatter_options,
314+
NoTokensParserConfig,
315+
unique,
316+
);
310317
let result = parser.parse();
311318

312319
let ast = AstBuilder::new(allocator);

crates/oxc_parser/src/astro/scripts.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use oxc_ast::ast::{Argument, Expression, JSXChild, JSXExpression, Statement};
88
use oxc_diagnostics::OxcDiagnostic;
99
use oxc_span::SourceType;
1010

11-
use crate::{ParseOptions, ParserImpl, parser_parse::UniquePromise};
11+
use crate::{ParseOptions, ParserImpl, config::NoTokensParserConfig, parser_parse::UniquePromise};
1212

1313
/// Parse script content in AstroScript nodes.
1414
/// This traverses the body and replaces placeholder programs with parsed TypeScript.
@@ -51,8 +51,14 @@ fn parse_scripts_in_child<'a>(
5151

5252
// Create a new parser for the script content
5353
let unique = UniquePromise::new_for_astro();
54-
let parser =
55-
ParserImpl::new(allocator, padded_source, ts_source_type, options, unique);
54+
let parser = ParserImpl::new(
55+
allocator,
56+
padded_source,
57+
ts_source_type,
58+
options,
59+
NoTokensParserConfig,
60+
unique,
61+
);
5662
let result = parser.parse();
5763

5864
// Replace the placeholder program with the parsed one

crates/oxc_parser/src/lexer/astro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use super::Lexer;
1010

1111
#[cfg(feature = "astro")]
12-
impl Lexer<'_> {
12+
impl<C: crate::config::LexerConfig> Lexer<'_, C> {
1313
/// Set the lexer position for Astro parsing.
1414
/// This is used to skip to a specific offset in the source.
1515
pub(crate) fn set_position_for_astro(&mut self, offset: u32) {
@@ -58,7 +58,7 @@ mod astro_jsx {
5858
/// Only `<` stops text scanning (for child tags like `<mi>`, `<mo>`, etc.).
5959
static ASTRO_FOREIGN_TEXT_END_TABLE: SafeByteMatchTable = safe_byte_match_table!(|b| b == b'<');
6060

61-
impl Lexer<'_> {
61+
impl<C: crate::config::LexerConfig> Lexer<'_, C> {
6262
/// Read a JSX child token in Astro mode.
6363
///
6464
/// This is the Astro-specific version of `read_jsx_child` that handles:

crates/oxc_semantic/src/astro/builder.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use oxc_cfg::{ControlFlowGraphBuilder, ErrorEdgeKind};
1111
use oxc_span::{Ident, SourceType};
1212
use oxc_syntax::{reference::ReferenceFlags, scope::ScopeFlags};
1313

14-
#[cfg(feature = "linter")]
15-
use crate::jsdoc::JSDocBuilder;
1614
use crate::{Semantic, SemanticBuilder, SemanticBuilderReturn, stats::Stats};
15+
#[cfg(feature = "jsdoc")]
16+
use oxc_jsdoc::JSDocBuilder;
1717

1818
#[cfg(feature = "cfg")]
1919
macro_rules! control_flow {
@@ -80,7 +80,7 @@ impl<'a> SemanticBuilderAstroExt<'a> for SemanticBuilder<'a> {
8080
// Astro files are TypeScript + JSX
8181
self.source_type = SourceType::ts().with_jsx(true);
8282

83-
#[cfg(feature = "linter")]
83+
#[cfg(feature = "jsdoc")]
8484
{
8585
self.jsdoc = JSDocBuilder::new(self.source_text, comments);
8686
}
@@ -108,8 +108,11 @@ impl<'a> SemanticBuilderAstroExt<'a> for SemanticBuilder<'a> {
108108
self.scoping
109109
.set_root_unresolved_references(self.unresolved_references.into_root().into_iter());
110110

111-
#[cfg(feature = "linter")]
112-
let jsdoc = self.jsdoc.build();
111+
#[cfg(feature = "jsdoc")]
112+
let jsdoc = {
113+
let result = self.jsdoc.build();
114+
crate::jsdoc::JSDocFinder::new(result.attached, result.not_attached)
115+
};
113116

114117
#[cfg(debug_assertions)]
115118
self.unused_labels.assert_empty();
@@ -122,7 +125,7 @@ impl<'a> SemanticBuilderAstroExt<'a> for SemanticBuilder<'a> {
122125
nodes: self.nodes,
123126
scoping: self.scoping,
124127
classes: self.class_table_builder.build(),
125-
#[cfg(feature = "linter")]
128+
#[cfg(feature = "jsdoc")]
126129
jsdoc,
127130
unused_labels: self.unused_labels.labels,
128131
#[cfg(feature = "cfg")]

napi/parser/src-js/generated/lazy/constructors.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14055,18 +14055,18 @@ function constructOptionBoxAstroFrontmatter(pos, ast) {
1405514055
return constructBoxAstroFrontmatter(pos, ast);
1405614056
}
1405714057

14058-
function constructU64(pos, ast) {
14059-
const { uint32 } = ast.buffer,
14060-
pos32 = pos >> 2;
14061-
return uint32[pos32] + uint32[pos32 + 1] * /* 2^32 */ 4294967296;
14062-
}
14063-
1406414058
function constructOptionNameSpan(pos, ast) {
1406514059
if (ast.buffer.uint32[(pos + 8) >> 2] === 0 && ast.buffer.uint32[(pos + 12) >> 2] === 0)
1406614060
return null;
1406714061
return new NameSpan(pos, ast);
1406814062
}
1406914063

14064+
function constructU64(pos, ast) {
14065+
const { uint32 } = ast.buffer,
14066+
pos32 = pos >> 2;
14067+
return uint32[pos32] + uint32[pos32 + 1] * /* 2^32 */ 4294967296;
14068+
}
14069+
1407014070
function constructOptionU64(pos, ast) {
1407114071
if (ast.buffer[pos] === 0) return null;
1407214072
return constructU64(pos + 8, ast);

0 commit comments

Comments
 (0)