mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Merge commit '21b06c1beb
' into sync-from-ra
This commit is contained in:
parent
cac74d98f6
commit
e37cf75791
59 changed files with 1080 additions and 477 deletions
|
@ -275,10 +275,19 @@ impl ast::Path {
|
|||
successors(Some(self.clone()), ast::Path::qualifier).last().unwrap()
|
||||
}
|
||||
|
||||
pub fn first_qualifier(&self) -> Option<ast::Path> {
|
||||
successors(self.qualifier(), ast::Path::qualifier).last()
|
||||
}
|
||||
|
||||
pub fn first_segment(&self) -> Option<ast::PathSegment> {
|
||||
self.first_qualifier_or_self().segment()
|
||||
}
|
||||
|
||||
// FIXME: Check usages of Self::segments, they might be wrong because of the logic of the bloew function
|
||||
pub fn segments_of_this_path_only_rev(&self) -> impl Iterator<Item = ast::PathSegment> + Clone {
|
||||
self.qualifiers_and_self().filter_map(|it| it.segment())
|
||||
}
|
||||
|
||||
pub fn segments(&self) -> impl Iterator<Item = ast::PathSegment> + Clone {
|
||||
successors(self.first_segment(), |p| {
|
||||
p.parent_path().parent_path().and_then(|p| p.segment())
|
||||
|
@ -289,6 +298,10 @@ impl ast::Path {
|
|||
successors(self.qualifier(), |p| p.qualifier())
|
||||
}
|
||||
|
||||
pub fn qualifiers_and_self(&self) -> impl Iterator<Item = ast::Path> + Clone {
|
||||
successors(Some(self.clone()), |p| p.qualifier())
|
||||
}
|
||||
|
||||
pub fn top_path(&self) -> ast::Path {
|
||||
let mut this = self.clone();
|
||||
while let Some(path) = this.parent_path() {
|
||||
|
|
|
@ -76,9 +76,6 @@ pub trait HasDocComments: HasAttrs {
|
|||
fn doc_comments(&self) -> DocCommentIter {
|
||||
DocCommentIter { iter: self.syntax().children_with_tokens() }
|
||||
}
|
||||
fn doc_comments_and_attrs(&self) -> AttrDocCommentIter {
|
||||
AttrDocCommentIter { iter: self.syntax().children_with_tokens() }
|
||||
}
|
||||
}
|
||||
|
||||
impl DocCommentIter {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue