mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Introduce Label
This commit is contained in:
parent
eb81731600
commit
aa1a7a5414
8 changed files with 68 additions and 30 deletions
|
@ -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<String>,
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue