mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Merge commit 'e36a20c24f
' into ra-sync-and-pms-component
This commit is contained in:
parent
dfe84494c1
commit
a1f1b95d00
48 changed files with 627 additions and 213 deletions
|
@ -190,7 +190,8 @@ pub(crate) fn resolve_doc_path_for_def(
|
|||
| Definition::SelfType(_)
|
||||
| Definition::Local(_)
|
||||
| Definition::GenericParam(_)
|
||||
| Definition::Label(_) => None,
|
||||
| Definition::Label(_)
|
||||
| Definition::DeriveHelper(_) => None,
|
||||
}
|
||||
.map(Definition::from)
|
||||
}
|
||||
|
@ -515,7 +516,8 @@ fn filename_and_frag_for_def(
|
|||
| Definition::GenericParam(_)
|
||||
| Definition::Label(_)
|
||||
| Definition::BuiltinAttr(_)
|
||||
| Definition::ToolModule(_) => return None,
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::DeriveHelper(_) => return None,
|
||||
};
|
||||
|
||||
Some((def, res, None))
|
||||
|
|
|
@ -115,7 +115,12 @@ pub(crate) fn hover(
|
|||
});
|
||||
}
|
||||
|
||||
let descended = sema.descend_into_macros_with_same_text(original_token.clone());
|
||||
let in_attr = matches!(original_token.parent().and_then(ast::TokenTree::cast), Some(tt) if tt.syntax().ancestors().any(|it| ast::Meta::can_cast(it.kind())));
|
||||
let descended = if in_attr {
|
||||
[sema.descend_into_macros_with_kind_preference(original_token.clone())].into()
|
||||
} else {
|
||||
sema.descend_into_macros_with_same_text(original_token.clone())
|
||||
};
|
||||
|
||||
// FIXME: Definition should include known lints and the like instead of having this special case here
|
||||
let hovered_lint = descended.iter().find_map(|token| {
|
||||
|
|
|
@ -370,6 +370,7 @@ pub(super) fn definition(
|
|||
// FIXME: We should be able to show more info about these
|
||||
Definition::BuiltinAttr(it) => return render_builtin_attr(db, it),
|
||||
Definition::ToolModule(it) => return Some(Markup::fenced_block(&it.name(db))),
|
||||
Definition::DeriveHelper(it) => (format!("derive_helper {}", it.name(db)), None),
|
||||
};
|
||||
|
||||
let docs = match config.documentation {
|
||||
|
|
|
@ -196,6 +196,8 @@ impl TryToNav for Definition {
|
|||
Definition::BuiltinType(_) => None,
|
||||
Definition::ToolModule(_) => None,
|
||||
Definition::BuiltinAttr(_) => None,
|
||||
// FIXME: The focus range should be set to the helper declaration
|
||||
Definition::DeriveHelper(it) => it.derive().try_to_nav(db),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,8 @@ fn signature_help_for_generics(
|
|||
| hir::PathResolution::Local(_)
|
||||
| hir::PathResolution::TypeParam(_)
|
||||
| hir::PathResolution::ConstParam(_)
|
||||
| hir::PathResolution::SelfType(_) => return None,
|
||||
| hir::PathResolution::SelfType(_)
|
||||
| hir::PathResolution::DeriveHelper(_) => return None,
|
||||
};
|
||||
|
||||
generic_def
|
||||
|
|
|
@ -107,6 +107,7 @@ pub struct HlRange {
|
|||
// builtinType:: Emitted for builtin types like `u32`, `str` and `f32`.
|
||||
// comment:: Emitted for comments.
|
||||
// constParameter:: Emitted for const parameters.
|
||||
// deriveHelper:: Emitted for derive helper attributes.
|
||||
// enumMember:: Emitted for enum variants.
|
||||
// generic:: Emitted for generic tokens that have no mapping.
|
||||
// keyword:: Emitted for keywords.
|
||||
|
@ -431,6 +432,13 @@ fn traverse(
|
|||
// let the editor do its highlighting for these tokens instead
|
||||
continue;
|
||||
}
|
||||
if highlight.tag == HlTag::UnresolvedReference
|
||||
&& matches!(attr_or_derive_item, Some(AttrOrDerive::Derive(_)) if inside_attribute)
|
||||
{
|
||||
// do not emit unresolved references in derive helpers if the token mapping maps to
|
||||
// something unresolvable. FIXME: There should be a way to prevent that
|
||||
continue;
|
||||
}
|
||||
if inside_attribute {
|
||||
highlight |= HlMod::Attribute
|
||||
}
|
||||
|
|
|
@ -472,6 +472,7 @@ fn highlight_def(
|
|||
Definition::Label(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)),
|
||||
Definition::BuiltinAttr(_) => Highlight::new(HlTag::Symbol(SymbolKind::BuiltinAttr)),
|
||||
Definition::ToolModule(_) => Highlight::new(HlTag::Symbol(SymbolKind::ToolModule)),
|
||||
Definition::DeriveHelper(_) => Highlight::new(HlTag::Symbol(SymbolKind::DeriveHelper)),
|
||||
};
|
||||
|
||||
let def_crate = def.krate(db);
|
||||
|
|
|
@ -270,6 +270,7 @@ fn module_def_to_hl_tag(def: Definition) -> HlTag {
|
|||
Definition::Label(_) => SymbolKind::Label,
|
||||
Definition::BuiltinAttr(_) => SymbolKind::BuiltinAttr,
|
||||
Definition::ToolModule(_) => SymbolKind::ToolModule,
|
||||
Definition::DeriveHelper(_) => SymbolKind::DeriveHelper,
|
||||
};
|
||||
HlTag::Symbol(symbol)
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ impl HlTag {
|
|||
SymbolKind::Const => "constant",
|
||||
SymbolKind::ConstParam => "const_param",
|
||||
SymbolKind::Derive => "derive",
|
||||
SymbolKind::DeriveHelper => "derive_helper",
|
||||
SymbolKind::Enum => "enum",
|
||||
SymbolKind::Field => "field",
|
||||
SymbolKind::Function => "function",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue