mod checker;
mod context;
mod diagnostic;
#[cfg(feature = "native")]
mod file_uri;
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 corsa_bridge;
#[cfg(feature = "native")]
pub mod lsp_client;
#[cfg(feature = "native")]
pub use lsp_client as corsa_client;
#[cfg(all(feature = "native", unix))]
pub mod corsa_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 corsa_bridge::{
CorsaBridge, CorsaBridgeConfig, CorsaBridgeError, LspCompletionItem, LspCompletionList,
LspCompletionResponse, LspDefinitionResponse, LspDiagnostic, LspDocumentation, LspHover,
LspHoverContents, LspLocation, LspLocationLink, LspMarkedString, LspMarkupContent, LspPosition,
LspRange, VIRTUAL_URI_SCHEME,
};
#[cfg(feature = "native")]
pub use batch::{
BatchTypeChecker, BatchTypeCheckerOptions, CorsaError, CorsaExecutor, CorsaNotFoundError,
DeclarationEmitOptions, DeclarationEmitResult, DeclarationOutput,
Diagnostic as BatchDiagnostic, ImportRewriter, ImportSourceMap, PackageManager, SfcBlockType,
TypeCheckResult as BatchTypeCheckResult, TypeChecker as BatchTypeCheckerTrait, VirtualFile,
VirtualProject, VirtualTsGenerator,
};
#[cfg(feature = "native")]
pub use typecheck_service::{
SfcDiagnostic, SfcDiagnosticSeverity, SfcRelatedInfo,
SfcTypeCheckResult as CorsaTypeCheckResult, TypeCheckService, TypeCheckServiceOptions,
};
#[cfg(all(feature = "native", unix))]
pub use corsa_server::{
CheckParams, CheckResult as CorsaServerCheckResult, CorsaServer,
Diagnostic as CorsaServerDiagnostic, JsonRpcError, JsonRpcRequest, JsonRpcResponse,
ServerConfig,
};
#[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);
}
}