mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Fill deprecation for LSP
This commit is contained in:
parent
569e1e871e
commit
852b083794
6 changed files with 86 additions and 23 deletions
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
created: "2019-01-26T07:11:02.463391362+00:00"
|
created: "2019-02-05T22:03:50.763530100Z"
|
||||||
creator: insta@0.5.2
|
creator: insta@0.6.1
|
||||||
expression: structure
|
|
||||||
source: crates/ra_ide_api_light/src/structure.rs
|
source: crates/ra_ide_api_light/src/structure.rs
|
||||||
|
expression: structure
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
StructureNode {
|
StructureNode {
|
||||||
|
@ -11,7 +11,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [8; 11),
|
navigation_range: [8; 11),
|
||||||
node_range: [1; 26),
|
node_range: [1; 26),
|
||||||
kind: STRUCT_DEF,
|
kind: STRUCT_DEF,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -23,7 +24,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: NAMED_FIELD_DEF,
|
kind: NAMED_FIELD_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"i32"
|
"i32"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -31,7 +33,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [32; 33),
|
navigation_range: [32; 33),
|
||||||
node_range: [28; 158),
|
node_range: [28; 158),
|
||||||
kind: MODULE,
|
kind: MODULE,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -43,7 +46,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: FN_DEF,
|
kind: FN_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn()"
|
"fn()"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -55,7 +59,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: FN_DEF,
|
kind: FN_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn<T>(t: T) -> T"
|
"fn<T>(t: T) -> T"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -67,7 +72,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: FN_DEF,
|
kind: FN_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"fn<A, B>(a: A, b: B) -> Vec< u32 >"
|
"fn<A, B>(a: A, b: B) -> Vec< u32 >"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -75,7 +81,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [165; 166),
|
navigation_range: [165; 166),
|
||||||
node_range: [160; 180),
|
node_range: [160; 180),
|
||||||
kind: ENUM_DEF,
|
kind: ENUM_DEF,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -85,7 +92,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [169; 170),
|
navigation_range: [169; 170),
|
||||||
node_range: [169; 170),
|
node_range: [169; 170),
|
||||||
kind: ENUM_VARIANT,
|
kind: ENUM_VARIANT,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: Some(
|
parent: Some(
|
||||||
|
@ -95,7 +103,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [172; 173),
|
navigation_range: [172; 173),
|
||||||
node_range: [172; 178),
|
node_range: [172; 178),
|
||||||
kind: ENUM_VARIANT,
|
kind: ENUM_VARIANT,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -105,7 +114,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: TYPE_DEF,
|
kind: TYPE_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"()"
|
"()"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -115,7 +125,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: STATIC_DEF,
|
kind: STATIC_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"i32"
|
"i32"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -125,7 +136,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
kind: CONST_DEF,
|
kind: CONST_DEF,
|
||||||
detail: Some(
|
detail: Some(
|
||||||
"i32"
|
"i32"
|
||||||
)
|
),
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -133,7 +145,8 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [239; 240),
|
navigation_range: [239; 240),
|
||||||
node_range: [234; 243),
|
node_range: [234; 243),
|
||||||
kind: IMPL_BLOCK,
|
kind: IMPL_BLOCK,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
},
|
},
|
||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
|
@ -141,6 +154,29 @@ source: crates/ra_ide_api_light/src/structure.rs
|
||||||
navigation_range: [265; 266),
|
navigation_range: [265; 266),
|
||||||
node_range: [245; 269),
|
node_range: [245; 269),
|
||||||
kind: IMPL_BLOCK,
|
kind: IMPL_BLOCK,
|
||||||
detail: None
|
detail: None,
|
||||||
|
deprecated: false
|
||||||
|
},
|
||||||
|
StructureNode {
|
||||||
|
parent: None,
|
||||||
|
label: "obsolete",
|
||||||
|
navigation_range: [288; 296),
|
||||||
|
node_range: [271; 301),
|
||||||
|
kind: FN_DEF,
|
||||||
|
detail: Some(
|
||||||
|
"fn()"
|
||||||
|
),
|
||||||
|
deprecated: true
|
||||||
|
},
|
||||||
|
StructureNode {
|
||||||
|
parent: None,
|
||||||
|
label: "very_obsolete",
|
||||||
|
navigation_range: [341; 354),
|
||||||
|
node_range: [303; 359),
|
||||||
|
kind: FN_DEF,
|
||||||
|
detail: Some(
|
||||||
|
"fn()"
|
||||||
|
),
|
||||||
|
deprecated: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::TextRange;
|
||||||
|
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
algo::visit::{visitor, Visitor},
|
algo::visit::{visitor, Visitor},
|
||||||
ast::{self, NameOwner, TypeParamsOwner},
|
ast::{self, AttrsOwner, NameOwner, TypeParamsOwner},
|
||||||
AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
|
AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ pub struct StructureNode {
|
||||||
pub node_range: TextRange,
|
pub node_range: TextRange,
|
||||||
pub kind: SyntaxKind,
|
pub kind: SyntaxKind,
|
||||||
pub detail: Option<String>,
|
pub detail: Option<String>,
|
||||||
|
pub deprecated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
|
pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
|
||||||
|
@ -40,11 +41,11 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
fn decl<N: NameOwner>(node: &N) -> Option<StructureNode> {
|
fn decl<N: NameOwner + AttrsOwner>(node: &N) -> Option<StructureNode> {
|
||||||
decl_with_detail(node, None)
|
decl_with_detail(node, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_with_type_ref<N: NameOwner>(
|
fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
|
||||||
node: &N,
|
node: &N,
|
||||||
type_ref: Option<&ast::TypeRef>,
|
type_ref: Option<&ast::TypeRef>,
|
||||||
) -> Option<StructureNode> {
|
) -> Option<StructureNode> {
|
||||||
|
@ -56,8 +57,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
decl_with_detail(node, detail)
|
decl_with_detail(node, detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_with_detail<N: NameOwner>(node: &N, detail: Option<String>) -> Option<StructureNode> {
|
fn decl_with_detail<N: NameOwner + AttrsOwner>(
|
||||||
|
node: &N,
|
||||||
|
detail: Option<String>,
|
||||||
|
) -> Option<StructureNode> {
|
||||||
let name = node.name()?;
|
let name = node.name()?;
|
||||||
|
dbg!(name.text().to_string());
|
||||||
Some(StructureNode {
|
Some(StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: name.text().to_string(),
|
label: name.text().to_string(),
|
||||||
|
@ -65,6 +70,10 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
node_range: node.syntax().range(),
|
node_range: node.syntax().range(),
|
||||||
kind: node.syntax().kind(),
|
kind: node.syntax().kind(),
|
||||||
detail,
|
detail,
|
||||||
|
deprecated: node
|
||||||
|
.attrs()
|
||||||
|
.filter_map(|x| x.as_named())
|
||||||
|
.any(|x| x == "deprecated"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +137,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
node_range: im.syntax().range(),
|
node_range: im.syntax().range(),
|
||||||
kind: im.syntax().kind(),
|
kind: im.syntax().kind(),
|
||||||
detail: None,
|
detail: None,
|
||||||
|
deprecated: false,
|
||||||
};
|
};
|
||||||
Some(node)
|
Some(node)
|
||||||
})
|
})
|
||||||
|
@ -165,6 +175,12 @@ const C: i32 = 92;
|
||||||
impl E {}
|
impl E {}
|
||||||
|
|
||||||
impl fmt::Debug for E {}
|
impl fmt::Debug for E {}
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
fn obsolete() {}
|
||||||
|
|
||||||
|
#[deprecated(note = "for awhile")]
|
||||||
|
fn very_obsolete() {}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
let structure = file_structure(&file);
|
let structure = file_structure(&file);
|
||||||
|
|
|
@ -140,7 +140,7 @@ pub fn handle_document_symbol(
|
||||||
name: symbol.label,
|
name: symbol.label,
|
||||||
detail: symbol.detail,
|
detail: symbol.detail,
|
||||||
kind: symbol.kind.conv(),
|
kind: symbol.kind.conv(),
|
||||||
deprecated: None,
|
deprecated: Some(symbol.deprecated),
|
||||||
range: symbol.node_range.conv_with(&line_index),
|
range: symbol.node_range.conv_with(&line_index),
|
||||||
selection_range: symbol.navigation_range.conv_with(&line_index),
|
selection_range: symbol.navigation_range.conv_with(&line_index),
|
||||||
children: None,
|
children: None,
|
||||||
|
|
|
@ -177,6 +177,16 @@ impl Attr {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn as_named(&self) -> Option<SmolStr> {
|
||||||
|
let tt = self.value()?;
|
||||||
|
let attr = tt.syntax().children().nth(1)?;
|
||||||
|
if attr.kind() == IDENT {
|
||||||
|
Some(attr.leaf_text().unwrap().clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comment {
|
impl Comment {
|
||||||
|
|
|
@ -755,6 +755,7 @@ impl ToOwned for EnumVariant {
|
||||||
|
|
||||||
impl ast::NameOwner for EnumVariant {}
|
impl ast::NameOwner for EnumVariant {}
|
||||||
impl ast::DocCommentsOwner for EnumVariant {}
|
impl ast::DocCommentsOwner for EnumVariant {}
|
||||||
|
impl ast::AttrsOwner for EnumVariant {}
|
||||||
impl EnumVariant {
|
impl EnumVariant {
|
||||||
pub fn expr(&self) -> Option<&Expr> {
|
pub fn expr(&self) -> Option<&Expr> {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
|
|
|
@ -281,7 +281,7 @@ Grammar(
|
||||||
"DocCommentsOwner"
|
"DocCommentsOwner"
|
||||||
], options: [["variant_list", "EnumVariantList"]] ),
|
], options: [["variant_list", "EnumVariantList"]] ),
|
||||||
"EnumVariantList": ( collections: [["variants", "EnumVariant"]] ),
|
"EnumVariantList": ( collections: [["variants", "EnumVariant"]] ),
|
||||||
"EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ),
|
"EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ),
|
||||||
"TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ),
|
"TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ),
|
||||||
"Module": (
|
"Module": (
|
||||||
traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ],
|
traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ],
|
||||||
|
|
Loading…
Reference in a new issue