Don't expose SyntaxKind from IDE API
SyntaxKind is somewhat of an internal type, but IDE is using it to basically specify an icon. Let's have a dedicated entity for this instead.
This commit is contained in:
parent
2465fa02b7
commit
55ba353b39
crates
@ -181,8 +181,8 @@ fn caller() {
|
||||
call<|>ee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..44 18..24 : [33..39]"],
|
||||
"callee Function FileId(0) 0..14 3..9",
|
||||
&["caller Function FileId(0) 15..44 18..24 : [33..39]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -197,8 +197,8 @@ fn caller() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..44 18..24 : [33..39]"],
|
||||
"callee Function FileId(0) 0..14 3..9",
|
||||
&["caller Function FileId(0) 15..44 18..24 : [33..39]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -214,8 +214,8 @@ fn caller() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
&["caller FN FileId(0) 15..58 18..24 : [33..39, 47..53]"],
|
||||
"callee Function FileId(0) 0..14 3..9",
|
||||
&["caller Function FileId(0) 15..58 18..24 : [33..39, 47..53]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -234,10 +234,10 @@ fn caller2() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
"callee Function FileId(0) 0..14 3..9",
|
||||
&[
|
||||
"caller1 FN FileId(0) 15..45 18..25 : [34..40]",
|
||||
"caller2 FN FileId(0) 47..77 50..57 : [66..72]",
|
||||
"caller1 Function FileId(0) 15..45 18..25 : [34..40]",
|
||||
"caller2 Function FileId(0) 47..77 50..57 : [66..72]",
|
||||
],
|
||||
&[],
|
||||
);
|
||||
@ -263,10 +263,10 @@ mod tests {
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"callee FN FileId(0) 0..14 3..9",
|
||||
"callee Function FileId(0) 0..14 3..9",
|
||||
&[
|
||||
"caller1 FN FileId(0) 15..45 18..25 : [34..40]",
|
||||
"test_caller FN FileId(0) 95..149 110..121 : [134..140]",
|
||||
"caller1 Function FileId(0) 15..45 18..25 : [34..40]",
|
||||
"test_caller Function FileId(0) 95..149 110..121 : [134..140]",
|
||||
],
|
||||
&[],
|
||||
);
|
||||
@ -287,8 +287,8 @@ fn caller() {
|
||||
//- /foo/mod.rs
|
||||
pub fn callee() {}
|
||||
"#,
|
||||
"callee FN FileId(1) 0..18 7..13",
|
||||
&["caller FN FileId(0) 27..56 30..36 : [45..51]"],
|
||||
"callee Function FileId(1) 0..18 7..13",
|
||||
&["caller Function FileId(0) 27..56 30..36 : [45..51]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
@ -304,9 +304,9 @@ fn call<|>er() {
|
||||
callee();
|
||||
}
|
||||
"#,
|
||||
"caller FN FileId(0) 15..58 18..24",
|
||||
"caller Function FileId(0) 15..58 18..24",
|
||||
&[],
|
||||
&["callee FN FileId(0) 0..14 3..9 : [33..39, 47..53]"],
|
||||
&["callee Function FileId(0) 0..14 3..9 : [33..39, 47..53]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -325,9 +325,9 @@ fn call<|>er() {
|
||||
//- /foo/mod.rs
|
||||
pub fn callee() {}
|
||||
"#,
|
||||
"caller FN FileId(0) 27..56 30..36",
|
||||
"caller Function FileId(0) 27..56 30..36",
|
||||
&[],
|
||||
&["callee FN FileId(1) 0..18 7..13 : [45..51]"],
|
||||
&["callee Function FileId(1) 0..18 7..13 : [45..51]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -348,9 +348,9 @@ fn caller3() {
|
||||
|
||||
}
|
||||
"#,
|
||||
"caller2 FN FileId(0) 33..64 36..43",
|
||||
&["caller1 FN FileId(0) 0..31 3..10 : [19..26]"],
|
||||
&["caller3 FN FileId(0) 66..83 69..76 : [52..59]"],
|
||||
"caller2 Function FileId(0) 33..64 36..43",
|
||||
&["caller1 Function FileId(0) 0..31 3..10 : [19..26]"],
|
||||
&["caller3 Function FileId(0) 66..83 69..76 : [52..59]"],
|
||||
);
|
||||
}
|
||||
|
||||
@ -368,9 +368,9 @@ fn main() {
|
||||
a<|>()
|
||||
}
|
||||
"#,
|
||||
"a FN FileId(0) 0..18 3..4",
|
||||
&["main FN FileId(0) 31..52 34..38 : [47..48]"],
|
||||
&["b FN FileId(0) 20..29 23..24 : [13..14]"],
|
||||
"a Function FileId(0) 0..18 3..4",
|
||||
&["main Function FileId(0) 31..52 34..38 : [47..48]"],
|
||||
&["b Function FileId(0) 20..29 23..24 : [13..14]"],
|
||||
);
|
||||
|
||||
check_hierarchy(
|
||||
@ -385,8 +385,8 @@ fn main() {
|
||||
a()
|
||||
}
|
||||
"#,
|
||||
"b FN FileId(0) 20..29 23..24",
|
||||
&["a FN FileId(0) 0..18 3..4 : [13..14]"],
|
||||
"b Function FileId(0) 20..29 23..24",
|
||||
&["a Function FileId(0) 0..18 3..4 : [13..14]"],
|
||||
&[],
|
||||
);
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
//! This module contains utilities for turning SyntaxNodes and HIR types
|
||||
//! into types that may be used to render in a UI.
|
||||
|
||||
mod navigation_target;
|
||||
pub(crate) mod navigation_target;
|
||||
mod short_label;
|
||||
|
||||
pub use navigation_target::NavigationTarget;
|
||||
pub(crate) use navigation_target::{ToNav, TryToNav};
|
||||
pub(crate) use short_label::ShortLabel;
|
||||
|
||||
|
@ -2,19 +2,43 @@
|
||||
|
||||
use either::Either;
|
||||
use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource};
|
||||
use ide_db::base_db::{FileId, SourceDatabase};
|
||||
use ide_db::{
|
||||
base_db::{FileId, SourceDatabase},
|
||||
symbol_index::FileSymbolKind,
|
||||
};
|
||||
use ide_db::{defs::Definition, RootDatabase};
|
||||
use syntax::{
|
||||
ast::{self, NameOwner},
|
||||
match_ast, AstNode, SmolStr,
|
||||
SyntaxKind::{self, IDENT_PAT, LIFETIME_PARAM, TYPE_PARAM},
|
||||
TextRange,
|
||||
match_ast, AstNode, SmolStr, TextRange,
|
||||
};
|
||||
|
||||
use crate::FileSymbol;
|
||||
|
||||
use super::short_label::ShortLabel;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum SymbolKind {
|
||||
Module,
|
||||
Impl,
|
||||
Field,
|
||||
TypeParam,
|
||||
LifetimeParam,
|
||||
SelfParam,
|
||||
Local,
|
||||
Function,
|
||||
Const,
|
||||
Static,
|
||||
Struct,
|
||||
Enum,
|
||||
Variant,
|
||||
Union,
|
||||
TypeAlias,
|
||||
Trait,
|
||||
Macro,
|
||||
// Do we actually need this?
|
||||
DocTest,
|
||||
}
|
||||
|
||||
/// `NavigationTarget` represents and element in the editor's UI which you can
|
||||
/// click on to navigate to a particular piece of code.
|
||||
///
|
||||
@ -40,7 +64,7 @@ pub struct NavigationTarget {
|
||||
/// Clients should place the cursor on this range when navigating to this target.
|
||||
pub focus_range: Option<TextRange>,
|
||||
pub name: SmolStr,
|
||||
pub kind: SyntaxKind,
|
||||
pub kind: SymbolKind,
|
||||
pub container_name: Option<SmolStr>,
|
||||
pub description: Option<String>,
|
||||
pub docs: Option<Documentation>,
|
||||
@ -69,7 +93,7 @@ impl NavigationTarget {
|
||||
name,
|
||||
None,
|
||||
frange.range,
|
||||
src.value.syntax().kind(),
|
||||
SymbolKind::Module,
|
||||
);
|
||||
res.docs = module.attrs(db).docs();
|
||||
res.description = src.value.short_label();
|
||||
@ -101,6 +125,7 @@ impl NavigationTarget {
|
||||
pub(crate) fn from_named(
|
||||
db: &RootDatabase,
|
||||
node: InFile<&dyn ast::NameOwner>,
|
||||
kind: SymbolKind,
|
||||
) -> NavigationTarget {
|
||||
let name =
|
||||
node.value.name().map(|it| it.text().clone()).unwrap_or_else(|| SmolStr::new("_"));
|
||||
@ -108,13 +133,7 @@ impl NavigationTarget {
|
||||
node.value.name().map(|it| node.with_value(it.syntax()).original_file_range(db).range);
|
||||
let frange = node.map(|it| it.syntax()).original_file_range(db);
|
||||
|
||||
NavigationTarget::from_syntax(
|
||||
frange.file_id,
|
||||
name,
|
||||
focus_range,
|
||||
frange.range,
|
||||
node.value.syntax().kind(),
|
||||
)
|
||||
NavigationTarget::from_syntax(frange.file_id, name, focus_range, frange.range, kind)
|
||||
}
|
||||
|
||||
fn from_syntax(
|
||||
@ -122,7 +141,7 @@ impl NavigationTarget {
|
||||
name: SmolStr,
|
||||
focus_range: Option<TextRange>,
|
||||
full_range: TextRange,
|
||||
kind: SyntaxKind,
|
||||
kind: SymbolKind,
|
||||
) -> NavigationTarget {
|
||||
NavigationTarget {
|
||||
file_id,
|
||||
@ -142,7 +161,17 @@ impl ToNav for FileSymbol {
|
||||
NavigationTarget {
|
||||
file_id: self.file_id,
|
||||
name: self.name.clone(),
|
||||
kind: self.kind,
|
||||
kind: match self.kind {
|
||||
FileSymbolKind::Function => SymbolKind::Function,
|
||||
FileSymbolKind::Struct => SymbolKind::Struct,
|
||||
FileSymbolKind::Enum => SymbolKind::Enum,
|
||||
FileSymbolKind::Trait => SymbolKind::Trait,
|
||||
FileSymbolKind::Module => SymbolKind::Module,
|
||||
FileSymbolKind::TypeAlias => SymbolKind::TypeAlias,
|
||||
FileSymbolKind::Const => SymbolKind::Const,
|
||||
FileSymbolKind::Static => SymbolKind::Static,
|
||||
FileSymbolKind::Macro => SymbolKind::Macro,
|
||||
},
|
||||
full_range: self.range,
|
||||
focus_range: self.name_range,
|
||||
container_name: self.container_name.clone(),
|
||||
@ -191,16 +220,36 @@ impl TryToNav for hir::ModuleDef {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait ToNavFromAst {}
|
||||
impl ToNavFromAst for hir::Function {}
|
||||
impl ToNavFromAst for hir::Const {}
|
||||
impl ToNavFromAst for hir::Static {}
|
||||
impl ToNavFromAst for hir::Struct {}
|
||||
impl ToNavFromAst for hir::Enum {}
|
||||
impl ToNavFromAst for hir::EnumVariant {}
|
||||
impl ToNavFromAst for hir::Union {}
|
||||
impl ToNavFromAst for hir::TypeAlias {}
|
||||
impl ToNavFromAst for hir::Trait {}
|
||||
pub(crate) trait ToNavFromAst {
|
||||
const KIND: SymbolKind;
|
||||
}
|
||||
impl ToNavFromAst for hir::Function {
|
||||
const KIND: SymbolKind = SymbolKind::Function;
|
||||
}
|
||||
impl ToNavFromAst for hir::Const {
|
||||
const KIND: SymbolKind = SymbolKind::Const;
|
||||
}
|
||||
impl ToNavFromAst for hir::Static {
|
||||
const KIND: SymbolKind = SymbolKind::Static;
|
||||
}
|
||||
impl ToNavFromAst for hir::Struct {
|
||||
const KIND: SymbolKind = SymbolKind::Struct;
|
||||
}
|
||||
impl ToNavFromAst for hir::Enum {
|
||||
const KIND: SymbolKind = SymbolKind::Enum;
|
||||
}
|
||||
impl ToNavFromAst for hir::EnumVariant {
|
||||
const KIND: SymbolKind = SymbolKind::Variant;
|
||||
}
|
||||
impl ToNavFromAst for hir::Union {
|
||||
const KIND: SymbolKind = SymbolKind::Union;
|
||||
}
|
||||
impl ToNavFromAst for hir::TypeAlias {
|
||||
const KIND: SymbolKind = SymbolKind::TypeAlias;
|
||||
}
|
||||
impl ToNavFromAst for hir::Trait {
|
||||
const KIND: SymbolKind = SymbolKind::Trait;
|
||||
}
|
||||
|
||||
impl<D> ToNav for D
|
||||
where
|
||||
@ -209,8 +258,11 @@ where
|
||||
{
|
||||
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
||||
let src = self.source(db);
|
||||
let mut res =
|
||||
NavigationTarget::from_named(db, src.as_ref().map(|it| it as &dyn ast::NameOwner));
|
||||
let mut res = NavigationTarget::from_named(
|
||||
db,
|
||||
src.as_ref().map(|it| it as &dyn ast::NameOwner),
|
||||
D::KIND,
|
||||
);
|
||||
res.docs = self.docs(db);
|
||||
res.description = src.value.short_label();
|
||||
res
|
||||
@ -228,7 +280,7 @@ impl ToNav for hir::Module {
|
||||
}
|
||||
};
|
||||
let frange = src.with_value(syntax).original_file_range(db);
|
||||
NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, syntax.kind())
|
||||
NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module)
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +304,7 @@ impl ToNav for hir::Impl {
|
||||
"impl".into(),
|
||||
focus_range,
|
||||
frange.range,
|
||||
src.value.syntax().kind(),
|
||||
SymbolKind::Impl,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -263,7 +315,8 @@ impl ToNav for hir::Field {
|
||||
|
||||
match &src.value {
|
||||
FieldSource::Named(it) => {
|
||||
let mut res = NavigationTarget::from_named(db, src.with_value(it));
|
||||
let mut res =
|
||||
NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field);
|
||||
res.docs = self.docs(db);
|
||||
res.description = it.short_label();
|
||||
res
|
||||
@ -275,7 +328,7 @@ impl ToNav for hir::Field {
|
||||
"".into(),
|
||||
None,
|
||||
frange.range,
|
||||
it.syntax().kind(),
|
||||
SymbolKind::Field,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -286,8 +339,11 @@ impl ToNav for hir::MacroDef {
|
||||
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
||||
let src = self.source(db);
|
||||
log::debug!("nav target {:#?}", src.value.syntax());
|
||||
let mut res =
|
||||
NavigationTarget::from_named(db, src.as_ref().map(|it| it as &dyn ast::NameOwner));
|
||||
let mut res = NavigationTarget::from_named(
|
||||
db,
|
||||
src.as_ref().map(|it| it as &dyn ast::NameOwner),
|
||||
SymbolKind::Macro,
|
||||
);
|
||||
res.docs = self.docs(db);
|
||||
res
|
||||
}
|
||||
@ -330,7 +386,7 @@ impl ToNav for hir::Local {
|
||||
NavigationTarget {
|
||||
file_id: full_range.file_id,
|
||||
name,
|
||||
kind: IDENT_PAT,
|
||||
kind: SymbolKind::Local,
|
||||
full_range: full_range.range,
|
||||
focus_range: None,
|
||||
container_name: None,
|
||||
@ -354,7 +410,7 @@ impl ToNav for hir::TypeParam {
|
||||
NavigationTarget {
|
||||
file_id: src.file_id.original_file(db),
|
||||
name: self.name(db).to_string().into(),
|
||||
kind: TYPE_PARAM,
|
||||
kind: SymbolKind::TypeParam,
|
||||
full_range,
|
||||
focus_range,
|
||||
container_name: None,
|
||||
@ -371,7 +427,7 @@ impl ToNav for hir::LifetimeParam {
|
||||
NavigationTarget {
|
||||
file_id: src.file_id.original_file(db),
|
||||
name: self.name(db).to_string().into(),
|
||||
kind: LIFETIME_PARAM,
|
||||
kind: SymbolKind::LifetimeParam,
|
||||
full_range,
|
||||
focus_range: Some(full_range),
|
||||
container_name: None,
|
||||
@ -432,7 +488,7 @@ fn foo() { enum FooInner { } }
|
||||
5..13,
|
||||
),
|
||||
name: "FooInner",
|
||||
kind: ENUM,
|
||||
kind: Enum,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"enum FooInner",
|
||||
@ -448,7 +504,7 @@ fn foo() { enum FooInner { } }
|
||||
34..42,
|
||||
),
|
||||
name: "FooInner",
|
||||
kind: ENUM,
|
||||
kind: Enum,
|
||||
container_name: Some(
|
||||
"foo",
|
||||
),
|
||||
|
@ -1,15 +1,17 @@
|
||||
use syntax::{
|
||||
ast::{self, AttrsOwner, GenericParamsOwner, NameOwner},
|
||||
match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent,
|
||||
match_ast, AstNode, SourceFile, SyntaxNode, TextRange, WalkEvent,
|
||||
};
|
||||
|
||||
use crate::SymbolKind;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StructureNode {
|
||||
pub parent: Option<usize>,
|
||||
pub label: String,
|
||||
pub navigation_range: TextRange,
|
||||
pub node_range: TextRange,
|
||||
pub kind: SyntaxKind,
|
||||
pub kind: SymbolKind,
|
||||
pub detail: Option<String>,
|
||||
pub deprecated: bool,
|
||||
}
|
||||
@ -51,25 +53,27 @@ pub(crate) fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
|
||||
}
|
||||
|
||||
fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||
fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> {
|
||||
decl_with_detail(&node, None)
|
||||
fn decl<N: NameOwner + AttrsOwner>(node: N, kind: SymbolKind) -> Option<StructureNode> {
|
||||
decl_with_detail(&node, None, kind)
|
||||
}
|
||||
|
||||
fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
|
||||
node: &N,
|
||||
type_ref: Option<ast::Type>,
|
||||
kind: SymbolKind,
|
||||
) -> Option<StructureNode> {
|
||||
let detail = type_ref.map(|type_ref| {
|
||||
let mut detail = String::new();
|
||||
collapse_ws(type_ref.syntax(), &mut detail);
|
||||
detail
|
||||
});
|
||||
decl_with_detail(node, detail)
|
||||
decl_with_detail(node, detail, kind)
|
||||
}
|
||||
|
||||
fn decl_with_detail<N: NameOwner + AttrsOwner>(
|
||||
node: &N,
|
||||
detail: Option<String>,
|
||||
kind: SymbolKind,
|
||||
) -> Option<StructureNode> {
|
||||
let name = node.name()?;
|
||||
|
||||
@ -78,7 +82,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||
label: name.text().to_string(),
|
||||
navigation_range: name.syntax().text_range(),
|
||||
node_range: node.syntax().text_range(),
|
||||
kind: node.syntax().kind(),
|
||||
kind,
|
||||
detail,
|
||||
deprecated: node.attrs().filter_map(|x| x.simple_name()).any(|x| x == "deprecated"),
|
||||
})
|
||||
@ -117,18 +121,18 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||
collapse_ws(ret_type.syntax(), &mut detail);
|
||||
}
|
||||
|
||||
decl_with_detail(&it, Some(detail))
|
||||
decl_with_detail(&it, Some(detail), SymbolKind::Function)
|
||||
},
|
||||
ast::Struct(it) => decl(it),
|
||||
ast::Union(it) => decl(it),
|
||||
ast::Enum(it) => decl(it),
|
||||
ast::Variant(it) => decl(it),
|
||||
ast::Trait(it) => decl(it),
|
||||
ast::Module(it) => decl(it),
|
||||
ast::TypeAlias(it) => decl_with_type_ref(&it, it.ty()),
|
||||
ast::RecordField(it) => decl_with_type_ref(&it, it.ty()),
|
||||
ast::Const(it) => decl_with_type_ref(&it, it.ty()),
|
||||
ast::Static(it) => decl_with_type_ref(&it, it.ty()),
|
||||
ast::Struct(it) => decl(it, SymbolKind::Struct),
|
||||
ast::Union(it) => decl(it, SymbolKind::Union),
|
||||
ast::Enum(it) => decl(it, SymbolKind::Enum),
|
||||
ast::Variant(it) => decl(it, SymbolKind::Variant),
|
||||
ast::Trait(it) => decl(it, SymbolKind::Trait),
|
||||
ast::Module(it) => decl(it, SymbolKind::Module),
|
||||
ast::TypeAlias(it) => decl_with_type_ref(&it, it.ty(), SymbolKind::TypeAlias),
|
||||
ast::RecordField(it) => decl_with_type_ref(&it, it.ty(), SymbolKind::Field),
|
||||
ast::Const(it) => decl_with_type_ref(&it, it.ty(), SymbolKind::Const),
|
||||
ast::Static(it) => decl_with_type_ref(&it, it.ty(), SymbolKind::Static),
|
||||
ast::Impl(it) => {
|
||||
let target_type = it.self_ty()?;
|
||||
let target_trait = it.trait_();
|
||||
@ -144,13 +148,13 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||
label,
|
||||
navigation_range: target_type.syntax().text_range(),
|
||||
node_range: it.syntax().text_range(),
|
||||
kind: it.syntax().kind(),
|
||||
kind: SymbolKind::Impl,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
};
|
||||
Some(node)
|
||||
},
|
||||
ast::MacroRules(it) => decl(it),
|
||||
ast::MacroRules(it) => decl(it, SymbolKind::Macro),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -222,7 +226,7 @@ fn very_obsolete() {}
|
||||
label: "Foo",
|
||||
navigation_range: 8..11,
|
||||
node_range: 1..26,
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -233,7 +237,7 @@ fn very_obsolete() {}
|
||||
label: "x",
|
||||
navigation_range: 18..19,
|
||||
node_range: 18..24,
|
||||
kind: RECORD_FIELD,
|
||||
kind: Field,
|
||||
detail: Some(
|
||||
"i32",
|
||||
),
|
||||
@ -244,7 +248,7 @@ fn very_obsolete() {}
|
||||
label: "m",
|
||||
navigation_range: 32..33,
|
||||
node_range: 28..158,
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -255,7 +259,7 @@ fn very_obsolete() {}
|
||||
label: "bar1",
|
||||
navigation_range: 43..47,
|
||||
node_range: 40..52,
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
detail: Some(
|
||||
"fn()",
|
||||
),
|
||||
@ -268,7 +272,7 @@ fn very_obsolete() {}
|
||||
label: "bar2",
|
||||
navigation_range: 60..64,
|
||||
node_range: 57..81,
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
detail: Some(
|
||||
"fn<T>(t: T) -> T",
|
||||
),
|
||||
@ -281,7 +285,7 @@ fn very_obsolete() {}
|
||||
label: "bar3",
|
||||
navigation_range: 89..93,
|
||||
node_range: 86..156,
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
detail: Some(
|
||||
"fn<A, B>(a: A, b: B) -> Vec< u32 >",
|
||||
),
|
||||
@ -292,7 +296,7 @@ fn very_obsolete() {}
|
||||
label: "E",
|
||||
navigation_range: 165..166,
|
||||
node_range: 160..180,
|
||||
kind: ENUM,
|
||||
kind: Enum,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -303,7 +307,7 @@ fn very_obsolete() {}
|
||||
label: "X",
|
||||
navigation_range: 169..170,
|
||||
node_range: 169..170,
|
||||
kind: VARIANT,
|
||||
kind: Variant,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -314,7 +318,7 @@ fn very_obsolete() {}
|
||||
label: "Y",
|
||||
navigation_range: 172..173,
|
||||
node_range: 172..178,
|
||||
kind: VARIANT,
|
||||
kind: Variant,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -323,7 +327,7 @@ fn very_obsolete() {}
|
||||
label: "T",
|
||||
navigation_range: 186..187,
|
||||
node_range: 181..193,
|
||||
kind: TYPE_ALIAS,
|
||||
kind: TypeAlias,
|
||||
detail: Some(
|
||||
"()",
|
||||
),
|
||||
@ -334,7 +338,7 @@ fn very_obsolete() {}
|
||||
label: "S",
|
||||
navigation_range: 201..202,
|
||||
node_range: 194..213,
|
||||
kind: STATIC,
|
||||
kind: Static,
|
||||
detail: Some(
|
||||
"i32",
|
||||
),
|
||||
@ -345,7 +349,7 @@ fn very_obsolete() {}
|
||||
label: "C",
|
||||
navigation_range: 220..221,
|
||||
node_range: 214..232,
|
||||
kind: CONST,
|
||||
kind: Const,
|
||||
detail: Some(
|
||||
"i32",
|
||||
),
|
||||
@ -356,7 +360,7 @@ fn very_obsolete() {}
|
||||
label: "impl E",
|
||||
navigation_range: 239..240,
|
||||
node_range: 234..243,
|
||||
kind: IMPL,
|
||||
kind: Impl,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -365,7 +369,7 @@ fn very_obsolete() {}
|
||||
label: "impl fmt::Debug for E",
|
||||
navigation_range: 265..266,
|
||||
node_range: 245..269,
|
||||
kind: IMPL,
|
||||
kind: Impl,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -374,7 +378,7 @@ fn very_obsolete() {}
|
||||
label: "mc",
|
||||
navigation_range: 284..286,
|
||||
node_range: 271..303,
|
||||
kind: MACRO_RULES,
|
||||
kind: Macro,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -383,7 +387,7 @@ fn very_obsolete() {}
|
||||
label: "mcexp",
|
||||
navigation_range: 334..339,
|
||||
node_range: 305..356,
|
||||
kind: MACRO_RULES,
|
||||
kind: Macro,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -392,7 +396,7 @@ fn very_obsolete() {}
|
||||
label: "mcexp",
|
||||
navigation_range: 387..392,
|
||||
node_range: 358..409,
|
||||
kind: MACRO_RULES,
|
||||
kind: Macro,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
@ -401,7 +405,7 @@ fn very_obsolete() {}
|
||||
label: "obsolete",
|
||||
navigation_range: 428..436,
|
||||
node_range: 411..441,
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
detail: Some(
|
||||
"fn()",
|
||||
),
|
||||
@ -412,7 +416,7 @@ fn very_obsolete() {}
|
||||
label: "very_obsolete",
|
||||
navigation_range: 481..494,
|
||||
node_range: 443..499,
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
detail: Some(
|
||||
"fn()",
|
||||
),
|
||||
|
@ -9,7 +9,7 @@ use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset,
|
||||
|
||||
use crate::{
|
||||
display::{ToNav, TryToNav},
|
||||
FilePosition, NavigationTarget, RangeInfo,
|
||||
FilePosition, NavigationTarget, RangeInfo, SymbolKind,
|
||||
};
|
||||
|
||||
// Feature: Go to Definition
|
||||
@ -86,7 +86,7 @@ fn self_to_nav_target(self_param: ast::SelfParam, file_id: FileId) -> Option<Nav
|
||||
full_range: self_param.syntax().text_range(),
|
||||
focus_range: Some(self_token.text_range()),
|
||||
name: self_token.text().clone(),
|
||||
kind: self_token.kind(),
|
||||
kind: SymbolKind::SelfParam,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
|
@ -2191,7 +2191,7 @@ fn foo_<|>test() {}
|
||||
11..19,
|
||||
),
|
||||
name: "foo_test",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -2234,7 +2234,7 @@ mod tests<|> {
|
||||
4..9,
|
||||
),
|
||||
name: "tests",
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -2273,7 +2273,7 @@ fn main() { let s<|>t = S{ f1:0 }; }
|
||||
7..8,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2312,7 +2312,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
|
||||
24..25,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2331,7 +2331,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
|
||||
7..10,
|
||||
),
|
||||
name: "Arg",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct Arg",
|
||||
@ -2370,7 +2370,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
|
||||
24..25,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2389,7 +2389,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
|
||||
7..10,
|
||||
),
|
||||
name: "Arg",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct Arg",
|
||||
@ -2431,7 +2431,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
|
||||
7..8,
|
||||
),
|
||||
name: "A",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct A",
|
||||
@ -2450,7 +2450,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
|
||||
22..23,
|
||||
),
|
||||
name: "B",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct B",
|
||||
@ -2469,7 +2469,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
|
||||
53..54,
|
||||
),
|
||||
name: "C",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"pub struct C",
|
||||
@ -2508,7 +2508,7 @@ fn main() { let s<|>t = foo(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2548,7 +2548,7 @@ fn main() { let s<|>t = foo(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2567,7 +2567,7 @@ fn main() { let s<|>t = foo(); }
|
||||
23..24,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2607,7 +2607,7 @@ fn main() { let s<|>t = foo(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2626,7 +2626,7 @@ fn main() { let s<|>t = foo(); }
|
||||
19..22,
|
||||
),
|
||||
name: "Bar",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Bar",
|
||||
@ -2669,7 +2669,7 @@ fn main() { let s<|>t = foo(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2688,7 +2688,7 @@ fn main() { let s<|>t = foo(); }
|
||||
22..25,
|
||||
),
|
||||
name: "Bar",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Bar",
|
||||
@ -2707,7 +2707,7 @@ fn main() { let s<|>t = foo(); }
|
||||
39..41,
|
||||
),
|
||||
name: "S1",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S1",
|
||||
@ -2726,7 +2726,7 @@ fn main() { let s<|>t = foo(); }
|
||||
52..54,
|
||||
),
|
||||
name: "S2",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S2",
|
||||
@ -2763,7 +2763,7 @@ fn foo(ar<|>g: &impl Foo) {}
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2803,7 +2803,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2822,7 +2822,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
19..22,
|
||||
),
|
||||
name: "Bar",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Bar",
|
||||
@ -2841,7 +2841,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
|
||||
36..37,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2886,7 +2886,7 @@ mod future {
|
||||
140..146,
|
||||
),
|
||||
name: "Future",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"pub trait Future",
|
||||
@ -2905,7 +2905,7 @@ mod future {
|
||||
7..8,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -2943,7 +2943,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -2962,7 +2962,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
|
||||
23..24,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -3005,7 +3005,7 @@ fn main() { let s<|>t = foo(); }
|
||||
49..50,
|
||||
),
|
||||
name: "B",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct B",
|
||||
@ -3024,7 +3024,7 @@ fn main() { let s<|>t = foo(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -3061,7 +3061,7 @@ fn foo(ar<|>g: &dyn Foo) {}
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -3099,7 +3099,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
@ -3118,7 +3118,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
|
||||
23..24,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -3159,7 +3159,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
6..15,
|
||||
),
|
||||
name: "ImplTrait",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait ImplTrait",
|
||||
@ -3178,7 +3178,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
50..51,
|
||||
),
|
||||
name: "B",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct B",
|
||||
@ -3197,7 +3197,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
28..36,
|
||||
),
|
||||
name: "DynTrait",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait DynTrait",
|
||||
@ -3216,7 +3216,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
|
||||
65..66,
|
||||
),
|
||||
name: "S",
|
||||
kind: STRUCT,
|
||||
kind: Struct,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"struct S",
|
||||
@ -3264,7 +3264,7 @@ fn main() { let s<|>t = test().get(); }
|
||||
6..9,
|
||||
),
|
||||
name: "Foo",
|
||||
kind: TRAIT,
|
||||
kind: Trait,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"trait Foo",
|
||||
|
@ -64,7 +64,7 @@ use crate::display::ToNav;
|
||||
pub use crate::{
|
||||
call_hierarchy::CallItem,
|
||||
diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity},
|
||||
display::NavigationTarget,
|
||||
display::navigation_target::{NavigationTarget, SymbolKind},
|
||||
expand_macro::ExpandedMacro,
|
||||
file_structure::StructureNode,
|
||||
folding_ranges::{Fold, FoldKind},
|
||||
|
@ -78,7 +78,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("foo MODULE FileId(0) 0..8");
|
||||
nav.assert_match("foo Module FileId(0) 0..8");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -97,7 +97,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("foo MODULE FileId(0) 0..8");
|
||||
nav.assert_match("foo Module FileId(0) 0..8");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -113,7 +113,7 @@ mod tests {
|
||||
",
|
||||
);
|
||||
let nav = analysis.parent_module(pos).unwrap().pop().unwrap();
|
||||
nav.assert_match("baz MODULE FileId(0) 32..44");
|
||||
nav.assert_match("baz Module FileId(0) 32..44");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -24,7 +24,7 @@ use syntax::{
|
||||
match_ast, AstNode, SyntaxKind, SyntaxNode, TextRange, TokenAtOffset,
|
||||
};
|
||||
|
||||
use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo};
|
||||
use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeInfo, SymbolKind};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReferenceSearchResult {
|
||||
@ -278,7 +278,7 @@ fn try_find_self_references(
|
||||
full_range: self_param.syntax().text_range(),
|
||||
focus_range: Some(param_self_token.text_range()),
|
||||
name: param_self_token.text().clone(),
|
||||
kind: param_self_token.kind(),
|
||||
kind: SymbolKind::SelfParam,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -343,7 +343,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(0) 0..26 7..10 Other
|
||||
Foo Struct FileId(0) 0..26 7..10 Other
|
||||
|
||||
FileId(0) 101..104 StructLiteral
|
||||
"#]],
|
||||
@ -361,7 +361,7 @@ struct Foo<|> {}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(0) 0..13 7..10 Other
|
||||
Foo Struct FileId(0) 0..13 7..10 Other
|
||||
|
||||
FileId(0) 41..44 Other
|
||||
FileId(0) 54..57 StructLiteral
|
||||
@ -380,7 +380,7 @@ struct Foo<T> <|>{}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(0) 0..16 7..10 Other
|
||||
Foo Struct FileId(0) 0..16 7..10 Other
|
||||
|
||||
FileId(0) 64..67 StructLiteral
|
||||
"#]],
|
||||
@ -399,7 +399,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(0) 0..16 7..10 Other
|
||||
Foo Struct FileId(0) 0..16 7..10 Other
|
||||
|
||||
FileId(0) 54..57 StructLiteral
|
||||
"#]],
|
||||
@ -420,7 +420,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo ENUM FileId(0) 0..26 5..8 Other
|
||||
Foo Enum FileId(0) 0..26 5..8 Other
|
||||
|
||||
FileId(0) 63..66 EnumLiteral
|
||||
"#]],
|
||||
@ -441,7 +441,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo ENUM FileId(0) 0..26 5..8 Other
|
||||
Foo Enum FileId(0) 0..26 5..8 Other
|
||||
|
||||
FileId(0) 50..53 Other
|
||||
FileId(0) 63..66 EnumLiteral
|
||||
@ -463,7 +463,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo ENUM FileId(0) 0..32 5..8 Other
|
||||
Foo Enum FileId(0) 0..32 5..8 Other
|
||||
|
||||
FileId(0) 73..76 EnumLiteral
|
||||
"#]],
|
||||
@ -484,7 +484,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo ENUM FileId(0) 0..33 5..8 Other
|
||||
Foo Enum FileId(0) 0..33 5..8 Other
|
||||
|
||||
FileId(0) 70..73 EnumLiteral
|
||||
"#]],
|
||||
@ -507,7 +507,7 @@ fn main() {
|
||||
i = 5;
|
||||
}"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(0) 24..25 Other Write
|
||||
i Local FileId(0) 24..25 Other Write
|
||||
|
||||
FileId(0) 50..51 Other Write
|
||||
FileId(0) 54..55 Other Read
|
||||
@ -531,7 +531,7 @@ fn bar() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
spam IDENT_PAT FileId(0) 19..23 Other
|
||||
spam Local FileId(0) 19..23 Other
|
||||
|
||||
FileId(0) 34..38 Other Read
|
||||
FileId(0) 41..45 Other Read
|
||||
@ -546,7 +546,7 @@ fn bar() {
|
||||
fn foo(i : u32) -> u32 { i<|> }
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(0) 7..8 Other
|
||||
i Local FileId(0) 7..8 Other
|
||||
|
||||
FileId(0) 25..26 Other Read
|
||||
"#]],
|
||||
@ -560,7 +560,7 @@ fn foo(i : u32) -> u32 { i<|> }
|
||||
fn foo(i<|> : u32) -> u32 { i }
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(0) 7..8 Other
|
||||
i Local FileId(0) 7..8 Other
|
||||
|
||||
FileId(0) 25..26 Other Read
|
||||
"#]],
|
||||
@ -581,7 +581,7 @@ fn main(s: Foo) {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
spam RECORD_FIELD FileId(0) 17..30 21..25 Other
|
||||
spam Field FileId(0) 17..30 21..25 Other
|
||||
|
||||
FileId(0) 67..71 Other Read
|
||||
"#]],
|
||||
@ -598,7 +598,7 @@ impl Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
f FN FileId(0) 27..43 30..31 Other
|
||||
f Function FileId(0) 27..43 30..31 Other
|
||||
|
||||
"#]],
|
||||
);
|
||||
@ -615,7 +615,7 @@ enum Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
B VARIANT FileId(0) 22..23 22..23 Other
|
||||
B Variant FileId(0) 22..23 22..23 Other
|
||||
|
||||
"#]],
|
||||
);
|
||||
@ -632,7 +632,7 @@ enum Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 26..35 26..31 Other
|
||||
field Field FileId(0) 26..35 26..31 Other
|
||||
|
||||
"#]],
|
||||
);
|
||||
@ -673,7 +673,7 @@ fn f() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(1) 17..51 28..31 Other
|
||||
Foo Struct FileId(1) 17..51 28..31 Other
|
||||
|
||||
FileId(0) 53..56 StructLiteral
|
||||
FileId(2) 79..82 StructLiteral
|
||||
@ -703,7 +703,7 @@ pub struct Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
foo SOURCE_FILE FileId(1) 0..35 Other
|
||||
foo Module FileId(1) 0..35 Other
|
||||
|
||||
FileId(0) 14..17 Other
|
||||
"#]],
|
||||
@ -731,7 +731,7 @@ pub(super) struct Foo<|> {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Foo STRUCT FileId(2) 0..41 18..21 Other
|
||||
Foo Struct FileId(2) 0..41 18..21 Other
|
||||
|
||||
FileId(1) 20..23 Other
|
||||
FileId(1) 47..50 StructLiteral
|
||||
@ -759,7 +759,7 @@ pub(super) struct Foo<|> {
|
||||
code,
|
||||
None,
|
||||
expect![[r#"
|
||||
quux FN FileId(0) 19..35 26..30 Other
|
||||
quux Function FileId(0) 19..35 26..30 Other
|
||||
|
||||
FileId(1) 16..20 StructLiteral
|
||||
FileId(2) 16..20 StructLiteral
|
||||
@ -770,7 +770,7 @@ pub(super) struct Foo<|> {
|
||||
code,
|
||||
Some(SearchScope::single_file(FileId(2))),
|
||||
expect![[r#"
|
||||
quux FN FileId(0) 19..35 26..30 Other
|
||||
quux Function FileId(0) 19..35 26..30 Other
|
||||
|
||||
FileId(2) 16..20 StructLiteral
|
||||
"#]],
|
||||
@ -790,7 +790,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
m1 MACRO_RULES FileId(0) 0..46 29..31 Other
|
||||
m1 Macro FileId(0) 0..46 29..31 Other
|
||||
|
||||
FileId(0) 63..65 StructLiteral
|
||||
FileId(0) 73..75 StructLiteral
|
||||
@ -808,7 +808,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(0) 23..24 Other Write
|
||||
i Local FileId(0) 23..24 Other Write
|
||||
|
||||
FileId(0) 34..35 Other Write
|
||||
FileId(0) 38..39 Other Read
|
||||
@ -830,7 +830,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
f RECORD_FIELD FileId(0) 15..21 15..16 Other
|
||||
f Field FileId(0) 15..21 15..16 Other
|
||||
|
||||
FileId(0) 55..56 RecordFieldExprOrPat Read
|
||||
FileId(0) 68..69 Other Write
|
||||
@ -848,7 +848,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
i IDENT_PAT FileId(0) 19..20 Other
|
||||
i Local FileId(0) 19..20 Other
|
||||
|
||||
FileId(0) 26..27 Other Write
|
||||
"#]],
|
||||
@ -872,7 +872,7 @@ fn main() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
new FN FileId(0) 54..81 61..64 Other
|
||||
new Function FileId(0) 54..81 61..64 Other
|
||||
|
||||
FileId(0) 126..129 StructLiteral
|
||||
"#]],
|
||||
@ -894,7 +894,7 @@ use crate::f;
|
||||
fn g() { f(); }
|
||||
"#,
|
||||
expect![[r#"
|
||||
f FN FileId(0) 22..31 25..26 Other
|
||||
f Function FileId(0) 22..31 25..26 Other
|
||||
|
||||
FileId(1) 11..12 Other
|
||||
FileId(1) 24..25 StructLiteral
|
||||
@ -917,7 +917,7 @@ fn f(s: S) {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 15..24 15..20 Other
|
||||
field Field FileId(0) 15..24 15..20 Other
|
||||
|
||||
FileId(0) 68..73 FieldShorthandForField Read
|
||||
"#]],
|
||||
@ -941,7 +941,7 @@ fn f(e: En) {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 32..41 32..37 Other
|
||||
field Field FileId(0) 32..41 32..37 Other
|
||||
|
||||
FileId(0) 102..107 FieldShorthandForField Read
|
||||
"#]],
|
||||
@ -965,7 +965,7 @@ fn f() -> m::En {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
field RECORD_FIELD FileId(0) 56..65 56..61 Other
|
||||
field Field FileId(0) 56..65 56..61 Other
|
||||
|
||||
FileId(0) 125..130 RecordFieldExprOrPat Read
|
||||
"#]],
|
||||
@ -990,7 +990,7 @@ impl Foo {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
self SELF_KW FileId(0) 47..51 47..51 SelfKw Read
|
||||
self SelfParam FileId(0) 47..51 47..51 SelfKw Read
|
||||
|
||||
FileId(0) 71..75 SelfKw Read
|
||||
FileId(0) 152..156 SelfKw Read
|
||||
@ -1038,7 +1038,7 @@ fn foo<'a, 'b: 'a>(x: &'a<|> ()) -> &'a () where &'a (): Foo<'a> {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
'a LIFETIME_PARAM FileId(0) 55..57 55..57 Lifetime
|
||||
'a LifetimeParam FileId(0) 55..57 55..57 Lifetime
|
||||
|
||||
FileId(0) 63..65 Lifetime
|
||||
FileId(0) 71..73 Lifetime
|
||||
@ -1056,7 +1056,7 @@ fn foo<'a, 'b: 'a>(x: &'a<|> ()) -> &'a () where &'a (): Foo<'a> {
|
||||
type Foo<'a, T> where T: 'a<|> = &'a T;
|
||||
"#,
|
||||
expect![[r#"
|
||||
'a LIFETIME_PARAM FileId(0) 9..11 9..11 Lifetime
|
||||
'a LifetimeParam FileId(0) 9..11 9..11 Lifetime
|
||||
|
||||
FileId(0) 25..27 Lifetime
|
||||
FileId(0) 31..33 Lifetime
|
||||
@ -1078,7 +1078,7 @@ impl<'a> Foo<'a> for &'a () {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
'a LIFETIME_PARAM FileId(0) 47..49 47..49 Lifetime
|
||||
'a LifetimeParam FileId(0) 47..49 47..49 Lifetime
|
||||
|
||||
FileId(0) 55..57 Lifetime
|
||||
FileId(0) 64..66 Lifetime
|
||||
|
@ -12,7 +12,7 @@ use syntax::{
|
||||
|
||||
use crate::{
|
||||
display::{ToNav, TryToNav},
|
||||
FileId, NavigationTarget,
|
||||
FileId, NavigationTarget, SymbolKind,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -137,7 +137,11 @@ fn runnable_fn(sema: &Semantics<RootDatabase>, func: ast::Fn, file_id: FileId) -
|
||||
}
|
||||
};
|
||||
|
||||
let nav = NavigationTarget::from_named(sema.db, InFile::new(file_id.into(), &func));
|
||||
let nav = NavigationTarget::from_named(
|
||||
sema.db,
|
||||
InFile::new(file_id.into(), &func),
|
||||
SymbolKind::Function,
|
||||
);
|
||||
let cfg = def.attrs(sema.db).cfg();
|
||||
Some(Runnable { nav, kind, cfg })
|
||||
}
|
||||
@ -204,7 +208,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op
|
||||
nav.focus_range = None;
|
||||
nav.description = None;
|
||||
nav.docs = None;
|
||||
nav.kind = syntax::SyntaxKind::COMMENT;
|
||||
nav.kind = SymbolKind::DocTest;
|
||||
let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() };
|
||||
Some(res)
|
||||
}
|
||||
@ -352,7 +356,7 @@ fn bench() {}
|
||||
4..8,
|
||||
),
|
||||
name: "main",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -370,7 +374,7 @@ fn bench() {}
|
||||
26..34,
|
||||
),
|
||||
name: "test_foo",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -395,7 +399,7 @@ fn bench() {}
|
||||
62..70,
|
||||
),
|
||||
name: "test_foo",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -420,7 +424,7 @@ fn bench() {}
|
||||
89..94,
|
||||
),
|
||||
name: "bench",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -517,7 +521,7 @@ struct StructWithRunnable(String);
|
||||
4..8,
|
||||
),
|
||||
name: "main",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -533,7 +537,7 @@ struct StructWithRunnable(String);
|
||||
full_range: 15..74,
|
||||
focus_range: None,
|
||||
name: "should_have_runnable",
|
||||
kind: COMMENT,
|
||||
kind: DocTest,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -553,7 +557,7 @@ struct StructWithRunnable(String);
|
||||
full_range: 76..148,
|
||||
focus_range: None,
|
||||
name: "should_have_runnable_1",
|
||||
kind: COMMENT,
|
||||
kind: DocTest,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -573,7 +577,7 @@ struct StructWithRunnable(String);
|
||||
full_range: 150..254,
|
||||
focus_range: None,
|
||||
name: "should_have_runnable_2",
|
||||
kind: COMMENT,
|
||||
kind: DocTest,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -593,7 +597,7 @@ struct StructWithRunnable(String);
|
||||
full_range: 756..821,
|
||||
focus_range: None,
|
||||
name: "StructWithRunnable",
|
||||
kind: COMMENT,
|
||||
kind: DocTest,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -639,7 +643,7 @@ impl Data {
|
||||
4..8,
|
||||
),
|
||||
name: "main",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -655,7 +659,7 @@ impl Data {
|
||||
full_range: 44..98,
|
||||
focus_range: None,
|
||||
name: "foo",
|
||||
kind: COMMENT,
|
||||
kind: DocTest,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -696,7 +700,7 @@ mod test_mod {
|
||||
5..13,
|
||||
),
|
||||
name: "test_mod",
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -716,7 +720,7 @@ mod test_mod {
|
||||
35..44,
|
||||
),
|
||||
name: "test_foo1",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -776,7 +780,7 @@ mod root_tests {
|
||||
26..40,
|
||||
),
|
||||
name: "nested_tests_0",
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -796,7 +800,7 @@ mod root_tests {
|
||||
55..69,
|
||||
),
|
||||
name: "nested_tests_1",
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -816,7 +820,7 @@ mod root_tests {
|
||||
107..121,
|
||||
),
|
||||
name: "nested_test_11",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -841,7 +845,7 @@ mod root_tests {
|
||||
163..177,
|
||||
),
|
||||
name: "nested_test_12",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -866,7 +870,7 @@ mod root_tests {
|
||||
206..220,
|
||||
),
|
||||
name: "nested_tests_2",
|
||||
kind: MODULE,
|
||||
kind: Module,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -886,7 +890,7 @@ mod root_tests {
|
||||
258..271,
|
||||
),
|
||||
name: "nested_test_2",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -929,7 +933,7 @@ fn test_foo1() {}
|
||||
36..45,
|
||||
),
|
||||
name: "test_foo1",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
@ -979,7 +983,7 @@ fn test_foo1() {}
|
||||
58..67,
|
||||
),
|
||||
name: "test_foo1",
|
||||
kind: FN,
|
||||
kind: Function,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
|
@ -39,7 +39,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use syntax::{
|
||||
ast::{self, NameOwner},
|
||||
match_ast, AstNode, Parse, SmolStr, SourceFile,
|
||||
SyntaxKind::{self, *},
|
||||
SyntaxKind::*,
|
||||
SyntaxNode, SyntaxNodePtr, TextRange, WalkEvent,
|
||||
};
|
||||
|
||||
@ -323,7 +323,7 @@ impl Query {
|
||||
let (start, end) = SymbolIndex::map_value_to_range(indexed_value.value);
|
||||
|
||||
for symbol in &symbol_index.symbols[start..end] {
|
||||
if self.only_types && !is_type(symbol.kind) {
|
||||
if self.only_types && !symbol.kind.is_type() {
|
||||
continue;
|
||||
}
|
||||
if self.exact && symbol.name != self.query {
|
||||
@ -341,23 +341,44 @@ impl Query {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_type(kind: SyntaxKind) -> bool {
|
||||
matches!(kind, STRUCT | ENUM | TRAIT | TYPE_ALIAS)
|
||||
}
|
||||
|
||||
/// The actual data that is stored in the index. It should be as compact as
|
||||
/// possible.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FileSymbol {
|
||||
pub file_id: FileId,
|
||||
pub name: SmolStr,
|
||||
pub kind: SyntaxKind,
|
||||
pub kind: FileSymbolKind,
|
||||
pub range: TextRange,
|
||||
pub ptr: SyntaxNodePtr,
|
||||
pub name_range: Option<TextRange>,
|
||||
pub container_name: Option<SmolStr>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||
pub enum FileSymbolKind {
|
||||
Function,
|
||||
Struct,
|
||||
Enum,
|
||||
Trait,
|
||||
Module,
|
||||
TypeAlias,
|
||||
Const,
|
||||
Static,
|
||||
Macro,
|
||||
}
|
||||
|
||||
impl FileSymbolKind {
|
||||
fn is_type(self: FileSymbolKind) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
FileSymbolKind::Struct
|
||||
| FileSymbolKind::Enum
|
||||
| FileSymbolKind::Trait
|
||||
| FileSymbolKind::TypeAlias
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn source_file_to_file_symbols(source_file: &SourceFile, file_id: FileId) -> Vec<FileSymbol> {
|
||||
let mut symbols = Vec::new();
|
||||
let mut stack = Vec::new();
|
||||
@ -412,7 +433,18 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
|
||||
fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> {
|
||||
to_symbol(node).map(move |(name, ptr, name_range)| FileSymbol {
|
||||
name,
|
||||
kind: node.kind(),
|
||||
kind: match node.kind() {
|
||||
FN => FileSymbolKind::Function,
|
||||
STRUCT => FileSymbolKind::Struct,
|
||||
ENUM => FileSymbolKind::Enum,
|
||||
TRAIT => FileSymbolKind::Trait,
|
||||
MODULE => FileSymbolKind::Module,
|
||||
TYPE_ALIAS => FileSymbolKind::TypeAlias,
|
||||
CONST => FileSymbolKind::Const,
|
||||
STATIC => FileSymbolKind::Static,
|
||||
MACRO_RULES => FileSymbolKind::Macro,
|
||||
kind => unreachable!("{:?}", kind),
|
||||
},
|
||||
range: node.text_range(),
|
||||
ptr,
|
||||
file_id,
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
|
||||
use ide::{
|
||||
CompletionResolveCapability, FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData,
|
||||
NavigationTarget, Query, RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit,
|
||||
NavigationTarget, Query, RangeInfo, Runnable, RunnableKind, SearchScope, SymbolKind, TextEdit,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use lsp_server::ErrorCode;
|
||||
@ -27,7 +27,7 @@ use project_model::TargetKind;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::to_value;
|
||||
use stdx::{format_to, split_once};
|
||||
use syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize};
|
||||
use syntax::{algo, ast, AstNode, TextRange, TextSize};
|
||||
|
||||
use crate::{
|
||||
cargo_target_spec::CargoTargetSpec,
|
||||
@ -1037,10 +1037,10 @@ pub(crate) fn handle_code_lens(
|
||||
.filter(|it| {
|
||||
matches!(
|
||||
it.kind,
|
||||
SyntaxKind::TRAIT
|
||||
| SyntaxKind::STRUCT
|
||||
| SyntaxKind::ENUM
|
||||
| SyntaxKind::UNION
|
||||
SymbolKind::Trait
|
||||
| SymbolKind::Struct
|
||||
| SymbolKind::Enum
|
||||
| SymbolKind::Union
|
||||
)
|
||||
})
|
||||
.map(|it| {
|
||||
@ -1263,7 +1263,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
|
||||
let RangeInfo { range: _, info: navs } = nav_info;
|
||||
let res = navs
|
||||
.into_iter()
|
||||
.filter(|it| it.kind == SyntaxKind::FN)
|
||||
.filter(|it| it.kind == SymbolKind::Function)
|
||||
.map(|it| to_proto::call_hierarchy_item(&snap, it))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
|
@ -9,10 +9,9 @@ use ide::{
|
||||
FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag,
|
||||
HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup,
|
||||
NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange,
|
||||
SourceFileEdit, TextEdit, TextRange, TextSize,
|
||||
SourceFileEdit, SymbolKind, TextEdit, TextRange, TextSize,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use syntax::SyntaxKind;
|
||||
|
||||
use crate::{
|
||||
cargo_target_spec::CargoTargetSpec, global_state::GlobalStateSnapshot,
|
||||
@ -30,21 +29,25 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
|
||||
lsp_types::Range::new(start, end)
|
||||
}
|
||||
|
||||
pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind {
|
||||
match syntax_kind {
|
||||
SyntaxKind::FN => lsp_types::SymbolKind::Function,
|
||||
SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct,
|
||||
SyntaxKind::ENUM => lsp_types::SymbolKind::Enum,
|
||||
SyntaxKind::VARIANT => lsp_types::SymbolKind::EnumMember,
|
||||
SyntaxKind::TRAIT => lsp_types::SymbolKind::Interface,
|
||||
SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function,
|
||||
SyntaxKind::MODULE => lsp_types::SymbolKind::Module,
|
||||
SyntaxKind::TYPE_ALIAS => lsp_types::SymbolKind::TypeParameter,
|
||||
SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field,
|
||||
SyntaxKind::STATIC => lsp_types::SymbolKind::Constant,
|
||||
SyntaxKind::CONST => lsp_types::SymbolKind::Constant,
|
||||
SyntaxKind::IMPL => lsp_types::SymbolKind::Object,
|
||||
_ => lsp_types::SymbolKind::Variable,
|
||||
pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
||||
match symbol_kind {
|
||||
SymbolKind::Function => lsp_types::SymbolKind::Function,
|
||||
SymbolKind::Struct => lsp_types::SymbolKind::Struct,
|
||||
SymbolKind::Enum => lsp_types::SymbolKind::Enum,
|
||||
SymbolKind::Variant => lsp_types::SymbolKind::EnumMember,
|
||||
SymbolKind::Trait => lsp_types::SymbolKind::Interface,
|
||||
SymbolKind::Macro => lsp_types::SymbolKind::Function,
|
||||
SymbolKind::Module => lsp_types::SymbolKind::Module,
|
||||
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TypeParameter,
|
||||
SymbolKind::Field => lsp_types::SymbolKind::Field,
|
||||
SymbolKind::Static => lsp_types::SymbolKind::Constant,
|
||||
SymbolKind::Const => lsp_types::SymbolKind::Constant,
|
||||
SymbolKind::Impl => lsp_types::SymbolKind::Object,
|
||||
SymbolKind::Local
|
||||
| SymbolKind::SelfParam
|
||||
| SymbolKind::LifetimeParam
|
||||
| SymbolKind::DocTest => lsp_types::SymbolKind::Variable,
|
||||
SymbolKind::Union => lsp_types::SymbolKind::Struct,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user