mirror of
https://github.com/denoland/deno.git
synced 2025-03-08 20:27:05 -05:00
validate range
This commit is contained in:
parent
714ed55473
commit
31473ca292
1 changed files with 12 additions and 8 deletions
|
@ -78,11 +78,14 @@ impl LintPluginContainer {
|
||||||
) {
|
) {
|
||||||
let source_text_info = self.source_text_info.as_ref().unwrap();
|
let source_text_info = self.source_text_info.as_ref().unwrap();
|
||||||
let specifier = self.specifier.clone().unwrap();
|
let specifier = self.specifier.clone().unwrap();
|
||||||
|
let source_range = source_text_info.range();
|
||||||
let start_pos = source_text_info.start_pos();
|
let start_pos = source_text_info.start_pos();
|
||||||
let source_range = SourceRange::new(start_pos + start, start_pos + end);
|
let diagnostic_range = SourceRange::new(start_pos + start, start_pos + end);
|
||||||
// TODO(bartlomieju): validate this is a correct range
|
if !source_range.contains(&diagnostic_range) {
|
||||||
|
todo!("Return op error that range is wrong");
|
||||||
|
}
|
||||||
let range = LintDiagnosticRange {
|
let range = LintDiagnosticRange {
|
||||||
range: source_range,
|
range: diagnostic_range,
|
||||||
description: None,
|
description: None,
|
||||||
text_info: source_text_info.clone(),
|
text_info: source_text_info.clone(),
|
||||||
};
|
};
|
||||||
|
@ -90,14 +93,15 @@ impl LintPluginContainer {
|
||||||
let mut fixes: Vec<LintFix> = vec![];
|
let mut fixes: Vec<LintFix> = vec![];
|
||||||
|
|
||||||
if let Some(fix) = fix {
|
if let Some(fix) = fix {
|
||||||
|
let fix_range =
|
||||||
|
SourceRange::new(start_pos + fix.range.0, start_pos + fix.range.1);
|
||||||
|
if !source_range.contains(&fix_range) {
|
||||||
|
todo!("Return op error that range is wrong");
|
||||||
|
}
|
||||||
fixes.push(LintFix {
|
fixes.push(LintFix {
|
||||||
changes: vec![LintFixChange {
|
changes: vec![LintFixChange {
|
||||||
new_text: fix.text.into(),
|
new_text: fix.text.into(),
|
||||||
// TODO(bartlomieju): validate this is a correct range
|
range: fix_range,
|
||||||
range: SourceRange::new(
|
|
||||||
start_pos + fix.range.0,
|
|
||||||
start_pos + fix.range.1,
|
|
||||||
),
|
|
||||||
}],
|
}],
|
||||||
description: format!("Fix this {} problem", id).into(),
|
description: format!("Fix this {} problem", id).into(),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue