From 533f178a524dabe6c56ee533966f2a2be1a4104b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 10 Mar 2022 17:07:11 +0100 Subject: [PATCH] minor: Access parser internals through ide_db for ide crates --- Cargo.lock | 1 - crates/ide_assists/Cargo.toml | 1 - crates/ide_assists/src/handlers/extract_module.rs | 5 +++-- crates/ide_assists/src/utils/suggest_name.rs | 2 +- crates/ide_db/src/lib.rs | 2 ++ 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1b559f405..5dfc14e8b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,6 @@ dependencies = [ "hir", "ide_db", "itertools", - "parser", "profile", "rustc-hash", "sourcegen", diff --git a/crates/ide_assists/Cargo.toml b/crates/ide_assists/Cargo.toml index 878c556d77..09242e0aaf 100644 --- a/crates/ide_assists/Cargo.toml +++ b/crates/ide_assists/Cargo.toml @@ -16,7 +16,6 @@ itertools = "0.10.0" either = "1.6.1" stdx = { path = "../stdx", version = "0.0.0" } -parser = { path = "../parser", version = "0.0.0" } syntax = { path = "../syntax", version = "0.0.0" } text_edit = { path = "../text_edit", version = "0.0.0" } profile = { path = "../profile", version = "0.0.0" } diff --git a/crates/ide_assists/src/handlers/extract_module.rs b/crates/ide_assists/src/handlers/extract_module.rs index 08bfd10dc7..9e1481b2f6 100644 --- a/crates/ide_assists/src/handlers/extract_module.rs +++ b/crates/ide_assists/src/handlers/extract_module.rs @@ -7,7 +7,6 @@ use ide_db::{ defs::{Definition, NameClass, NameRefClass}, search::{FileReference, SearchScope}, }; -use parser::SyntaxKind::WHITESPACE; use stdx::format_to; use syntax::{ algo::find_node_at_range, @@ -16,7 +15,9 @@ use syntax::{ edit::{AstNodeEdit, IndentLevel}, make, HasName, HasVisibility, }, - match_ast, ted, AstNode, SourceFile, SyntaxNode, TextRange, + match_ast, ted, AstNode, SourceFile, + SyntaxKind::WHITESPACE, + SyntaxNode, TextRange, }; use crate::{AssistContext, Assists}; diff --git a/crates/ide_assists/src/utils/suggest_name.rs b/crates/ide_assists/src/utils/suggest_name.rs index f91b2fe44e..5b79a7495f 100644 --- a/crates/ide_assists/src/utils/suggest_name.rs +++ b/crates/ide_assists/src/utils/suggest_name.rs @@ -135,7 +135,7 @@ fn normalize(name: &str) -> Option { } fn is_valid_name(name: &str) -> bool { - match parser::LexedStr::single_token(name) { + match ide_db::syntax_helpers::LexedStr::single_token(name) { Some((syntax::SyntaxKind::IDENT, _error)) => true, _ => false, } diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs index b11b70d127..5abeb88837 100644 --- a/crates/ide_db/src/lib.rs +++ b/crates/ide_db/src/lib.rs @@ -35,6 +35,8 @@ pub mod syntax_helpers { pub mod node_ext; pub mod insert_whitespace_into_node; pub mod format_string; + + pub use parser::LexedStr; } use std::{fmt, mem::ManuallyDrop, sync::Arc};