Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement with_label & with_note #363

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions codespan-reporting/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,24 @@ impl<FileId> Diagnostic<FileId> {
self
}

/// Add a label to the diagnostic.
pub fn with_label(mut self, label: Label<FileId>) -> Diagnostic<FileId> {
self.labels.push(label);
self
}

/// Add some labels to the diagnostic.
pub fn with_labels(mut self, mut labels: Vec<Label<FileId>>) -> Diagnostic<FileId> {
self.labels.append(&mut labels);
self
}

/// Add a note to the diagnostic.
pub fn with_note(mut self, note: impl ToString) -> Diagnostic<FileId> {
self.notes.push(note.to_string());
self
}

/// Add some notes to the diagnostic.
pub fn with_notes(mut self, mut notes: Vec<String>) -> Diagnostic<FileId> {
self.notes.append(&mut notes);
Expand Down