fix: Recognize Self as a proper keyword

This commit is contained in:
Lukas Wirth 2022-03-05 23:20:06 +01:00
parent 8f504dc873
commit c0d6471143
27 changed files with 98 additions and 49 deletions

View file

@ -5,7 +5,11 @@ use std::{
iter,
};
use crate::{db::AstDatabase, hygiene::Hygiene, name::Name};
use crate::{
db::AstDatabase,
hygiene::Hygiene,
name::{known, Name},
};
use base_db::CrateId;
use either::Either;
use syntax::{ast, AstNode};
@ -162,6 +166,15 @@ fn convert_path(
}
}
}
ast::PathSegmentKind::SelfTypeKw => {
let mut res = prefix.unwrap_or_else(|| {
ModPath::from_kind(
segment.coloncolon_token().map_or(PathKind::Plain, |_| PathKind::Abs),
)
});
res.segments.push(known::SELF_TYPE);
res
}
ast::PathSegmentKind::CrateKw => {
if prefix.is_some() {
return None;