From cdd75a699aaa9dbf971a8c6b0d59b36c5b6b49e6 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 22 Aug 2020 22:03:02 +0300 Subject: Omit lenses for not runnable doctests --- crates/syntax/src/algo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 6254b38ba..ea199f9b8 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -32,7 +32,7 @@ pub fn ancestors_at_offset( /// imprecise: if the cursor is strictly between two nodes of the desired type, /// as in /// -/// ```no-run +/// ```no_run /// struct Foo {}|struct Bar; /// ``` /// -- cgit v1.2.3 From 1d129a7172bbe502182be6cc3b50b3250cb6f3a9 Mon Sep 17 00:00:00 2001 From: dragfire Date: Sun, 23 Aug 2020 14:30:07 -0600 Subject: Invert if should be smart about is_some, is_none, is_ok, is_err --- crates/syntax/src/ast/make.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index d20c085aa..7958721e2 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -7,7 +7,7 @@ use itertools::Itertools; use stdx::format_to; -use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; +use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxText, SyntaxToken}; pub fn name(text: &str) -> ast::Name { ast_from_text(&format!("mod {};", text)) @@ -137,6 +137,12 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { expr_from_text(&format!("{}{}", f, arg_list)) } +pub fn expr_method_call(text: &str, caller: F) -> Option +where + F: FnOnce() -> Option, +{ + try_expr_from_text(&format!("{}.{}()", caller()?, text)) +} fn expr_from_text(text: &str) -> ast::Expr { ast_from_text(&format!("const C: () = {};", text)) } -- cgit v1.2.3 From a8fa5cd42e3cfa131121a46b289ee919e495316e Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Mon, 24 Aug 2020 10:25:19 +0200 Subject: Add version to deps in cargo.toml --- crates/syntax/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/syntax') diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 6818f3ad8..2c1bdb295 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -23,9 +23,9 @@ once_cell = "1.3.1" smol_str = { version = "0.1.15", features = ["serde"] } serde = { version = "1.0.106", features = ["derive"] } -stdx = { path = "../stdx" } -text_edit = { path = "../text_edit" } -parser = { path = "../parser" } +stdx = { path = "../stdx", version = "0.0.0" } +text_edit = { path = "../text_edit", version = "0.0.0" } +parser = { path = "../parser", version = "0.0.0" } [dev-dependencies] walkdir = "2.3.1" -- cgit v1.2.3 From f3ac19e8cd8be78f1eb96893482edac038739bb1 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 24 Aug 2020 22:02:55 +0200 Subject: Support extern types --- crates/syntax/src/ast/generated/nodes.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs index 6317407c6..d6af5755c 100644 --- a/crates/syntax/src/ast/generated/nodes.rs +++ b/crates/syntax/src/ast/generated/nodes.rs @@ -1380,6 +1380,7 @@ pub enum ExternItem { Fn(Fn), MacroCall(MacroCall), Static(Static), + TypeAlias(TypeAlias), } impl ast::AttrsOwner for ExternItem {} impl ast::NameOwner for ExternItem {} @@ -3339,10 +3340,13 @@ impl From for ExternItem { impl From for ExternItem { fn from(node: Static) -> ExternItem { ExternItem::Static(node) } } +impl From for ExternItem { + fn from(node: TypeAlias) -> ExternItem { ExternItem::TypeAlias(node) } +} impl AstNode for ExternItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN | MACRO_CALL | STATIC => true, + FN | MACRO_CALL | STATIC | TYPE_ALIAS => true, _ => false, } } @@ -3351,6 +3355,7 @@ impl AstNode for ExternItem { FN => ExternItem::Fn(Fn { syntax }), MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), STATIC => ExternItem::Static(Static { syntax }), + TYPE_ALIAS => ExternItem::TypeAlias(TypeAlias { syntax }), _ => return None, }; Some(res) @@ -3360,6 +3365,7 @@ impl AstNode for ExternItem { ExternItem::Fn(it) => &it.syntax, ExternItem::MacroCall(it) => &it.syntax, ExternItem::Static(it) => &it.syntax, + ExternItem::TypeAlias(it) => &it.syntax, } } } -- cgit v1.2.3