Skip to content

Commit 157f993

Browse files
committed
refactor(linter): make Message.span public
1 parent 1c7fb41 commit 157f993

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_language_server/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ oxc_diagnostics = { workspace = true }
2828
oxc_formatter = { workspace = true }
2929
oxc_linter = { workspace = true, features = ["language_server"] }
3030
oxc_parser = { workspace = true }
31-
oxc_span = { workspace = true }
3231

3332
#
3433
env_logger = { workspace = true, features = ["humantime"] }

crates/oxc_language_server/src/linter/error_with_position.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use tower_lsp_server::lsp_types::{
88
use oxc_data_structures::rope::{Rope, get_line_column};
99
use oxc_diagnostics::{OxcCode, Severity};
1010
use oxc_linter::{Fix, Message, PossibleFixes};
11-
use oxc_span::GetSpan;
1211

1312
#[derive(Debug, Clone, Default)]
1413
pub struct DiagnosticReport {
@@ -67,8 +66,8 @@ pub fn message_to_lsp_diagnostic(
6766
.collect()
6867
});
6968

70-
let start_position = offset_to_position(rope, message.span().start, source_text);
71-
let end_position = offset_to_position(rope, message.span().end, source_text);
69+
let start_position = offset_to_position(rope, message.span.start, source_text);
70+
let end_position = offset_to_position(rope, message.span.end, source_text);
7271
let range = Range::new(start_position, end_position);
7372

7473
let code = message.error.code.to_string();
@@ -114,7 +113,7 @@ pub fn message_to_lsp_diagnostic(
114113
};
115114

116115
// Add ignore fixes
117-
let error_offset = message.span().start;
116+
let error_offset = message.span.start;
118117
let section_offset = message.section_offset;
119118
let fixed_content = add_ignore_fixes(
120119
fixed_content,

crates/oxc_linter/src/context/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use oxc_ast::ast::IdentifierReference;
88
use oxc_cfg::ControlFlowGraph;
99
use oxc_diagnostics::{OxcDiagnostic, Severity};
1010
use oxc_semantic::Semantic;
11-
use oxc_span::{GetSpan, Span};
11+
use oxc_span::Span;
1212

1313
#[cfg(debug_assertions)]
1414
use crate::rule::RuleFixMeta;
@@ -223,7 +223,7 @@ impl<'a> LintContext<'a> {
223223
/// Add a diagnostic message to the list of diagnostics. Outputs a diagnostic with the current rule
224224
/// name, severity, and a link to the rule's documentation URL.
225225
fn add_diagnostic(&self, mut message: Message) {
226-
if self.parent.disable_directives().contains(self.current_rule_name, message.span()) {
226+
if self.parent.disable_directives().contains(self.current_rule_name, message.span) {
227227
return;
228228
}
229229
message.error = message

crates/oxc_linter/src/fixer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub struct FixResult<'a> {
221221
pub struct Message {
222222
pub error: OxcDiagnostic,
223223
pub fixes: PossibleFixes,
224-
span: Span,
224+
pub span: Span,
225225
fixed: bool,
226226
#[cfg(feature = "language_server")]
227227
pub section_offset: u32,

crates/oxc_linter/src/tsgolint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ pub fn try_find_tsgolint_executable(cwd: &Path) -> Result<PathBuf, String> {
855855
#[cfg(feature = "language_server")]
856856
mod test {
857857
use oxc_diagnostics::{LabeledSpan, OxcCode, Severity};
858-
use oxc_span::{GetSpan, Span};
858+
use oxc_span::Span;
859859

860860
use crate::{
861861
fixer::{Message, PossibleFixes},
@@ -881,7 +881,7 @@ mod test {
881881

882882
assert_eq!(message.error.message, "Some description");
883883
assert_eq!(message.error.severity, Severity::Warning);
884-
assert_eq!(message.span(), Span::new(0, 10));
884+
assert_eq!(message.span, Span::new(0, 10));
885885
assert_eq!(
886886
message.error.code,
887887
OxcCode { scope: Some("typescript-eslint".into()), number: Some("some_rule".into()) }

0 commit comments

Comments
 (0)