Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/oxc_language_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ oxc_diagnostics = { workspace = true }
oxc_formatter = { workspace = true }
oxc_linter = { workspace = true, features = ["language_server"] }
oxc_parser = { workspace = true }
oxc_span = { workspace = true }

#
env_logger = { workspace = true, features = ["humantime"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use tower_lsp_server::lsp_types::{
use oxc_data_structures::rope::{Rope, get_line_column};
use oxc_diagnostics::{OxcCode, Severity};
use oxc_linter::{Fix, Message, PossibleFixes};
use oxc_span::GetSpan;

#[derive(Debug, Clone, Default)]
pub struct DiagnosticReport {
Expand Down Expand Up @@ -67,8 +66,8 @@ pub fn message_to_lsp_diagnostic(
.collect()
});

let start_position = offset_to_position(rope, message.span().start, source_text);
let end_position = offset_to_position(rope, message.span().end, source_text);
let start_position = offset_to_position(rope, message.span.start, source_text);
let end_position = offset_to_position(rope, message.span.end, source_text);
let range = Range::new(start_position, end_position);

let code = message.error.code.to_string();
Expand Down Expand Up @@ -114,13 +113,13 @@ pub fn message_to_lsp_diagnostic(
};

// Add ignore fixes
let error_offset = message.span().start;
let error_offset = message.span.start;
let section_offset = message.section_offset;

// If the error is exactly at the section offset and has 0 span length, it means that the file is the problem
// and attaching a ignore comment would not ignore the error.
// This is because the ignore comment would need to be placed before the error offset, which is not possible.
if error_offset == section_offset && message.span().end == section_offset {
if error_offset == section_offset && message.span.end == section_offset {
return DiagnosticReport { diagnostic, fixed_content };
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use oxc_ast::ast::IdentifierReference;
use oxc_cfg::ControlFlowGraph;
use oxc_diagnostics::{OxcDiagnostic, Severity};
use oxc_semantic::Semantic;
use oxc_span::{GetSpan, Span};
use oxc_span::Span;

#[cfg(debug_assertions)]
use crate::rule::RuleFixMeta;
Expand Down Expand Up @@ -223,7 +223,7 @@ impl<'a> LintContext<'a> {
/// Add a diagnostic message to the list of diagnostics. Outputs a diagnostic with the current rule
/// name, severity, and a link to the rule's documentation URL.
fn add_diagnostic(&self, mut message: Message) {
if self.parent.disable_directives().contains(self.current_rule_name, message.span()) {
if self.parent.disable_directives().contains(self.current_rule_name, message.span) {
return;
}
message.error = message
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/fixer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub struct FixResult<'a> {
pub struct Message {
pub error: OxcDiagnostic,
pub fixes: PossibleFixes,
span: Span,
pub span: Span,
fixed: bool,
#[cfg(feature = "language_server")]
pub section_offset: u32,
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/tsgolint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ pub fn try_find_tsgolint_executable(cwd: &Path) -> Result<PathBuf, String> {
#[cfg(feature = "language_server")]
mod test {
use oxc_diagnostics::{LabeledSpan, OxcCode, Severity};
use oxc_span::{GetSpan, Span};
use oxc_span::Span;

use crate::{
fixer::{Message, PossibleFixes},
Expand All @@ -881,7 +881,7 @@ mod test {

assert_eq!(message.error.message, "Some description");
assert_eq!(message.error.severity, Severity::Warning);
assert_eq!(message.span(), Span::new(0, 10));
assert_eq!(message.span, Span::new(0, 10));
assert_eq!(
message.error.code,
OxcCode { scope: Some("typescript-eslint".into()), number: Some("some_rule".into()) }
Expand Down
Loading