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
23 changes: 23 additions & 0 deletions crates/oxc_language_server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use rustc_hash::FxBuildHasher;

mod backend;
mod capabilities;
mod code_actions;
mod commands;
mod file_system;
mod formatter;
mod linter;
mod options;
#[cfg(test)]
mod tester;
mod utils;
mod worker;

pub use crate::backend::Backend;
pub use crate::linter::server_linter::ServerLinter;
pub use crate::worker::WorkspaceWorker;

pub type ConcurrentHashMap<K, V> = papaya::HashMap<K, V, FxBuildHasher>;

pub const LINT_CONFIG_FILE: &str = ".oxlintrc.json";
pub const FORMAT_CONFIG_FILES: &[&str; 2] = &[".oxfmtrc.json", ".oxfmtrc.jsonc"];
2 changes: 2 additions & 0 deletions crates/oxc_language_server/src/linter/server_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ impl ServerLinterDiagnostics {
}

impl ServerLinter {
/// # Panics
/// Panics if the root URI cannot be converted to a file path.
pub fn new(root_uri: &Uri, options: &LSPLintOptions) -> Self {
let root_path = root_uri.to_file_path().unwrap();
let mut nested_ignore_patterns = Vec::new();
Expand Down
22 changes: 1 addition & 21 deletions crates/oxc_language_server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
use rustc_hash::FxBuildHasher;
use oxc_language_server::Backend;
use tower_lsp_server::{LspService, Server};

mod backend;
mod capabilities;
mod code_actions;
mod commands;
mod file_system;
mod formatter;
mod linter;
mod options;
#[cfg(test)]
mod tester;
mod utils;
mod worker;

use crate::backend::Backend;

type ConcurrentHashMap<K, V> = papaya::HashMap<K, V, FxBuildHasher>;

const LINT_CONFIG_FILE: &str = ".oxlintrc.json";
const FORMAT_CONFIG_FILES: &[&str; 2] = &[".oxfmtrc.json", ".oxfmtrc.jsonc"];

#[tokio::main]
async fn main() {
env_logger::init();
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_language_server/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ impl WorkspaceWorker {
/// e.g. root URI: file:///path/to/root
/// responsible for: file:///path/to/root/file.js
/// not responsible for: file:///path/to/other/file.js
///
/// # Panics
/// Panics if the root URI cannot be converted to a file path.
pub fn is_responsible_for_uri(&self, uri: &Uri) -> bool {
if let Some(path) = uri.to_file_path() {
return path.starts_with(self.root_uri.to_file_path().unwrap());
Expand Down Expand Up @@ -336,6 +339,9 @@ impl WorkspaceWorker {
}

/// Handle server configuration changes from the client
///
/// # Panics
/// Panics if the root URI cannot be converted to a file path.
pub async fn did_change_configuration(
&self,
changed_options: &Options,
Expand Down
Loading