aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-17 20:03:55 +0100
committerAleksey Kladov <[email protected]>2018-08-17 20:03:55 +0100
commitc7b1be6be345f97d6c4fd9ff3c51a94fb817fa56 (patch)
tree123b895ad8b2797b3b6ebcceebd36fb375ec7a38 /crates/libsyntax2
parentd3c90ded2b9a4f75e101fa3abc60cd3aebc439c9 (diff)
Owned
Diffstat (limited to 'crates/libsyntax2')
-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
3 files changed, 10 insertions, 3 deletions
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