pub struct DiagnosticBuilder<'a> { /* private fields */ }Expand description
Builder for creating type error diagnostics.
Implementations§
Source§impl<'a> DiagnosticBuilder<'a>
impl<'a> DiagnosticBuilder<'a>
pub fn new(interner: &'a dyn TypeDatabase) -> Self
Sourcepub fn with_symbols(
interner: &'a dyn TypeDatabase,
symbol_arena: &'a SymbolArena,
) -> Self
pub fn with_symbols( interner: &'a dyn TypeDatabase, symbol_arena: &'a SymbolArena, ) -> Self
Create a diagnostic builder with access to symbol names.
This prevents “Ref(N)” fallback strings in diagnostic messages by resolving symbol references to their actual names.
Sourcepub fn with_def_store(self, def_store: &'a DefinitionStore) -> Self
pub fn with_def_store(self, def_store: &'a DefinitionStore) -> Self
Create a diagnostic builder with access to definition store.
This prevents “Lazy(N)” fallback strings in diagnostic messages by
resolving DefIds to their type names.
Sourcepub fn type_not_assignable(
&mut self,
source: TypeId,
target: TypeId,
) -> TypeDiagnostic
pub fn type_not_assignable( &mut self, source: TypeId, target: TypeId, ) -> TypeDiagnostic
Create a “Type X is not assignable to type Y” diagnostic.
Sourcepub fn property_missing(
&mut self,
prop_name: &str,
source: TypeId,
target: TypeId,
) -> TypeDiagnostic
pub fn property_missing( &mut self, prop_name: &str, source: TypeId, target: TypeId, ) -> TypeDiagnostic
Create a “Property X is missing in type Y” diagnostic.
Sourcepub fn property_not_exist(
&mut self,
prop_name: &str,
type_id: TypeId,
) -> TypeDiagnostic
pub fn property_not_exist( &mut self, prop_name: &str, type_id: TypeId, ) -> TypeDiagnostic
Create a “Property X does not exist on type Y” diagnostic.
Sourcepub fn property_not_exist_did_you_mean(
&mut self,
prop_name: &str,
type_id: TypeId,
suggestion: &str,
) -> TypeDiagnostic
pub fn property_not_exist_did_you_mean( &mut self, prop_name: &str, type_id: TypeId, suggestion: &str, ) -> TypeDiagnostic
Create a “Property X does not exist on type Y. Did you mean Z?” diagnostic (TS2551).
Sourcepub fn argument_not_assignable(
&mut self,
arg_type: TypeId,
param_type: TypeId,
) -> TypeDiagnostic
pub fn argument_not_assignable( &mut self, arg_type: TypeId, param_type: TypeId, ) -> TypeDiagnostic
Create an “Argument not assignable” diagnostic.
Sourcepub fn cannot_find_name(&mut self, name: &str) -> TypeDiagnostic
pub fn cannot_find_name(&mut self, name: &str) -> TypeDiagnostic
Create a “Cannot find name” diagnostic.
Sourcepub fn not_callable(&mut self, type_id: TypeId) -> TypeDiagnostic
pub fn not_callable(&mut self, type_id: TypeId) -> TypeDiagnostic
Create a “Type X is not callable” diagnostic.
pub fn this_type_mismatch( &mut self, expected_this: TypeId, actual_this: TypeId, ) -> TypeDiagnostic
Sourcepub fn argument_count_mismatch(
&mut self,
expected: usize,
got: usize,
) -> TypeDiagnostic
pub fn argument_count_mismatch( &mut self, expected: usize, got: usize, ) -> TypeDiagnostic
Create an “Expected N arguments but got M” diagnostic.
Sourcepub fn readonly_property(&mut self, prop_name: &str) -> TypeDiagnostic
pub fn readonly_property(&mut self, prop_name: &str) -> TypeDiagnostic
Create a “Cannot assign to readonly property” diagnostic.
Sourcepub fn excess_property(
&mut self,
prop_name: &str,
target: TypeId,
) -> TypeDiagnostic
pub fn excess_property( &mut self, prop_name: &str, target: TypeId, ) -> TypeDiagnostic
Create an “Excess property” diagnostic.
Sourcepub fn implicit_any_parameter(&mut self, param_name: &str) -> TypeDiagnostic
pub fn implicit_any_parameter(&mut self, param_name: &str) -> TypeDiagnostic
Create a “Parameter implicitly has an ‘any’ type” diagnostic (TS7006).
Sourcepub fn implicit_any_parameter_with_type(
&mut self,
param_name: &str,
implicit_type: TypeId,
) -> TypeDiagnostic
pub fn implicit_any_parameter_with_type( &mut self, param_name: &str, implicit_type: TypeId, ) -> TypeDiagnostic
Create a “Parameter implicitly has a specific type” diagnostic (TS7006 variant).
Sourcepub fn implicit_any_member(&mut self, member_name: &str) -> TypeDiagnostic
pub fn implicit_any_member(&mut self, member_name: &str) -> TypeDiagnostic
Create a “Member implicitly has an ‘any’ type” diagnostic (TS7008).
Sourcepub fn implicit_any_variable(
&mut self,
var_name: &str,
var_type: TypeId,
) -> TypeDiagnostic
pub fn implicit_any_variable( &mut self, var_name: &str, var_type: TypeId, ) -> TypeDiagnostic
Create a “Variable implicitly has an ‘any’ type” diagnostic (TS7005).
Sourcepub fn implicit_any_return(
&mut self,
func_name: &str,
return_type: TypeId,
) -> TypeDiagnostic
pub fn implicit_any_return( &mut self, func_name: &str, return_type: TypeId, ) -> TypeDiagnostic
Create an “implicitly has an ‘any’ return type” diagnostic (TS7010).
Sourcepub fn implicit_any_return_function_expression(
&mut self,
return_type: TypeId,
) -> TypeDiagnostic
pub fn implicit_any_return_function_expression( &mut self, return_type: TypeId, ) -> TypeDiagnostic
Create a “Function expression implicitly has an ‘any’ return type” diagnostic (TS7011).