Skip to main content

TypeChecker

Struct TypeChecker 

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

类型检查器

负责执行 HXO 文件的类型检查

Implementations§

Source§

impl TypeChecker

Source

pub fn new() -> Self

创建新的类型检查器实例

Source

pub fn parse_tsconfig(&mut self, path: &PathBuf) -> NargoResult<()>

解析 tsconfig.json 配置文件

§参数
  • path - 配置文件路径
§返回

解析结果

Source

pub fn load_tsconfig(&mut self, dir: &PathBuf) -> NargoResult<()>

从项目目录加载 tsconfig.json

§参数
  • dir - 项目目录
§返回

加载结果

Source

pub fn check_file(&mut self, file: &PathBuf, source: &str) -> NargoResult<()>

类型检查单个文件

§参数
  • file - 文件路径
  • source - 文件内容
§返回

检查结果,包含错误信息

Source

pub async fn check_project( &mut self, input: PathBuf, ) -> NargoResult<TypeCheckResult>

类型检查整个项目

§参数
  • input - 项目路径
§返回

类型检查结果

Source§

impl TypeChecker

Source

pub async fn incremental_check( &mut self, files: Vec<PathBuf>, ) -> NargoResult<TypeCheckResult>

增量类型检查

§参数
  • files - 需要检查的文件列表
§返回

类型检查结果

Trait Implementations§

Source§

impl TypeScriptStmtHandler for TypeChecker

Source§

fn handle_typescript_stmt(&mut self, stmt_str: &str)

处理 TypeScript 特有的语句 Read more
Source§

fn handle_interface_def( &mut self, name: String, members: HashMap<String, Type>, extends: Vec<String>, )

处理接口定义 Read more
Source§

fn handle_type_alias(&mut self, name: String, ty: Type)

处理类型别名 Read more
Source§

fn handle_generic_type(&self, name: String, type_args: Vec<Type>) -> Type

处理泛型类型 Read more
Source§

fn handle_union_type(&self, types: Vec<Type>) -> Type

处理联合类型 Read more
Source§

fn handle_intersection_type(&self, types: Vec<Type>) -> Type

处理交叉类型 Read more
Source§

fn handle_conditional_type( &self, check_type: Type, extends_type: Type, true_type: Type, false_type: Type, ) -> Type

处理条件类型 Read more
Source§

fn handle_mapped_type( &self, key_var: String, source_type: Type, mapped_type: Type, ) -> Type

处理映射类型 Read more
Source§

fn handle_index_access_type(&self, object_type: Type, index_type: Type) -> Type

处理索引访问类型 Read more
Source§

fn handle_keyof_type(&self, target_type: Type) -> Type

处理 KeyOf 类型 Read more
Source§

fn handle_literal_type(&self, literal: String) -> Type

处理字面量类型 Read more
Source§

fn handle_this_type(&self, this_type: Type) -> Type

处理 this 类型 Read more
Source§

fn handle_omit_this_parameter_type(&self, target_type: Type) -> Type

处理省略 this 参数类型 Read more
Source§

fn handle_this_parameter_type(&self, target_type: Type) -> Type

处理 this 参数类型 Read more
Source§

fn handle_interface_stmt(&mut self, stmt_str: &str)

处理接口定义语句 Read more
Source§

fn parse_interface_members(&self, members_str: &str) -> HashMap<String, Type>

解析接口成员 Read more
Source§

fn handle_type_alias_stmt(&mut self, stmt_str: &str)

处理类型别名语句 Read more
Source§

fn parse_type(&self, type_str: &str) -> Type

解析类型字符串 Read more

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, 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V