Skip to main content

Parser

Struct Parser 

Source
pub struct Parser { /* private fields */ }
Expand description

High-performance parser using Node architecture (16 bytes/node). This is the optimized path for Phase 8 test suite evaluation.

Implementations§

Source§

impl Parser

Source

pub fn new(file_name: String, source_text: String) -> Self

Create a new Parser for the given source file.

Source

pub fn set_compiler_options( &mut self, options_json: &str, ) -> Result<(), JsValue>

Set compiler options from JSON.

§Arguments
  • options_json - JSON string containing compiler options
§Example
const parser = new Parser("file.ts", "const x = 1;");
parser.setCompilerOptions(JSON.stringify({
  strict: true,
  noImplicitAny: true,
  strictNullChecks: true
}));
Source

pub fn add_lib_file(&mut self, file_name: String, source_text: String)

Add a lib file (e.g., lib.es5.d.ts) for global type resolution. The lib file will be parsed and bound, and its global symbols will be available during binding and type checking.

Source

pub fn parse_source_file(&mut self) -> u32

Parse the source file and return the root node index.

Source

pub fn get_node_count(&self) -> usize

Get the number of nodes in the AST.

Source

pub fn get_diagnostics_json(&self) -> String

Get parse diagnostics as JSON.

Source

pub fn bind_source_file(&mut self) -> String

Bind the source file and return symbol count.

Source

pub fn check_source_file(&mut self) -> String

Type check the source file and return diagnostics.

Source

pub fn get_type_of_node(&mut self, node_idx: u32) -> String

Get the type of a node as a string.

Source

pub fn emit(&self) -> String

Emit the source file as JavaScript (ES5 target, auto-detect CommonJS for modules).

Source

pub fn emit_modern(&self) -> String

Emit the source file as JavaScript (ES6+ modern output).

Source

pub fn generate_transforms( &self, target: u32, module: u32, ) -> WasmTransformContext

Generate transform directives based on compiler options.

Source

pub fn emit_with_transforms(&self, context: &WasmTransformContext) -> String

Emit the source file using pre-computed transforms.

Source

pub fn get_ast_json(&self) -> String

Get the AST as JSON (for debugging).

Source

pub fn debug_type_lowering(&self, interface_name: &str) -> String

Debug type lowering - trace what happens when lowering an interface type

Source

pub fn debug_interface_members(&self, interface_name: &str) -> String

Debug interface parsing - dump interface members for diagnostics

Source

pub fn debug_scopes(&self) -> String

Debug namespace scoping - dump scope info for all scopes

Source

pub fn trace_parent_chain(&self, pos: u32) -> String

Trace the parent chain for a node at a given position

Source

pub fn dump_var_decl(&self, var_decl_idx: u32) -> String

Dump variable declaration info for debugging

Source

pub fn dump_all_nodes(&self, start: u32, count: u32) -> String

Dump all nodes for debugging

Source

pub fn get_definition_at_position( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Go to Definition: Returns array of Location objects.

Source

pub fn get_references_at_position( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Find References: Returns array of Location objects.

Source

pub fn get_completions_at_position( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Completions: Returns array of CompletionItem objects.

Source

pub fn get_hover_at_position( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Hover: Returns HoverInfo object.

Source

pub fn get_signature_help_at_position( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Signature Help: Returns SignatureHelp object.

Source

pub fn get_document_symbols(&mut self) -> Result<JsValue, JsValue>

Document Symbols: Returns array of DocumentSymbol objects.

Source

pub fn get_semantic_tokens(&mut self) -> Result<Vec<u32>, JsValue>

Semantic Tokens: Returns flat array of u32 (delta encoded).

Source

pub fn prepare_rename( &mut self, line: u32, character: u32, ) -> Result<JsValue, JsValue>

Rename - Prepare: Check if rename is valid at position.

Source

pub fn get_rename_edits( &mut self, line: u32, character: u32, new_name: String, ) -> Result<JsValue, JsValue>

Rename - Edits: Get workspace edits for rename.

Source

pub fn get_code_actions( &mut self, start_line: u32, start_char: u32, end_line: u32, end_char: u32, ) -> Result<JsValue, JsValue>

Code Actions: Get code actions for a range.

Source

pub fn get_code_actions_with_context( &mut self, start_line: u32, start_char: u32, end_line: u32, end_char: u32, context: JsValue, ) -> Result<JsValue, JsValue>

Code Actions: Get code actions for a range with diagnostics context.

Source

pub fn get_lsp_diagnostics(&mut self) -> Result<JsValue, JsValue>

Diagnostics: Get checker diagnostics in LSP format.

Trait Implementations§

Source§

impl From<Parser> for JsValue

Source§

fn from(value: Parser) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for Parser

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for Parser

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for Parser

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<Parser>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for Parser

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for Parser

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for Parser

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<Parser>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for Parser

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<Parser>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for Parser

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for Parser

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Parser]>

Source§

impl VectorIntoWasmAbi for Parser

Source§

type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi

Source§

fn vector_into_abi(vector: Box<[Parser]>) -> Self::Abi

Source§

impl WasmDescribe for Parser

Source§

impl WasmDescribeVector for Parser

Source§

impl SupportsConstructor for Parser

Source§

impl SupportsInstanceProperty for Parser

Source§

impl SupportsStaticProperty for Parser

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more