Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
-rw-r--r--crates/syntax/src/ast/node_ext.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index 229c71c76b..4a3abcb3a9 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -183,6 +183,7 @@ impl ast::Attr {
pub enum PathSegmentKind {
Name(ast::NameRef),
Type { type_ref: Option<ast::Type>, trait_ref: Option<ast::PathType> },
+ SelfTypeKw,
SelfKw,
SuperKw,
CrateKw,
@@ -204,6 +205,10 @@ impl ast::PathSegment {
self.name_ref().and_then(|it| it.self_token())
}
+ pub fn self_type_token(&self) -> Option<SyntaxToken> {
+ self.name_ref().and_then(|it| it.Self_token())
+ }
+
pub fn super_token(&self) -> Option<SyntaxToken> {
self.name_ref().and_then(|it| it.super_token())
}
@@ -211,6 +216,7 @@ impl ast::PathSegment {
pub fn kind(&self) -> Option<PathSegmentKind> {
let res = if let Some(name_ref) = self.name_ref() {
match name_ref.syntax().first_token().map(|it| it.kind()) {
+ Some(T![Self]) => PathSegmentKind::SelfTypeKw,
Some(T![self]) => PathSegmentKind::SelfKw,
Some(T![super]) => PathSegmentKind::SuperKw,
Some(T![crate]) => PathSegmentKind::CrateKw,