1652: Improve type hints behavior r=matklad a=SomeoneToIgnore

This PR fixed the following type hints issues:

* Restructures the `InlayKind` enum contents based on the discussion here: https://github.com/rust-analyzer/rust-analyzer/pull/1606#issuecomment-515968055
* Races described in #1639 
* Caches the latest decorations received for each file to show them the next time the file is opened (instead of a new server request)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
bors[bot] 2019-08-06 16:50:49 +00:00
commit 7e12422fa2
5 changed files with 100 additions and 114 deletions

View file

@ -885,14 +885,7 @@ pub fn handle_inlay_hints(
label: api_type.label.to_string(),
range: api_type.range.conv_with(&line_index),
kind: match api_type.kind {
ra_ide_api::InlayKind::LetBindingType => InlayKind::LetBindingType,
ra_ide_api::InlayKind::ClosureParameterType => InlayKind::ClosureParameterType,
ra_ide_api::InlayKind::ForExpressionBindingType => {
InlayKind::ForExpressionBindingType
}
ra_ide_api::InlayKind::IfExpressionType => InlayKind::IfExpressionType,
ra_ide_api::InlayKind::WhileLetExpressionType => InlayKind::WhileLetExpressionType,
ra_ide_api::InlayKind::MatchArmType => InlayKind::MatchArmType,
ra_ide_api::InlayKind::TypeHint => InlayKind::TypeHint,
},
})
.collect())

View file

@ -213,12 +213,7 @@ pub struct InlayHintsParams {
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum InlayKind {
LetBindingType,
ClosureParameterType,
ForExpressionBindingType,
IfExpressionType,
WhileLetExpressionType,
MatchArmType,
TypeHint,
}
#[derive(Debug, Deserialize, Serialize)]