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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl IsolatedLintHandler {

let mut messages: Vec<DiagnosticReport> = self
.runner
.run_source(&Arc::from(path.as_os_str()), source_text.to_string(), &fs)
.run_source(&Arc::from(path.as_os_str()), &fs)
.into_iter()
.map(|message| message_to_lsp_diagnostic(message, uri, source_text, rope))
.collect();
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_linter/src/lint_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,13 @@ impl LintRunner {
pub fn run_source(
&self,
file: &Arc<OsStr>,
source_text: String,
file_system: &(dyn crate::RuntimeFileSystem + Sync + Send),
) -> Vec<Message> {
let mut messages = self.lint_service.run_source(file_system, vec![Arc::clone(file)]);

if let Some(type_aware_linter) = &self.type_aware_linter {
let tsgo_messages =
match type_aware_linter.lint_source(file, source_text, self.directives_store.map())
match type_aware_linter.lint_source(file, file_system, self.directives_store.map())
{
Ok(msgs) => msgs,
Err(err) => {
Expand Down
15 changes: 12 additions & 3 deletions crates/oxc_linter/src/tsgolint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
sync::{Arc, Mutex},
};

use oxc_allocator::Allocator;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -320,12 +321,20 @@ impl TsGoLintState {
pub fn lint_source(
&self,
path: &Arc<OsStr>,
source_text: String,
file_system: &(dyn crate::RuntimeFileSystem + Sync + Send),
disable_directives_map: Arc<Mutex<FxHashMap<PathBuf, DisableDirectives>>>,
) -> Result<Vec<Message>, String> {
let mut resolved_configs: FxHashMap<PathBuf, ResolvedLinterState> = FxHashMap::default();
let mut source_overrides = FxHashMap::default();
source_overrides.insert(path.to_string_lossy().to_string(), source_text.clone());
let allocator = Allocator::default();
let Ok(source_text) = file_system.read_to_arena_str(Path::new(path.as_ref()), &allocator)
else {
return Err(format!("Failed to read source text for file: {}", path.to_string_lossy()));
};

// Clone source_text to own it for the spawned thread
let source_text_owned = source_text.to_string();
source_overrides.insert(path.to_string_lossy().to_string(), source_text_owned.clone());

let json_input = self.json_input(
std::slice::from_ref(path),
Expand Down Expand Up @@ -383,7 +392,7 @@ impl TsGoLintState {

let mut message = Message::from_tsgo_lint_diagnostic(
tsgolint_diagnostic,
&source_text,
&source_text_owned,
);

message.error.severity = if severity == AllowWarnDeny::Deny {
Expand Down
Loading