Skip to content

Commit

Permalink
Fix hover hints in LSP debugging types instead of displaying them
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Aug 11, 2024
1 parent 73b7bbc commit d53eddf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ante-ls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl LanguageServer for Backend {
let name = v.kind.name();

let value =
typeprinter::show_type_and_traits(&name, typ, &info.required_traits, &info.trait_info, &cache);
typeprinter::show_type_and_traits(&name, typ, &info.required_traits, &info.trait_info, &cache, false);

let location = v.locate();
let range =
Expand Down
2 changes: 1 addition & 1 deletion src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl Display for DiagnosticKind {
write!(f, "{actual} has no field '{field_name}' of type {expected}")
},
DiagnosticKind::TypeError(TypeErrorKind::AssignToNonMutRef, expected, actual) => {
write!(f, "Expression of type {actual} must be a `{expected}` type to be assigned to")
write!(f, "Expression of type {actual} must be a `{expected}` to be assigned to")
},
DiagnosticKind::TypeError(TypeErrorKind::AssignToWrongType, expected, actual) => {
write!(f, "Cannot assign expression of type {actual} to a Ref of type {expected}")
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn print_definition_types(cache: &ModuleCache) {

if let Some(typ) = &info.typ {
let type_string =
types::typeprinter::show_type_and_traits(name, typ, &info.required_traits, &info.trait_info, cache);
types::typeprinter::show_type_and_traits(name, typ, &info.required_traits, &info.trait_info, cache, true);
println!("{}", type_string);
} else {
println!("{} : (none)", name);
Expand Down
3 changes: 1 addition & 2 deletions src/types/typeprinter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,14 @@ fn fill_typevar_map(map: &mut HashMap<TypeVariableId, String>, typevars: Vec<Typ
/// naming to restart at `a` which may otherwise give them different names.
pub fn show_type_and_traits(
name: &str, typ: &GeneralizedType, traits: &[RequiredTrait], trait_info: &Option<(TraitInfoId, Vec<Type>)>,
cache: &ModuleCache<'_>,
cache: &ModuleCache<'_>, debug: bool,
) -> String {
let mut map = HashMap::new();
let mut current = 'a';

let typevars = typ.find_all_typevars(false, cache);
fill_typevar_map(&mut map, typevars, &mut current);

let debug = true;
let typ = typ.clone();
let printer = TypePrinter { typ, cache, debug, typevar_names: map.clone() };
let type_string = format!("{} : {}", name, printer);
Expand Down

0 comments on commit d53eddf

Please sign in to comment.