mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
More symbol usage
This commit is contained in:
parent
c30bdfcc84
commit
df5f1777b8
50 changed files with 388 additions and 303 deletions
|
@ -2,7 +2,7 @@
|
|||
use either::Either;
|
||||
use hir::{
|
||||
db::{DefDatabase, HirDatabase},
|
||||
resolve_doc_path_on, AttrId, AttrSourceMap, AttrsWithOwner, HasAttrs, InFile,
|
||||
resolve_doc_path_on, sym, AttrId, AttrSourceMap, AttrsWithOwner, HasAttrs, InFile,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use syntax::{
|
||||
|
@ -92,7 +92,7 @@ pub fn docs_with_rangemap(
|
|||
attrs: &AttrsWithOwner,
|
||||
) -> Option<(Documentation, DocsRangeMap)> {
|
||||
let docs = attrs
|
||||
.by_key("doc")
|
||||
.by_key(&sym::doc)
|
||||
.attrs()
|
||||
.filter_map(|attr| attr.string_value_unescape().map(|s| (s, attr.id)));
|
||||
let indent = doc_indent(attrs);
|
||||
|
@ -134,7 +134,7 @@ pub fn docs_with_rangemap(
|
|||
}
|
||||
|
||||
pub fn docs_from_attrs(attrs: &hir::Attrs) -> Option<String> {
|
||||
let docs = attrs.by_key("doc").attrs().filter_map(|attr| attr.string_value_unescape());
|
||||
let docs = attrs.by_key(&sym::doc).attrs().filter_map(|attr| attr.string_value_unescape());
|
||||
let indent = doc_indent(attrs);
|
||||
let mut buf = String::new();
|
||||
for doc in docs {
|
||||
|
@ -270,7 +270,7 @@ fn get_doc_string_in_attr(it: &ast::Attr) -> Option<ast::String> {
|
|||
|
||||
fn doc_indent(attrs: &hir::Attrs) -> usize {
|
||||
let mut min = !0;
|
||||
for val in attrs.by_key("doc").attrs().filter_map(|attr| attr.string_value_unescape()) {
|
||||
for val in attrs.by_key(&sym::doc).attrs().filter_map(|attr| attr.string_value_unescape()) {
|
||||
if let Some(m) =
|
||||
val.lines().filter_map(|line| line.chars().position(|c| !c.is_whitespace())).min()
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::mem;
|
|||
|
||||
use base_db::{salsa::Database, FileId, FileRange, SourceDatabase, SourceDatabaseExt};
|
||||
use hir::{
|
||||
AsAssocItem, DefWithBody, DescendPreference, HasAttrs, HasSource, HirFileIdExt, InFile,
|
||||
sym, AsAssocItem, DefWithBody, DescendPreference, HasAttrs, HasSource, HirFileIdExt, InFile,
|
||||
InRealFile, ModuleSource, PathResolution, Semantics, Visibility,
|
||||
};
|
||||
use memchr::memmem::Finder;
|
||||
|
@ -333,7 +333,7 @@ impl Definition {
|
|||
if let Definition::Macro(macro_def) = self {
|
||||
return match macro_def.kind(db) {
|
||||
hir::MacroKind::Declarative => {
|
||||
if macro_def.attrs(db).by_key("macro_export").exists() {
|
||||
if macro_def.attrs(db).by_key(&sym::macro_export).exists() {
|
||||
SearchScope::reverse_dependencies(db, module.krate())
|
||||
} else {
|
||||
SearchScope::krate(db, module.krate())
|
||||
|
@ -456,7 +456,7 @@ impl<'a> FindUsages<'a> {
|
|||
module
|
||||
.krate()
|
||||
.display_name(self.sema.db)
|
||||
.map(|crate_name| crate_name.crate_name().as_smol_str().clone())
|
||||
.map(|crate_name| crate_name.crate_name().symbol().as_str().into())
|
||||
}
|
||||
_ => {
|
||||
let self_kw_refs = || {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue