Skip to content

Commit

Permalink
Use range to iterate comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kaykdm committed Jan 6, 2024
1 parent 606c87f commit 25afca3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use oxc_diagnostics::{
thiserror::{self, Error},
};
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_span::{GetSpan, Span};
use regex::Regex;

use crate::{context::LintContext, rule::Rule};
Expand Down Expand Up @@ -133,8 +133,13 @@ impl Rule for TripleSlashReference {
}
}

let comments_range_end = match program.body.first() {
Some(v) => v.span().start,
None => program.span.end,
};

let comments = ctx.semantic().trivias().comments();
for (start, comment) in comments {
for (start, comment) in comments.range(0..comments_range_end) {
let raw = &ctx.semantic().source_text()[*start as usize..comment.end() as usize];
if let Some(captures) = REFERENCE_REGEX.captures(raw) {
let group1 = captures.get(1).map_or("", |m| m.as_str());
Expand Down

0 comments on commit 25afca3

Please sign in to comment.