mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(ast_tools): add line breaks to generated code for ESTree derive (#6680)
Follow-on after #6404. Style nit. Add line breaks to generated code, to make it easier to read.
This commit is contained in:
parent
ad8e293197
commit
85e69a11ef
5 changed files with 277 additions and 0 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,7 @@ impl<'a> Serialize for Pattern<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type Pattern = ({\n\ttype: 'Pattern';\n\tbody: Disjunction;\n}) & Span;";
|
||||
|
|
@ -30,6 +31,7 @@ impl<'a> Serialize for Disjunction<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type Disjunction = ({\n\ttype: 'Disjunction';\n\tbody: Array<Alternative>;\n}) & Span;";
|
||||
|
|
@ -43,6 +45,7 @@ impl<'a> Serialize for Alternative<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type Alternative = ({\n\ttype: 'Alternative';\n\tbody: Array<Term>;\n}) & Span;";
|
||||
|
|
@ -65,6 +68,7 @@ impl<'a> Serialize for Term<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Term = BoundaryAssertion | LookAroundAssertion | Quantifier | Character | Dot | CharacterClassEscape | UnicodePropertyEscape | CharacterClass | CapturingGroup | IgnoreGroup | IndexedReference | NamedReference;";
|
||||
|
||||
|
|
@ -77,6 +81,7 @@ impl Serialize for BoundaryAssertion {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type BoundaryAssertion = ({\n\ttype: 'BoundaryAssertion';\n\tspan: Span;\n\tkind: BoundaryAssertionKind;\n});";
|
||||
|
||||
|
|
@ -98,6 +103,7 @@ impl Serialize for BoundaryAssertionKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type BoundaryAssertionKind = 'start' | 'end' | 'boundary' | 'negativeBoundary';";
|
||||
|
|
@ -112,6 +118,7 @@ impl<'a> Serialize for LookAroundAssertion<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type LookAroundAssertion = ({\n\ttype: 'LookAroundAssertion';\n\tkind: LookAroundAssertionKind;\n\tbody: Disjunction;\n}) & Span;";
|
||||
|
||||
|
|
@ -137,6 +144,7 @@ impl Serialize for LookAroundAssertionKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type LookAroundAssertionKind = 'lookahead' | 'negativeLookahead' | 'lookbehind' | 'negativeLookbehind';";
|
||||
|
||||
|
|
@ -152,6 +160,7 @@ impl<'a> Serialize for Quantifier<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Quantifier = ({\n\ttype: 'Quantifier';\n\tmin: number;\n\tmax: (number) | null;\n\tgreedy: boolean;\n\tbody: Term;\n}) & Span;";
|
||||
|
||||
|
|
@ -165,6 +174,7 @@ impl Serialize for Character {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Character = ({\n\ttype: 'Character';\n\tkind: CharacterKind;\n\tvalue: number;\n}) & Span;";
|
||||
|
||||
|
|
@ -202,6 +212,7 @@ impl Serialize for CharacterKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterKind = 'controlLetter' | 'hexadecimalEscape' | 'identifier' | 'null' | 'octal1' | 'octal2' | 'octal3' | 'singleEscape' | 'symbol' | 'unicodeEscape';";
|
||||
|
||||
|
|
@ -214,6 +225,7 @@ impl Serialize for CharacterClassEscape {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterClassEscape = ({\n\ttype: 'CharacterClassEscape';\n\tkind: CharacterClassEscapeKind;\n}) & Span;";
|
||||
|
||||
|
|
@ -241,6 +253,7 @@ impl Serialize for CharacterClassEscapeKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterClassEscapeKind = 'd' | 'negativeD' | 's' | 'negativeS' | 'w' | 'negativeW';";
|
||||
|
||||
|
|
@ -256,6 +269,7 @@ impl<'a> Serialize for UnicodePropertyEscape<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type UnicodePropertyEscape = ({\n\ttype: 'UnicodePropertyEscape';\n\tnegative: boolean;\n\tstrings: boolean;\n\tname: string;\n\tvalue: (string) | null;\n}) & Span;";
|
||||
|
||||
|
|
@ -267,6 +281,7 @@ impl Serialize for Dot {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Dot = ({\n\ttype: 'Dot';\n}) & Span;";
|
||||
|
||||
|
|
@ -282,6 +297,7 @@ impl<'a> Serialize for CharacterClass<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterClass = ({\n\ttype: 'CharacterClass';\n\tnegative: boolean;\n\tstrings: boolean;\n\tkind: CharacterClassContentsKind;\n\tbody: Array<CharacterClassContents>;\n}) & Span;";
|
||||
|
||||
|
|
@ -302,6 +318,7 @@ impl Serialize for CharacterClassContentsKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type CharacterClassContentsKind = 'union' | 'intersection' | 'subtraction';";
|
||||
|
|
@ -320,6 +337,7 @@ impl<'a> Serialize for CharacterClassContents<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterClassContents = CharacterClassRange | CharacterClassEscape | UnicodePropertyEscape | Character | CharacterClass | ClassStringDisjunction;";
|
||||
|
||||
|
|
@ -333,6 +351,7 @@ impl Serialize for CharacterClassRange {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CharacterClassRange = ({\n\ttype: 'CharacterClassRange';\n\tmin: Character;\n\tmax: Character;\n}) & Span;";
|
||||
|
||||
|
|
@ -346,6 +365,7 @@ impl<'a> Serialize for ClassStringDisjunction<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type ClassStringDisjunction = ({\n\ttype: 'ClassStringDisjunction';\n\tstrings: boolean;\n\tbody: Array<ClassString>;\n}) & Span;";
|
||||
|
||||
|
|
@ -359,6 +379,7 @@ impl<'a> Serialize for ClassString<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type ClassString = ({\n\ttype: 'ClassString';\n\tstrings: boolean;\n\tbody: Array<Character>;\n}) & Span;";
|
||||
|
||||
|
|
@ -372,6 +393,7 @@ impl<'a> Serialize for CapturingGroup<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type CapturingGroup = ({\n\ttype: 'CapturingGroup';\n\tname: (string) | null;\n\tbody: Disjunction;\n}) & Span;";
|
||||
|
||||
|
|
@ -385,6 +407,7 @@ impl<'a> Serialize for IgnoreGroup<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type IgnoreGroup = ({\n\ttype: 'IgnoreGroup';\n\tmodifiers: (Modifiers) | null;\n\tbody: Disjunction;\n}) & Span;";
|
||||
|
||||
|
|
@ -398,6 +421,7 @@ impl Serialize for Modifiers {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Modifiers = ({\n\ttype: 'Modifiers';\n\tenabling: (Modifier) | null;\n\tdisabling: (Modifier) | null;\n}) & Span;";
|
||||
|
||||
|
|
@ -411,6 +435,7 @@ impl Serialize for Modifier {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type Modifier = ({\n\ttype: 'Modifier';\n\tignoreCase: boolean;\n\tmultiline: boolean;\n\tsticky: boolean;\n});";
|
||||
|
||||
|
|
@ -423,6 +448,7 @@ impl Serialize for IndexedReference {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type IndexedReference = ({\n\ttype: 'IndexedReference';\n\tindex: number;\n}) & Span;";
|
||||
|
|
@ -436,6 +462,7 @@ impl<'a> Serialize for NamedReference<'a> {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type NamedReference = ({\n\ttype: 'NamedReference';\n\tname: string;\n}) & Span;";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ impl Serialize for Span {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type Span = ({\n\tstart: number;\n\tend: number;\n});";
|
||||
|
|
@ -32,6 +33,7 @@ impl Serialize for SourceType {
|
|||
map.end()
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type SourceType = ({\n\tlanguage: Language;\n\tmoduleKind: ModuleKind;\n\tvariant: LanguageVariant;\n});";
|
||||
|
||||
|
|
@ -50,6 +52,7 @@ impl Serialize for Language {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type Language = 'javascript' | 'typescript' | 'typescriptDefinition';";
|
||||
|
|
@ -65,6 +68,7 @@ impl Serialize for ModuleKind {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type ModuleKind = 'script' | 'module' | 'unambiguous';";
|
||||
|
|
@ -81,5 +85,6 @@ impl Serialize for LanguageVariant {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type LanguageVariant = 'standard' | 'jsx';";
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ impl Serialize for AssignmentOperator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '&&=' | '||=' | '??=' | '**=';";
|
||||
|
||||
|
|
@ -135,6 +136,7 @@ impl Serialize for BinaryOperator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '|' | '^' | '&' | 'in' | 'instanceof' | '**';";
|
||||
|
||||
|
|
@ -151,6 +153,7 @@ impl Serialize for LogicalOperator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type LogicalOperator = '||' | '&&' | '??';";
|
||||
|
||||
|
|
@ -179,6 +182,7 @@ impl Serialize for UnaryOperator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str =
|
||||
"export type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';";
|
||||
|
|
@ -195,5 +199,6 @@ impl Serialize for UpdateOperator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = "export type UpdateOperator = '++' | '--';";
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ impl Derive for DeriveESTree {
|
|||
#body
|
||||
}
|
||||
}
|
||||
|
||||
///@@line_break
|
||||
#ts_type_def
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue