aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r--crates/ra_hir/src/path.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 8279daf4b..4a2e427cd 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -1,13 +1,13 @@
1use ra_syntax::{SmolStr, ast, AstNode, TextRange}; 1use ra_syntax::{SmolStr, ast, AstNode, TextRange};
2 2
3#[derive(Debug, Clone, PartialEq, Eq)] 3#[derive(Debug, Clone, PartialEq, Eq)]
4pub(crate) struct Path { 4pub struct Path {
5 pub(crate) kind: PathKind, 5 pub kind: PathKind,
6 pub(crate) segments: Vec<SmolStr>, 6 pub segments: Vec<SmolStr>,
7} 7}
8 8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)] 9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub(crate) enum PathKind { 10pub enum PathKind {
11 Plain, 11 Plain,
12 Self_, 12 Self_,
13 Super, 13 Super,
@@ -16,14 +16,14 @@ pub(crate) enum PathKind {
16 16
17impl Path { 17impl Path {
18 /// Calls `cb` with all paths, represented by this use item. 18 /// Calls `cb` with all paths, represented by this use item.
19 pub(crate) fn expand_use_item(item: ast::UseItem, mut cb: impl FnMut(Path, Option<TextRange>)) { 19 pub fn expand_use_item(item: ast::UseItem, mut cb: impl FnMut(Path, Option<TextRange>)) {
20 if let Some(tree) = item.use_tree() { 20 if let Some(tree) = item.use_tree() {
21 expand_use_tree(None, tree, &mut cb); 21 expand_use_tree(None, tree, &mut cb);
22 } 22 }
23 } 23 }
24 24
25 /// Converts an `ast::Path` to `Path`. Works with use trees. 25 /// Converts an `ast::Path` to `Path`. Works with use trees.
26 pub(crate) fn from_ast(mut path: ast::Path) -> Option<Path> { 26 pub fn from_ast(mut path: ast::Path) -> Option<Path> {
27 let mut kind = PathKind::Plain; 27 let mut kind = PathKind::Plain;
28 let mut segments = Vec::new(); 28 let mut segments = Vec::new();
29 loop { 29 loop {
@@ -64,7 +64,7 @@ impl Path {
64 } 64 }
65 65
66 /// `true` is this path is a single identifier, like `foo` 66 /// `true` is this path is a single identifier, like `foo`
67 pub(crate) fn is_ident(&self) -> bool { 67 pub fn is_ident(&self) -> bool {
68 self.kind == PathKind::Plain && self.segments.len() == 1 68 self.kind == PathKind::Plain && self.segments.len() == 1
69 } 69 }
70} 70}