aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libeditor/src/extend_selection.rs2
-rw-r--r--crates/libsyntax2/src/ast/mod.rs2
-rw-r--r--crates/libsyntax2/src/yellow/syntax.rs9
-rw-r--r--crates/libsyntax2/tests/test/main.rs2
4 files changed, 11 insertions, 4 deletions
diff --git a/crates/libeditor/src/extend_selection.rs b/crates/libeditor/src/extend_selection.rs
index cb6edb576..171e40692 100644
--- a/crates/libeditor/src/extend_selection.rs
+++ b/crates/libeditor/src/extend_selection.rs
@@ -6,7 +6,7 @@ use libsyntax2::{
6 6
7pub fn extend_selection(file: &ParsedFile, range: TextRange) -> Option<TextRange> { 7pub fn extend_selection(file: &ParsedFile, range: TextRange) -> Option<TextRange> {
8 let syntax = file.syntax(); 8 let syntax = file.syntax();
9 extend(syntax.as_ref(), range) 9 extend(syntax.borrowed(), range)
10} 10}
11 11
12pub(crate) fn extend(root: SyntaxNodeRef, range: TextRange) -> Option<TextRange> { 12pub(crate) fn extend(root: SyntaxNodeRef, range: TextRange) -> Option<TextRange> {
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs
index 46509b5ec..5b9a07db4 100644
--- a/crates/libsyntax2/src/ast/mod.rs
+++ b/crates/libsyntax2/src/ast/mod.rs
@@ -46,7 +46,7 @@ impl ParsedFile {
46 File::cast(self.syntax()).unwrap() 46 File::cast(self.syntax()).unwrap()
47 } 47 }
48 pub fn syntax(&self) -> SyntaxNodeRef { 48 pub fn syntax(&self) -> SyntaxNodeRef {
49 self.root.as_ref() 49 self.root.borrowed()
50 } 50 }
51 pub fn errors(&self) -> Vec<SyntaxError> { 51 pub fn errors(&self) -> Vec<SyntaxError> {
52 self.syntax().root.syntax_root().errors.clone() 52 self.syntax().root.syntax_root().errors.clone()
diff --git a/crates/libsyntax2/src/yellow/syntax.rs b/crates/libsyntax2/src/yellow/syntax.rs
index 87e4a159d..8f1b1d79a 100644
--- a/crates/libsyntax2/src/yellow/syntax.rs
+++ b/crates/libsyntax2/src/yellow/syntax.rs
@@ -51,13 +51,20 @@ impl SyntaxNode<OwnedRoot> {
51} 51}
52 52
53impl<R: TreeRoot> SyntaxNode<R> { 53impl<R: TreeRoot> SyntaxNode<R> {
54 pub fn as_ref<'a>(&'a self) -> SyntaxNode<RefRoot<'a>> { 54 pub fn borrowed<'a>(&'a self) -> SyntaxNodeRef<'a> {
55 SyntaxNode { 55 SyntaxNode {
56 root: self.root.borrowed(), 56 root: self.root.borrowed(),
57 red: self.red, 57 red: self.red,
58 } 58 }
59 } 59 }
60 60
61 pub fn owned<'a>(&'a self) -> SyntaxNode {
62 SyntaxNode {
63 root: self.root.owned(),
64 red: self.red,
65 }
66 }
67
61 pub fn kind(&self) -> SyntaxKind { 68 pub fn kind(&self) -> SyntaxKind {
62 self.red().green().kind() 69 self.red().green().kind()
63 } 70 }
diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs
index d35935c64..7e5dc32d9 100644
--- a/crates/libsyntax2/tests/test/main.rs
+++ b/crates/libsyntax2/tests/test/main.rs
@@ -21,7 +21,7 @@ fn lexer_tests() {
21fn parser_tests() { 21fn parser_tests() {
22 dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { 22 dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| {
23 let file = libsyntax2::parse(text); 23 let file = libsyntax2::parse(text);
24 libsyntax2::utils::dump_tree(file.as_ref()) 24 libsyntax2::utils::dump_tree(file.borrowed())
25 }) 25 })
26} 26}
27 27