From aa1a7a5414e59c7f1c6e74002df1b6a04937459e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 18 Aug 2020 16:41:21 +0200 Subject: Introduce Label --- crates/ide/src/diagnostics.rs | 13 ++++--------- crates/ide/src/lib.rs | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 1f85805d2..3c36c0e15 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -19,7 +19,7 @@ use syntax::{ }; use text_edit::TextEdit; -use crate::{FileId, SourceChange, SourceFileEdit}; +use crate::{FileId, Label, SourceChange, SourceFileEdit}; use self::fixes::DiagnosticWithFix; @@ -34,20 +34,15 @@ pub struct Diagnostic { #[derive(Debug)] pub struct Fix { - pub label: String, + pub label: Label, pub source_change: SourceChange, /// Allows to trigger the fix only when the caret is in the range given pub fix_trigger_range: TextRange, } impl Fix { - fn new( - label: impl Into, - source_change: SourceChange, - fix_trigger_range: TextRange, - ) -> Self { - let label = label.into(); - assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.')); + fn new(label: &str, source_change: SourceChange, fix_trigger_range: TextRange) -> Self { + let label = Label::new(label); Self { label, source_change, fix_trigger_range } } } diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index f37119e28..e3af6d5bc 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -88,6 +88,7 @@ pub use base_db::{ pub use hir::{Documentation, Semantics}; pub use ide_db::{ change::AnalysisChange, + label::Label, line_index::{LineCol, LineIndex}, search::SearchScope, source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, -- cgit v1.2.3