mod checker;
mod context;
mod diagnostic;
pub mod intelligence;
pub mod sfc_typecheck;
pub mod source_map;
mod types;
pub mod virtual_ts;
#[cfg(feature = "native")]
pub mod batch;
#[cfg(feature = "native")]
pub mod tsgo_bridge;
#[cfg(feature = "native")]
pub mod lsp_client;
#[cfg(all(feature = "native", unix))]
pub mod tsgo_server;
#[cfg(feature = "native")]
pub mod typecheck_service;
#[cfg(all(test, feature = "native"))]
mod tests;
pub use checker::TypeChecker;
pub use context::{Binding, BindingKind, Import, Prop, TypeContext};
pub use diagnostic::{TypeDiagnostic, TypeErrorCode, TypeSeverity};
pub use intelligence::{
Completion, CompletionKind as IntelCompletionKind, CursorContext, Diagnostic,
DiagnosticSeverity, HoverInfo, Location, TypeIntelligence,
};
pub use sfc_typecheck::{
type_check_sfc, SfcRelatedLocation, SfcTypeCheckOptions, SfcTypeCheckResult, SfcTypeDiagnostic,
SfcTypeSeverity,
};
pub use source_map::{
offset_to_position, position_to_offset, Mapping, MappingFlags, MappingKind, Position,
SourceMap, Span,
};
pub use types::{CompletionItem, CompletionKind, TypeInfo, TypeKind};
pub use vize_carton::i18n::Locale;
#[cfg(feature = "native")]
pub use tsgo_bridge::{
LspCompletionItem, LspCompletionList, LspCompletionResponse, LspDefinitionResponse,
LspDiagnostic, LspDocumentation, LspHover, LspHoverContents, LspLocation, LspLocationLink,
LspMarkedString, LspMarkupContent, LspPosition, LspRange, TsgoBridge, TsgoBridgeConfig,
TsgoBridgeError, VIRTUAL_URI_SCHEME,
};
#[cfg(feature = "native")]
pub use batch::{
BatchTypeChecker, Diagnostic as BatchDiagnostic, ImportRewriter, ImportSourceMap,
PackageManager, SfcBlockType, TsgoError, TsgoExecutor, TsgoNotFoundError,
TypeCheckResult as BatchTypeCheckResult, TypeChecker as BatchTypeCheckerTrait, VirtualFile,
VirtualProject, VirtualTsGenerator,
};
#[cfg(feature = "native")]
pub use typecheck_service::{
SfcDiagnostic, SfcDiagnosticSeverity, SfcRelatedInfo,
SfcTypeCheckResult as TsgoTypeCheckResult, TypeCheckService, TypeCheckServiceOptions,
};
#[cfg(all(feature = "native", unix))]
pub use tsgo_server::{
CheckParams, CheckResult as TsgoServerCheckResult, Diagnostic as TsgoServerDiagnostic,
JsonRpcError, JsonRpcRequest, JsonRpcResponse, ServerConfig, TsgoServer,
};
#[derive(Debug, Clone, Default)]
pub struct CheckResult {
pub diagnostics: Vec<TypeDiagnostic>,
pub error_count: usize,
pub warning_count: usize,
}
impl CheckResult {
pub fn new() -> Self {
Self::default()
}
pub fn has_errors(&self) -> bool {
self.error_count > 0
}
pub fn has_diagnostics(&self) -> bool {
!self.diagnostics.is_empty()
}
pub fn add_diagnostic(&mut self, diagnostic: TypeDiagnostic) {
match diagnostic.severity {
TypeSeverity::Error => self.error_count += 1,
TypeSeverity::Warning => self.warning_count += 1,
}
self.diagnostics.push(diagnostic);
}
}