diff --git a/crates/pglt_analyse/src/categories.rs b/crates/pglt_analyse/src/categories.rs index 184205a7b..71261caf4 100644 --- a/crates/pglt_analyse/src/categories.rs +++ b/crates/pglt_analyse/src/categories.rs @@ -74,38 +74,34 @@ impl ActionCategory { match self { ActionCategory::QuickFix(tag) => { if tag.is_empty() { - Cow::Borrowed("quickfix.pglsp") + Cow::Borrowed("quickfix.pglt") } else { - Cow::Owned(format!("quickfix.pglsp.{tag}")) + Cow::Owned(format!("quickfix.pglt.{tag}")) } } - ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pglsp"), + ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pglt"), ActionCategory::Refactor(RefactorKind::Extract) => { - Cow::Borrowed("refactor.extract.pglsp") - } - ActionCategory::Refactor(RefactorKind::Inline) => { - Cow::Borrowed("refactor.inline.pglsp") + Cow::Borrowed("refactor.extract.pglt") } + ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.pglt"), ActionCategory::Refactor(RefactorKind::Rewrite) => { - Cow::Borrowed("refactor.rewrite.pglsp") + Cow::Borrowed("refactor.rewrite.pglt") } ActionCategory::Refactor(RefactorKind::Other(tag)) => { - Cow::Owned(format!("refactor.{tag}.pglsp")) + Cow::Owned(format!("refactor.{tag}.pglt")) } - ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pglsp"), - ActionCategory::Source(SourceActionKind::FixAll) => { - Cow::Borrowed("source.fixAll.pglsp") - } + ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pglt"), + ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.pglt"), ActionCategory::Source(SourceActionKind::OrganizeImports) => { - Cow::Borrowed("source.organizeImports.pglsp") + Cow::Borrowed("source.organizeImports.pglt") } ActionCategory::Source(SourceActionKind::Other(tag)) => { - Cow::Owned(format!("source.{tag}.pglsp")) + Cow::Owned(format!("source.{tag}.pglt")) } - ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pglsp")), + ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pglt")), } } } diff --git a/crates/pglt_analyse/src/options.rs b/crates/pglt_analyse/src/options.rs index eaba5d37a..20ac7236f 100644 --- a/crates/pglt_analyse/src/options.rs +++ b/crates/pglt_analyse/src/options.rs @@ -45,7 +45,7 @@ impl AnalyserRules { /// A set of information useful to the analyser infrastructure #[derive(Debug, Default)] pub struct AnalyserOptions { - /// A data structured derived from the [`pglsp.toml`] file + /// A data structured derived from the [`pglt.toml`] file pub rules: AnalyserRules, } diff --git a/crates/pglt_analyser/CONTRIBUTING.md b/crates/pglt_analyser/CONTRIBUTING.md index 88f6f2873..c855ac592 100644 --- a/crates/pglt_analyser/CONTRIBUTING.md +++ b/crates/pglt_analyser/CONTRIBUTING.md @@ -79,7 +79,7 @@ Let's assume that the rule we implement support the following options: - `threshold`: an integer between 0 and 255; - `behaviorExceptions`: an array of strings. -We would like to set the options in the `pglsp.toml` configuration file: +We would like to set the options in the `pglt.toml` configuration file: ```toml [linter.rules.safety.myRule] @@ -132,9 +132,9 @@ We currently require implementing _serde_'s traits `Deserialize`/`Serialize`. Also, we use other `serde` macros to adjust the JSON configuration: -- `rename_all = "snake_case"`: it renames all fields in camel-case, so they are in line with the naming style of the `pglsp.toml`. +- `rename_all = "snake_case"`: it renames all fields in camel-case, so they are in line with the naming style of the `pglt.toml`. - `deny_unknown_fields`: it raises an error if the configuration contains extraneous fields. -- `default`: it uses the `Default` value when the field is missing from `pglsp.toml`. This macro makes the field optional. +- `default`: it uses the `Default` value when the field is missing from `pglt.toml`. This macro makes the field optional. You can simply use a derive macros: diff --git a/crates/pglt_base_db/src/change.rs b/crates/pglt_base_db/src/change.rs index 770af5e5d..689aa263c 100644 --- a/crates/pglt_base_db/src/change.rs +++ b/crates/pglt_base_db/src/change.rs @@ -292,13 +292,13 @@ mod tests { use text_size::{TextRange, TextSize}; use crate::{change::Change, document::StatementRef, Document, DocumentChange}; - use pglt_fs::PgLspPath; + use pglt_fs::PgLTPath; #[test] fn test_document_apply_changes() { let input = "select id from users;\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), Some(input.to_string())); + let mut d = Document::new(PgLTPath::new("test.sql"), Some(input.to_string())); assert_eq!(d.statement_ranges.len(), 2); @@ -317,7 +317,7 @@ mod tests { assert_eq!( changed[0].statement().to_owned(), StatementRef { - document_url: PgLspPath::new("test.sql"), + document_url: PgLTPath::new("test.sql"), text: "select id from users;".to_string(), idx: 0 } @@ -325,7 +325,7 @@ mod tests { assert_eq!( changed[1].statement().to_owned(), StatementRef { - document_url: PgLspPath::new("test.sql"), + document_url: PgLTPath::new("test.sql"), text: "select * from contacts;".to_string(), idx: 1 } @@ -350,7 +350,7 @@ mod tests { fn test_document_apply_changes_at_end_of_statement() { let input = "select id from\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), Some(input.to_string())); + let mut d = Document::new(PgLTPath::new("test.sql"), Some(input.to_string())); assert_eq!(d.statement_ranges.len(), 2); @@ -393,7 +393,7 @@ mod tests { #[test] fn test_document_apply_changes_replacement() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let mut doc = Document::new(path, None); @@ -508,7 +508,7 @@ mod tests { fn test_document_apply_changes_within_statement() { let input = "select id from users;\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), Some(input.to_string())); + let mut d = Document::new(PgLTPath::new("test.sql"), Some(input.to_string())); assert_eq!(d.statement_ranges.len(), 2); diff --git a/crates/pglt_base_db/src/document.rs b/crates/pglt_base_db/src/document.rs index 4446b6f37..2610dc049 100644 --- a/crates/pglt_base_db/src/document.rs +++ b/crates/pglt_base_db/src/document.rs @@ -3,14 +3,14 @@ use std::{hash::Hash, hash::Hasher, ops::RangeBounds}; use line_index::LineIndex; use text_size::{TextRange, TextSize}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; extern crate test; /// Represents a sql source file, and contains a list of statements represented by their ranges pub struct Document { /// The url of the document - pub url: PgLspPath, + pub url: PgLTPath, /// The text of the document pub text: String, /// The version of the document @@ -33,7 +33,7 @@ impl Hash for Document { /// Note that the ref must include all information needed to uniquely identify the statement, so that it can be used as a key in a hashmap. #[derive(Debug, Hash, PartialEq, Eq, Clone)] pub struct StatementRef { - pub document_url: PgLspPath, + pub document_url: PgLTPath, // TODO use string interner for text pub text: String, pub idx: usize, @@ -41,7 +41,7 @@ pub struct StatementRef { impl Document { /// Create a new document - pub fn new(url: PgLspPath, text: Option) -> Document { + pub fn new(url: PgLTPath, text: Option) -> Document { Document { version: 0, line_index: LineIndex::new(text.as_ref().unwrap_or(&"".to_string())), @@ -162,14 +162,14 @@ impl Document { #[cfg(test)] mod tests { - use pglt_fs::PgLspPath; + use pglt_fs::PgLTPath; use text_size::{TextRange, TextSize}; use crate::Document; #[test] fn test_statements_at_range() { - let url = PgLspPath::new("test.sql"); + let url = PgLTPath::new("test.sql"); let doc = Document::new( url, diff --git a/crates/pglt_cli/src/cli_options.rs b/crates/pglt_cli/src/cli_options.rs index 05e75b6a5..c49f6f798 100644 --- a/crates/pglt_cli/src/cli_options.rs +++ b/crates/pglt_cli/src/cli_options.rs @@ -26,7 +26,7 @@ pub struct CliOptions { #[bpaf(long("verbose"), switch, fallback(false))] pub verbose: bool, - /// Set the file path to the configuration file, or the directory path to find `pglsp.toml`. + /// Set the file path to the configuration file, or the directory path to find `pglt.toml`. /// If used, it disables the default configuration file resolution. #[bpaf(long("config-path"), argument("PATH"), optional)] pub config_path: Option, diff --git a/crates/pglt_cli/src/commands/clean.rs b/crates/pglt_cli/src/commands/clean.rs index 1bf2c3070..c01ab826b 100644 --- a/crates/pglt_cli/src/commands/clean.rs +++ b/crates/pglt_cli/src/commands/clean.rs @@ -1,15 +1,15 @@ -use crate::commands::daemon::default_pglsp_log_path; +use crate::commands::daemon::default_pglt_log_path; use crate::{CliDiagnostic, CliSession}; -use pglt_flags::pglsp_env; +use pglt_flags::pglt_env; use std::fs::{create_dir, remove_dir_all}; use std::path::PathBuf; /// Runs the clean command pub fn clean(_cli_session: CliSession) -> Result<(), CliDiagnostic> { - let logs_path = pglsp_env() - .pglsp_log_path + let logs_path = pglt_env() + .pglt_log_path .value() - .map_or(default_pglsp_log_path(), PathBuf::from); + .map_or(default_pglt_log_path(), PathBuf::from); remove_dir_all(logs_path.clone()).and_then(|_| create_dir(logs_path))?; Ok(()) } diff --git a/crates/pglt_cli/src/commands/daemon.rs b/crates/pglt_cli/src/commands/daemon.rs index 046afd769..43f96ddcf 100644 --- a/crates/pglt_cli/src/commands/daemon.rs +++ b/crates/pglt_cli/src/commands/daemon.rs @@ -176,9 +176,9 @@ pub(crate) fn read_most_recent_log_file( log_path: Option, log_file_name_prefix: String, ) -> io::Result> { - let pglsp_log_path = log_path.unwrap_or(default_pglsp_log_path()); + let pglt_log_path = log_path.unwrap_or(default_pglt_log_path()); - let most_recent = fs::read_dir(pglsp_log_path)? + let most_recent = fs::read_dir(pglt_log_path)? .flatten() .filter(|file| file.file_type().is_ok_and(|ty| ty.is_file())) .filter_map(|file| { @@ -203,16 +203,16 @@ pub(crate) fn read_most_recent_log_file( /// The events received by the subscriber are filtered at the `info` level, /// then printed using the [HierarchicalLayer] layer, and the resulting text /// is written to log files rotated on a hourly basis (in -/// `pglsp-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary +/// `pglt-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary /// directory) fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Option) { - let pglsp_log_path = log_path.unwrap_or(pglt_fs::ensure_cache_dir().join("pglsp-logs")); + let pglt_log_path = log_path.unwrap_or(pglt_fs::ensure_cache_dir().join("pglt-logs")); let appender_builder = tracing_appender::rolling::RollingFileAppender::builder(); let file_appender = appender_builder .filename_prefix(log_file_name_prefix.unwrap_or(String::from("server.log"))) .max_log_files(7) .rotation(Rotation::HOURLY) - .build(pglsp_log_path) + .build(pglt_log_path) .expect("Failed to start the logger for the daemon."); registry() @@ -229,19 +229,19 @@ fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Opt .init(); } -pub fn default_pglsp_log_path() -> PathBuf { +pub fn default_pglt_log_path() -> PathBuf { match env::var_os("PGLSP_LOG_PATH") { Some(directory) => PathBuf::from(directory), - None => pglt_fs::ensure_cache_dir().join("pglsp-logs"), + None => pglt_fs::ensure_cache_dir().join("pglt-logs"), } } /// Tracing filter enabling: /// - All spans and events at level info or higher -/// - All spans and events at level debug in crates whose name starts with `pglsp` +/// - All spans and events at level debug in crates whose name starts with `pglt` struct LoggingFilter; -/// Tracing filter used for spans emitted by `pglsp*` crates +/// Tracing filter used for spans emitted by `pglt*` crates const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { LevelFilter::TRACE } else { @@ -250,7 +250,7 @@ const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { impl LoggingFilter { fn is_enabled(&self, meta: &Metadata<'_>) -> bool { - let filter = if meta.target().starts_with("pglsp") { + let filter = if meta.target().starts_with("pglt") { SELF_FILTER } else { LevelFilter::INFO diff --git a/crates/pglt_cli/src/commands/init.rs b/crates/pglt_cli/src/commands/init.rs index fceaa0683..d25c5292b 100644 --- a/crates/pglt_cli/src/commands/init.rs +++ b/crates/pglt_cli/src/commands/init.rs @@ -7,7 +7,7 @@ use pglt_workspace::configuration::create_config; pub(crate) fn init(mut session: CliSession) -> Result<(), CliDiagnostic> { let fs = &mut session.app.fs; create_config(fs, PartialConfiguration::init())?; - let file_created = ConfigName::pglsp_toml(); + let file_created = ConfigName::pglt_toml(); session.app.console.log(markup! { " Welcome to the Postgres Language Server! Let's get you started... diff --git a/crates/pglt_cli/src/commands/mod.rs b/crates/pglt_cli/src/commands/mod.rs index c9f5c67fd..db8f53c31 100644 --- a/crates/pglt_cli/src/commands/mod.rs +++ b/crates/pglt_cli/src/commands/mod.rs @@ -24,7 +24,7 @@ pub(crate) mod version; #[derive(Debug, Clone, Bpaf)] #[bpaf(options, version(VERSION))] -/// PgLsp official CLI. Use it to check the health of your project or run it to check single files. +/// PgLT official CLI. Use it to check the health of your project or run it to check single files. pub enum PgltCommand { /// Shows the version information and quit. #[bpaf(command)] @@ -58,7 +58,7 @@ pub enum PgltCommand { changed: bool, /// Use this to specify the base branch to compare against when you're using the --changed - /// flag and the `defaultBranch` is not set in your `pglsp.toml` + /// flag and the `defaultBranch` is not set in your `pglt.toml` #[bpaf(long("since"), argument("REF"))] since: Option, @@ -87,11 +87,11 @@ pub enum PgltCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglt-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `pglsp.toml` + /// or a custom directory path to find `pglt.toml` #[bpaf(env("PGLSP_LOG_PREFIX_NAME"), long("config-path"), argument("PATH"))] config_path: Option, }, @@ -123,11 +123,11 @@ pub enum PgltCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglt-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `pglsp.toml` + /// or a custom directory path to find `pglt.toml` #[bpaf(env("PGLSP_CONFIG_PATH"), long("config-path"), argument("PATH"))] config_path: Option, /// Bogus argument to make the command work with vscode-languageclient @@ -157,14 +157,14 @@ pub enum PgltCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglt-logs")), )] log_path: PathBuf, #[bpaf(long("stop-on-disconnect"), hide_usage)] stop_on_disconnect: bool, /// Allows to set a custom file path to the configuration file, - /// or a custom directory path to find `pglsp.toml` + /// or a custom directory path to find `pglt.toml` #[bpaf(env("PGLSP_CONFIG_PATH"), long("config-path"), argument("PATH"))] config_path: Option, }, @@ -197,7 +197,7 @@ impl PgltCommand { } // We want force colors in CI, to give e better UX experience // Unless users explicitly set the colors flag - // if matches!(self, PgLspCommand::Ci { .. }) && cli_options.colors.is_none() { + // if matches!(self, PgLTCommand::Ci { .. }) && cli_options.colors.is_none() { // return Some(&ColorsArg::Force); // } // Normal behaviors diff --git a/crates/pglt_cli/src/diagnostics.rs b/crates/pglt_cli/src/diagnostics.rs index f13e0e81c..fa9b7ed2d 100644 --- a/crates/pglt_cli/src/diagnostics.rs +++ b/crates/pglt_cli/src/diagnostics.rs @@ -12,7 +12,7 @@ fn command_name() -> String { current_exe() .ok() .and_then(|path| Some(path.file_name()?.to_str()?.to_string())) - .unwrap_or_else(|| String::from("pglsp")) + .unwrap_or_else(|| String::from("pglt")) } /// A diagnostic that is emitted when running PGLSP via CLI. @@ -42,13 +42,13 @@ pub enum CliDiagnostic { FileCheck(FileCheck), /// When an argument is higher than the expected maximum OverflowNumberArgument(OverflowNumberArgument), - /// Wrapper for an underlying pglsp-service error + /// Wrapper for an underlying pglt-service error WorkspaceError(WorkspaceError), /// Wrapper for an underlying `std::io` error IoError(IoDiagnostic), /// The daemon is not running ServerNotRunning(ServerNotRunning), - /// The end configuration (`pglsp.toml` + other options) is incompatible with the command + /// The end configuration (`pglt.toml` + other options) is incompatible with the command IncompatibleEndConfiguration(IncompatibleEndConfiguration), /// No files processed during the file system traversal NoFilesWereProcessed(NoFilesWereProcessed), @@ -410,7 +410,7 @@ impl CliDiagnostic { Self::ServerNotRunning(ServerNotRunning) } - /// Emitted when the end configuration (`pglsp.toml` file + CLI arguments + LSP configuration) + /// Emitted when the end configuration (`pglt.toml` file + CLI arguments + LSP configuration) /// results in a combination of options that doesn't allow to run the command correctly. /// /// A reason needs to be provided diff --git a/crates/pglt_cli/src/execute/mod.rs b/crates/pglt_cli/src/execute/mod.rs index 266686820..b91fd6320 100644 --- a/crates/pglt_cli/src/execute/mod.rs +++ b/crates/pglt_cli/src/execute/mod.rs @@ -11,7 +11,7 @@ use crate::reporter::junit::{JunitReporter, JunitReporterVisitor}; use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor}; use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter}; use pglt_diagnostics::{category, Category}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use std::borrow::Borrow; use std::ffi::OsString; use std::fmt::{Display, Formatter}; @@ -229,11 +229,11 @@ pub fn execute_mode( // don't do any traversal if there's some content coming from stdin if let Some(stdin) = execution.as_stdin_file() { - let pglsp_path = PgLspPath::new(stdin.as_path()); + let pglt_path = PgLTPath::new(stdin.as_path()); std_in::run( session, &execution, - pglsp_path, + pglt_path, stdin.as_content(), cli_options.verbose, ) diff --git a/crates/pglt_cli/src/execute/process_file.rs b/crates/pglt_cli/src/execute/process_file.rs index 35044fb94..e4f7c92e6 100644 --- a/crates/pglt_cli/src/execute/process_file.rs +++ b/crates/pglt_cli/src/execute/process_file.rs @@ -5,7 +5,7 @@ use crate::execute::traverse::TraversalOptions; use crate::execute::TraversalMode; use check::check_file; use pglt_diagnostics::Error; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use std::marker::PhantomData; use std::ops::Deref; @@ -111,15 +111,15 @@ impl<'ctx, 'app> Deref for SharedTraversalOptions<'ctx, 'app> { /// diagnostics were emitted, or compare the formatted code with the original /// content of the file and emit a diff or write the new content to the disk if /// write mode is enabled -pub(crate) fn process_file(ctx: &TraversalOptions, pglsp_path: &PgLspPath) -> FileResult { - tracing::trace_span!("process_file", path = ?pglsp_path).in_scope(move || { +pub(crate) fn process_file(ctx: &TraversalOptions, pglt_path: &PgLTPath) -> FileResult { + tracing::trace_span!("process_file", path = ?pglt_path).in_scope(move || { let shared_context = &SharedTraversalOptions::new(ctx); match ctx.execution.traversal_mode { TraversalMode::Dummy => { unreachable!("The dummy mode should not be called for this file") } - TraversalMode::Check { .. } => check_file(shared_context, pglsp_path), + TraversalMode::Check { .. } => check_file(shared_context, pglt_path), } }) } diff --git a/crates/pglt_cli/src/execute/process_file/workspace_file.rs b/crates/pglt_cli/src/execute/process_file/workspace_file.rs index 07e1f6e77..3deed48c9 100644 --- a/crates/pglt_cli/src/execute/process_file/workspace_file.rs +++ b/crates/pglt_cli/src/execute/process_file/workspace_file.rs @@ -1,7 +1,7 @@ use crate::execute::diagnostics::{ResultExt, ResultIoExt}; use crate::execute::process_file::SharedTraversalOptions; use pglt_diagnostics::{category, Error}; -use pglt_fs::{File, OpenOptions, PgLspPath}; +use pglt_fs::{File, OpenOptions, PgLTPath}; use pglt_workspace::workspace::{ChangeParams, FileGuard, OpenFileParams}; use pglt_workspace::{Workspace, WorkspaceError}; use std::ffi::OsStr; @@ -21,7 +21,7 @@ impl<'ctx, 'app> WorkspaceFile<'ctx, 'app> { ctx: &SharedTraversalOptions<'ctx, 'app>, path: &Path, ) -> Result { - let pglsp_path = PgLspPath::new(path); + let pglt_path = PgLTPath::new(path); let open_options = OpenOptions::default() .read(true) .write(ctx.execution.requires_write_access()); @@ -37,7 +37,7 @@ impl<'ctx, 'app> WorkspaceFile<'ctx, 'app> { let guard = FileGuard::open( ctx.workspace, OpenFileParams { - path: pglsp_path, + path: pglt_path, version: 0, content: input.clone(), }, diff --git a/crates/pglt_cli/src/execute/std_in.rs b/crates/pglt_cli/src/execute/std_in.rs index 3c1bfb286..922d0e8af 100644 --- a/crates/pglt_cli/src/execute/std_in.rs +++ b/crates/pglt_cli/src/execute/std_in.rs @@ -3,12 +3,12 @@ use crate::execute::Execution; use crate::{CliDiagnostic, CliSession}; use pglt_console::{markup, ConsoleExt}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; pub(crate) fn run<'a>( session: CliSession, mode: &'a Execution, - pglsp_path: PgLspPath, + pglt_path: PgLTPath, content: &'a str, verbose: bool, ) -> Result<(), CliDiagnostic> { diff --git a/crates/pglt_cli/src/execute/traverse.rs b/crates/pglt_cli/src/execute/traverse.rs index a20128a4d..a50977a14 100644 --- a/crates/pglt_cli/src/execute/traverse.rs +++ b/crates/pglt_cli/src/execute/traverse.rs @@ -7,7 +7,7 @@ use crate::{CliDiagnostic, CliSession}; use crossbeam::channel::{unbounded, Receiver, Sender}; use pglt_diagnostics::DiagnosticTags; use pglt_diagnostics::{DiagnosticExt, Error, Resource, Severity}; -use pglt_fs::{FileSystem, PathInterner, PgLspPath}; +use pglt_fs::{FileSystem, PathInterner, PgLTPath}; use pglt_fs::{TraversalContext, TraversalScope}; use pglt_workspace::dome::Dome; use pglt_workspace::workspace::IsPathIgnoredParams; @@ -31,7 +31,7 @@ use std::{ pub(crate) struct TraverseResult { pub(crate) summary: TraversalSummary, - pub(crate) evaluated_paths: BTreeSet, + pub(crate) evaluated_paths: BTreeSet, pub(crate) diagnostics: Vec, } @@ -86,7 +86,7 @@ pub(crate) fn traverse( let (duration, evaluated_paths, diagnostics) = thread::scope(|s| { let handler = thread::Builder::new() - .name(String::from("pglsp::console")) + .name(String::from("pglt::console")) .spawn_scoped(s, || printer.run(receiver, recv_files)) .expect("failed to spawn console thread"); @@ -148,7 +148,7 @@ fn init_thread_pool() { static INIT_ONCE: Once = Once::new(); INIT_ONCE.call_once(|| { rayon::ThreadPoolBuilder::new() - .thread_name(|index| format!("pglsp::worker_{index}")) + .thread_name(|index| format!("pglt::worker_{index}")) .build_global() .expect("failed to initialize the global thread pool"); }); @@ -160,7 +160,7 @@ fn traverse_inputs( fs: &dyn FileSystem, inputs: Vec, ctx: &TraversalOptions, -) -> (Duration, BTreeSet) { +) -> (Duration, BTreeSet) { let start = Instant::now(); fs.traversal(Box::new(move |scope: &dyn TraversalScope| { for input in inputs { @@ -412,11 +412,11 @@ pub(crate) struct TraversalOptions<'ctx, 'app> { pub(crate) remaining_diagnostics: &'ctx AtomicU32, /// List of paths that should be processed - pub(crate) evaluated_paths: RwLock>, + pub(crate) evaluated_paths: RwLock>, } impl TraversalOptions<'_, '_> { - pub(crate) fn increment_changed(&self, path: &PgLspPath) { + pub(crate) fn increment_changed(&self, path: &PgLTPath) { self.changed.fetch_add(1, Ordering::Relaxed); self.evaluated_paths .write() @@ -436,10 +436,8 @@ impl TraversalOptions<'_, '_> { self.messages.send(msg.into()).ok(); } - pub(crate) fn protected_file(&self, pglsp_path: &PgLspPath) { - self.push_diagnostic( - WorkspaceError::protected_file(pglsp_path.display().to_string()).into(), - ) + pub(crate) fn protected_file(&self, pglt_path: &PgLTPath) { + self.push_diagnostic(WorkspaceError::protected_file(pglt_path.display().to_string()).into()) } } @@ -448,7 +446,7 @@ impl TraversalContext for TraversalOptions<'_, '_> { &self.interner } - fn evaluated_paths(&self) -> BTreeSet { + fn evaluated_paths(&self) -> BTreeSet { self.evaluated_paths.read().unwrap().clone() } @@ -456,8 +454,8 @@ impl TraversalContext for TraversalOptions<'_, '_> { self.push_message(error); } - fn can_handle(&self, pglsp_path: &PgLspPath) -> bool { - let path = pglsp_path.as_path(); + fn can_handle(&self, pglt_path: &PgLTPath) -> bool { + let path = pglt_path.as_path(); let is_valid_file = self.fs.path_is_file(path) && path @@ -474,7 +472,7 @@ impl TraversalContext for TraversalOptions<'_, '_> { let can_handle = !self .workspace .is_path_ignored(IsPathIgnoredParams { - pglsp_path: pglsp_path.clone(), + pglt_path: pglt_path.clone(), }) .unwrap_or_else(|err| { self.push_diagnostic(err.into()); @@ -494,22 +492,22 @@ impl TraversalContext for TraversalOptions<'_, '_> { } } - fn handle_path(&self, path: PgLspPath) { + fn handle_path(&self, path: PgLTPath) { handle_file(self, &path) } - fn store_path(&self, path: PgLspPath) { + fn store_path(&self, path: PgLTPath) { self.evaluated_paths .write() .unwrap() - .insert(PgLspPath::new(path.as_path())); + .insert(PgLTPath::new(path.as_path())); } } /// This function wraps the [process_file] function implementing the traversal /// in a [catch_unwind] block and emit diagnostics in case of error (either the /// traversal function returns Err or panics) -fn handle_file(ctx: &TraversalOptions, path: &PgLspPath) { +fn handle_file(ctx: &TraversalOptions, path: &PgLTPath) { match catch_unwind(move || process_file(ctx, path)) { Ok(Ok(FileStatus::Changed)) => { ctx.increment_changed(path); diff --git a/crates/pglt_cli/src/logging.rs b/crates/pglt_cli/src/logging.rs index 723950233..9e1f197eb 100644 --- a/crates/pglt_cli/src/logging.rs +++ b/crates/pglt_cli/src/logging.rs @@ -91,12 +91,12 @@ impl Display for LoggingLevel { /// Tracing filter enabling: /// - All spans and events at level info or higher -/// - All spans and events at level debug in crates whose name starts with `pglsp` +/// - All spans and events at level debug in crates whose name starts with `pglt` struct LoggingFilter { level: LoggingLevel, } -/// Tracing filter used for spans emitted by `pglsp*` crates +/// Tracing filter used for spans emitted by `pglt*` crates const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { LevelFilter::TRACE } else { @@ -105,7 +105,7 @@ const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { impl LoggingFilter { fn is_enabled(&self, meta: &Metadata<'_>) -> bool { - let filter = if meta.target().starts_with("pglsp") { + let filter = if meta.target().starts_with("pglt") { if let Some(level) = self.level.to_filter_level() { level } else { diff --git a/crates/pglt_cli/src/panic.rs b/crates/pglt_cli/src/panic.rs index 3e066bd23..892645f98 100644 --- a/crates/pglt_cli/src/panic.rs +++ b/crates/pglt_cli/src/panic.rs @@ -19,7 +19,7 @@ fn panic_handler(info: &PanicHookInfo) { writeln!(error, "Encountered an unexpected error").unwrap(); writeln!(error).unwrap(); - writeln!(error, "This is a bug in PgLsp, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:").unwrap(); + writeln!(error, "This is a bug in PgLT, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:").unwrap(); writeln!(error).unwrap(); if let Some(location) = info.location() { diff --git a/crates/pglt_cli/src/reporter/gitlab.rs b/crates/pglt_cli/src/reporter/gitlab.rs index 7035e5324..05b9dd0c2 100644 --- a/crates/pglt_cli/src/reporter/gitlab.rs +++ b/crates/pglt_cli/src/reporter/gitlab.rs @@ -131,8 +131,8 @@ impl Display for GitLabDiagnostics<'_> { true } }) - .filter_map(|pglsp_diagnostic| { - let absolute_path = match pglsp_diagnostic.location().resource { + .filter_map(|pglt_diagnostic| { + let absolute_path = match pglt_diagnostic.location().resource { Some(Resource::File(file)) => Some(file), _ => None, } @@ -143,11 +143,11 @@ impl Display for GitLabDiagnostics<'_> { None => absolute_path.to_owned(), }; - let initial_fingerprint = self.compute_initial_fingerprint(pglsp_diagnostic, &path); + let initial_fingerprint = self.compute_initial_fingerprint(pglt_diagnostic, &path); let fingerprint = hasher.rehash_until_unique(initial_fingerprint); GitLabDiagnostic::try_from_diagnostic( - pglsp_diagnostic, + pglt_diagnostic, path.to_string(), fingerprint, ) diff --git a/crates/pglt_cli/src/reporter/junit.rs b/crates/pglt_cli/src/reporter/junit.rs index 1097c1ec5..a055f21fa 100644 --- a/crates/pglt_cli/src/reporter/junit.rs +++ b/crates/pglt_cli/src/reporter/junit.rs @@ -34,7 +34,7 @@ pub(crate) struct JunitReporterVisitor<'a>(pub(crate) Report, pub(crate) &'a mut impl<'a> JunitReporterVisitor<'a> { pub(crate) fn new(console: &'a mut dyn Console) -> Self { - let report = Report::new("PgLsp"); + let report = Report::new("PgLT"); Self(report, console) } } @@ -85,7 +85,7 @@ impl ReporterVisitor for JunitReporterVisitor<'_> { )); let mut case = TestCase::new( format!( - "org.pglsp.{}", + "org.pglt.{}", diagnostic .category() .map(|c| c.name()) @@ -103,9 +103,7 @@ impl ReporterVisitor for JunitReporterVisitor<'_> { "column".into(), start.column_number.get().to_string().into(), ); - test_suite - .extra - .insert("package".into(), "org.pglsp".into()); + test_suite.extra.insert("package".into(), "org.pglt".into()); test_suite.add_test_case(case); self.0.add_test_suite(test_suite); } diff --git a/crates/pglt_cli/src/reporter/mod.rs b/crates/pglt_cli/src/reporter/mod.rs index fb7837b8c..c318b7c0a 100644 --- a/crates/pglt_cli/src/reporter/mod.rs +++ b/crates/pglt_cli/src/reporter/mod.rs @@ -5,7 +5,7 @@ pub(crate) mod terminal; use crate::execute::Execution; use pglt_diagnostics::{Error, Severity}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use serde::Serialize; use std::collections::BTreeSet; use std::io; @@ -49,7 +49,7 @@ pub trait ReporterVisitor { ) -> io::Result<()>; /// Writes the paths that were handled during a run. - fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { + fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { let _ = evaluated_paths; Ok(()) } diff --git a/crates/pglt_cli/src/reporter/terminal.rs b/crates/pglt_cli/src/reporter/terminal.rs index 734c95c39..d46435718 100644 --- a/crates/pglt_cli/src/reporter/terminal.rs +++ b/crates/pglt_cli/src/reporter/terminal.rs @@ -5,7 +5,7 @@ use pglt_console::fmt::Formatter; use pglt_console::{fmt, markup, Console, ConsoleExt}; use pglt_diagnostics::advice::ListAdvice; use pglt_diagnostics::{Diagnostic, PrintDiagnostic}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use std::collections::BTreeSet; use std::io; use std::time::Duration; @@ -14,7 +14,7 @@ pub(crate) struct ConsoleReporter { pub(crate) summary: TraversalSummary, pub(crate) diagnostics_payload: DiagnosticsPayload, pub(crate) execution: Execution, - pub(crate) evaluated_paths: BTreeSet, + pub(crate) evaluated_paths: BTreeSet, } impl Reporter for ConsoleReporter { @@ -66,7 +66,7 @@ impl ReporterVisitor for ConsoleReporterVisitor<'_> { Ok(()) } - fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { + fn report_handled_paths(&mut self, evaluated_paths: BTreeSet) -> io::Result<()> { let evaluated_paths_diagnostic = EvaluatedPathsDiagnostic { advice: ListAdvice { list: evaluated_paths diff --git a/crates/pglt_cli/src/service/mod.rs b/crates/pglt_cli/src/service/mod.rs index 4e55632a4..dba786a50 100644 --- a/crates/pglt_cli/src/service/mod.rs +++ b/crates/pglt_cli/src/service/mod.rs @@ -191,7 +191,7 @@ impl WorkspaceTransport for SocketTransport { self.pending_requests.insert(request.id, send); - let is_shutdown = request.method == "pglsp/shutdown"; + let is_shutdown = request.method == "pglt/shutdown"; let request = JsonRpcRequest { jsonrpc: Cow::Borrowed("2.0"), diff --git a/crates/pglt_cli/src/service/unix.rs b/crates/pglt_cli/src/service/unix.rs index 22608abc5..941a26c03 100644 --- a/crates/pglt_cli/src/service/unix.rs +++ b/crates/pglt_cli/src/service/unix.rs @@ -21,7 +21,7 @@ use tracing::{debug, info, Instrument}; /// Returns the filesystem path of the global socket used to communicate with /// the server daemon fn get_socket_name() -> PathBuf { - pglt_fs::ensure_cache_dir().join(format!("pglsp-socket-{}", pglt_configuration::VERSION)) + pglt_fs::ensure_cache_dir().join(format!("pglt-socket-{}", pglt_configuration::VERSION)) } pub(crate) fn enumerate_pipes() -> io::Result> { @@ -31,7 +31,7 @@ pub(crate) fn enumerate_pipes() -> io::Result> { let file_name = entry.file_name()?; let file_name = file_name.to_str()?; - let version = file_name.strip_prefix("pglsp-socket")?; + let version = file_name.strip_prefix("pglt-socket")?; if version.is_empty() { Some(String::new()) } else { diff --git a/crates/pglt_cli/src/service/windows.rs b/crates/pglt_cli/src/service/windows.rs index 408553c0c..d1a614b76 100644 --- a/crates/pglt_cli/src/service/windows.rs +++ b/crates/pglt_cli/src/service/windows.rs @@ -24,7 +24,7 @@ use tracing::Instrument; /// Returns the name of the global named pipe used to communicate with the /// server daemon fn get_pipe_name() -> String { - format!(r"\\.\pipe\pglsp-service-{}", pglt_configuration::VERSION) + format!(r"\\.\pipe\pglt-service-{}", pglt_configuration::VERSION) } pub(crate) fn enumerate_pipes() -> io::Result> { @@ -34,7 +34,7 @@ pub(crate) fn enumerate_pipes() -> io::Result> { let file_name = entry.file_name()?; let file_name = file_name.to_str()?; - let version = file_name.strip_prefix("pglsp-service")?; + let version = file_name.strip_prefix("pglt-service")?; if version.is_empty() { Some(String::new()) } else { diff --git a/crates/pglt_configuration/src/lib.rs b/crates/pglt_configuration/src/lib.rs index 7190271dd..d505baf66 100644 --- a/crates/pglt_configuration/src/lib.rs +++ b/crates/pglt_configuration/src/lib.rs @@ -1,4 +1,4 @@ -//! This module contains the configuration of `pglsp.toml` +//! This module contains the configuration of `pglt.toml` //! //! The configuration is divided by "tool", and then it's possible to further customise it //! by language. The language might further options divided by tool. diff --git a/crates/pglt_configuration/src/vcs.rs b/crates/pglt_configuration/src/vcs.rs index 7f9b049ea..be61abdaf 100644 --- a/crates/pglt_configuration/src/vcs.rs +++ b/crates/pglt_configuration/src/vcs.rs @@ -28,7 +28,7 @@ pub struct VcsConfiguration { pub use_ignore_file: bool, /// The folder where we should check for VCS files. By default, we will use the same - /// folder where `pglsp.toml` was found. + /// folder where `pglt.toml` was found. /// /// If we can't find the configuration, it will attempt to use the current working directory. /// If no current working directory can't be found, we won't use the VCS integration, and a diagnostic diff --git a/crates/pglt_diagnostics_categories/src/categories.rs b/crates/pglt_diagnostics_categories/src/categories.rs index bc7912720..5c590c428 100644 --- a/crates/pglt_diagnostics_categories/src/categories.rs +++ b/crates/pglt_diagnostics_categories/src/categories.rs @@ -13,8 +13,8 @@ // must be between `define_categories! {\n` and `\n ;\n`. define_categories! { - "lint/safety/banDropColumn": "https://pglsp.dev/linter/rules/ban-drop-column", - "lint/safety/banDropNotNull": "https://pglsp.dev/linter/rules/ban-drop-not-null", + "lint/safety/banDropColumn": "https://pglt.dev/linter/rules/ban-drop-column", + "lint/safety/banDropNotNull": "https://pglt.dev/linter/rules/ban-drop-not-null", // end lint rules ; // General categories diff --git a/crates/pglt_flags/src/lib.rs b/crates/pglt_flags/src/lib.rs index ad293db3a..162db2f7d 100644 --- a/crates/pglt_flags/src/lib.rs +++ b/crates/pglt_flags/src/lib.rs @@ -6,34 +6,34 @@ use std::env; use std::ops::Deref; use std::sync::{LazyLock, OnceLock}; -/// Returns `true` if this is an unstable build of PgLsp +/// Returns `true` if this is an unstable build of PgLT pub fn is_unstable() -> bool { PGLSP_VERSION.deref().is_none() } -/// The internal version of PgLsp. This is usually supplied during the CI build +/// The internal version of PgLT. This is usually supplied during the CI build pub static PGLSP_VERSION: LazyLock> = LazyLock::new(|| option_env!("PGLSP_VERSION")); -pub struct PgLspEnv { - pub pglsp_log_path: PgLspEnvVariable, - pub pglsp_log_prefix: PgLspEnvVariable, - pub pglsp_config_path: PgLspEnvVariable, +pub struct PgLTEnv { + pub pglt_log_path: PgLTEnvVariable, + pub pglt_log_prefix: PgLTEnvVariable, + pub pglt_config_path: PgLTEnvVariable, } -pub static PGLSP_ENV: OnceLock = OnceLock::new(); +pub static PGLSP_ENV: OnceLock = OnceLock::new(); -impl PgLspEnv { +impl PgLTEnv { fn new() -> Self { Self { - pglsp_log_path: PgLspEnvVariable::new( + pglt_log_path: PgLTEnvVariable::new( "PGLSP_LOG_PATH", "The directory where the Daemon logs will be saved.", ), - pglsp_log_prefix: PgLspEnvVariable::new( + pglt_log_prefix: PgLTEnvVariable::new( "PGLSP_LOG_PREFIX_NAME", "A prefix that's added to the name of the log. Default: `server.log.`", ), - pglsp_config_path: PgLspEnvVariable::new( + pglt_config_path: PgLTEnvVariable::new( "PGLSP_CONFIG_PATH", "A path to the configuration file", ), @@ -41,7 +41,7 @@ impl PgLspEnv { } } -pub struct PgLspEnvVariable { +pub struct PgLTEnvVariable { /// The name of the environment variable name: &'static str, /// The description of the variable. @@ -49,7 +49,7 @@ pub struct PgLspEnvVariable { description: &'static str, } -impl PgLspEnvVariable { +impl PgLTEnvVariable { fn new(name: &'static str, description: &'static str) -> Self { Self { name, description } } @@ -70,38 +70,37 @@ impl PgLspEnvVariable { } } -pub fn pglsp_env() -> &'static PgLspEnv { - PGLSP_ENV.get_or_init(PgLspEnv::new) +pub fn pglt_env() -> &'static PgLTEnv { + PGLSP_ENV.get_or_init(PgLTEnv::new) } -impl Display for PgLspEnv { +impl Display for PgLTEnv { fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { - match self.pglsp_log_path.value() { + match self.pglt_log_path.value() { None => { - KeyValuePair(self.pglsp_log_path.name, markup! { "unset" }).fmt(fmt)?; + KeyValuePair(self.pglt_log_path.name, markup! { "unset" }).fmt(fmt)?; } Some(value) => { - KeyValuePair(self.pglsp_log_path.name, markup! {{DebugDisplay(value)}}).fmt(fmt)?; + KeyValuePair(self.pglt_log_path.name, markup! {{DebugDisplay(value)}}).fmt(fmt)?; } }; - match self.pglsp_log_prefix.value() { + match self.pglt_log_prefix.value() { None => { - KeyValuePair(self.pglsp_log_prefix.name, markup! { "unset" }) - .fmt(fmt)?; + KeyValuePair(self.pglt_log_prefix.name, markup! { "unset" }).fmt(fmt)?; } Some(value) => { - KeyValuePair(self.pglsp_log_prefix.name, markup! {{DebugDisplay(value)}}) + KeyValuePair(self.pglt_log_prefix.name, markup! {{DebugDisplay(value)}}) .fmt(fmt)?; } }; - match self.pglsp_config_path.value() { + match self.pglt_config_path.value() { None => { - KeyValuePair(self.pglsp_config_path.name, markup! { "unset" }) + KeyValuePair(self.pglt_config_path.name, markup! { "unset" }) .fmt(fmt)?; } Some(value) => { - KeyValuePair(self.pglsp_config_path.name, markup! {{DebugDisplay(value)}}) + KeyValuePair(self.pglt_config_path.name, markup! {{DebugDisplay(value)}}) .fmt(fmt)?; } }; diff --git a/crates/pglt_fs/src/dir.rs b/crates/pglt_fs/src/dir.rs index d4a635208..a137f39dd 100644 --- a/crates/pglt_fs/src/dir.rs +++ b/crates/pglt_fs/src/dir.rs @@ -3,10 +3,10 @@ use std::{env, fs, path::PathBuf}; use tracing::warn; pub fn ensure_cache_dir() -> PathBuf { - if let Some(proj_dirs) = ProjectDirs::from("dev", "supabase-community", "pglsp") { - // Linux: /home/alice/.cache/pglsp - // Win: C:\Users\Alice\AppData\Local\supabase-community\pglsp\cache - // Mac: /Users/Alice/Library/Caches/dev.supabase-community.pglsp + if let Some(proj_dirs) = ProjectDirs::from("dev", "supabase-community", "pglt") { + // Linux: /home/alice/.cache/pglt + // Win: C:\Users\Alice\AppData\Local\supabase-community\pglt\cache + // Mac: /Users/Alice/Library/Caches/dev.supabase-community.pglt let cache_dir = proj_dirs.cache_dir().to_path_buf(); if let Err(err) = fs::create_dir_all(&cache_dir) { let temp_dir = env::temp_dir(); diff --git a/crates/pglt_fs/src/fs.rs b/crates/pglt_fs/src/fs.rs index 30f9cea7d..055d5eb5a 100644 --- a/crates/pglt_fs/src/fs.rs +++ b/crates/pglt_fs/src/fs.rs @@ -1,4 +1,4 @@ -use crate::{PathInterner, PgLspPath}; +use crate::{PathInterner, PgLTPath}; pub use memory::{ErrorEntry, MemoryFileSystem}; pub use os::OsFileSystem; use pglt_diagnostics::{console, Advices, Diagnostic, LogCategory, Visit}; @@ -18,9 +18,9 @@ mod os; pub struct ConfigName; impl ConfigName { - const PGLSP_TOML: [&'static str; 1] = ["pglsp.toml"]; + const PGLSP_TOML: [&'static str; 1] = ["pglt.toml"]; - pub const fn pglsp_toml() -> &'static str { + pub const fn pglt_toml() -> &'static str { Self::PGLSP_TOML[0] } @@ -302,18 +302,18 @@ pub trait TraversalContext: Sync { /// Checks if the traversal context can handle a particular path, used as /// an optimization to bail out of scheduling a file handler if it wouldn't /// be able to process the file anyway - fn can_handle(&self, path: &PgLspPath) -> bool; + fn can_handle(&self, path: &PgLTPath) -> bool; /// This method will be called by the traversal for each file it finds /// where [TraversalContext::can_handle] returned true - fn handle_path(&self, path: PgLspPath); + fn handle_path(&self, path: PgLTPath); /// This method will be called by the traversal for each file it finds /// where [TraversalContext::store_path] returned true - fn store_path(&self, path: PgLspPath); + fn store_path(&self, path: PgLTPath); /// Returns the paths that should be handled - fn evaluated_paths(&self) -> BTreeSet; + fn evaluated_paths(&self) -> BTreeSet; } impl FileSystem for Arc diff --git a/crates/pglt_fs/src/fs/memory.rs b/crates/pglt_fs/src/fs/memory.rs index e6b58a436..31a036424 100644 --- a/crates/pglt_fs/src/fs/memory.rs +++ b/crates/pglt_fs/src/fs/memory.rs @@ -10,7 +10,7 @@ use parking_lot::{lock_api::ArcMutexGuard, Mutex, RawMutex, RwLock}; use pglt_diagnostics::{Error, Severity}; use crate::fs::OpenOptions; -use crate::{FileSystem, PgLspPath, TraversalContext, TraversalScope}; +use crate::{FileSystem, PgLTPath, TraversalContext, TraversalScope}; use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic}; @@ -297,11 +297,11 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> { if should_process_file { let _ = ctx.interner().intern_path(path.into()); - let pglsp_path = PgLspPath::new(path); - if !ctx.can_handle(&pglsp_path) { + let pglt_path = PgLTPath::new(path); + if !ctx.can_handle(&pglt_path) { continue; } - ctx.store_path(pglsp_path); + ctx.store_path(pglt_path); } } } @@ -328,7 +328,7 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> { } fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) { - context.handle_path(PgLspPath::new(path)); + context.handle_path(PgLTPath::new(path)); } } @@ -345,7 +345,7 @@ mod tests { use pglt_diagnostics::Error; use crate::{fs::FileSystemExt, OpenOptions}; - use crate::{FileSystem, MemoryFileSystem, PathInterner, PgLspPath, TraversalContext}; + use crate::{FileSystem, MemoryFileSystem, PathInterner, PgLTPath, TraversalContext}; #[test] fn fs_read_only() { @@ -509,7 +509,7 @@ mod tests { struct TestContext { interner: PathInterner, - visited: Mutex>, + visited: Mutex>, } impl TraversalContext for TestContext { @@ -521,19 +521,19 @@ mod tests { panic!("unexpected error {err:?}") } - fn can_handle(&self, _: &PgLspPath) -> bool { + fn can_handle(&self, _: &PgLTPath) -> bool { true } - fn handle_path(&self, path: PgLspPath) { + fn handle_path(&self, path: PgLTPath) { self.visited.lock().insert(path.to_written()); } - fn store_path(&self, path: PgLspPath) { + fn store_path(&self, path: PgLTPath) { self.visited.lock().insert(path); } - fn evaluated_paths(&self) -> BTreeSet { + fn evaluated_paths(&self) -> BTreeSet { let lock = self.visited.lock(); lock.clone() } @@ -554,8 +554,8 @@ mod tests { swap(&mut visited, ctx.visited.get_mut()); assert_eq!(visited.len(), 2); - assert!(visited.contains(&PgLspPath::new("dir1/file1"))); - assert!(visited.contains(&PgLspPath::new("dir1/file2"))); + assert!(visited.contains(&PgLTPath::new("dir1/file1"))); + assert!(visited.contains(&PgLTPath::new("dir1/file2"))); // Traverse a single file fs.traversal(Box::new(|scope| { @@ -566,6 +566,6 @@ mod tests { swap(&mut visited, ctx.visited.get_mut()); assert_eq!(visited.len(), 1); - assert!(visited.contains(&PgLspPath::new("dir2/file2"))); + assert!(visited.contains(&PgLTPath::new("dir2/file2"))); } } diff --git a/crates/pglt_fs/src/fs/os.rs b/crates/pglt_fs/src/fs/os.rs index fce0d8f70..7f0ee7d22 100644 --- a/crates/pglt_fs/src/fs/os.rs +++ b/crates/pglt_fs/src/fs/os.rs @@ -3,7 +3,7 @@ use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic}; use crate::fs::OpenOptions; use crate::{ fs::{TraversalContext, TraversalScope}, - FileSystem, PgLspPath, + FileSystem, PgLTPath, }; use pglt_diagnostics::{adapters::IoError, DiagnosticExt, Error, Severity}; use rayon::{scope, Scope}; @@ -190,7 +190,7 @@ impl<'scope> TraversalScope<'scope> for OsTraversalScope<'scope> { fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) { self.scope.spawn(move |_| { - context.handle_path(PgLspPath::new(path)); + context.handle_path(PgLTPath::new(path)); }); } } @@ -268,7 +268,7 @@ fn handle_any_file<'scope>( } if file_type.is_symlink() { - if !ctx.can_handle(&PgLspPath::new(path.clone())) { + if !ctx.can_handle(&PgLTPath::new(path.clone())) { return; } let Ok((target_path, target_file_type)) = expand_symbolic_link(path.clone(), ctx) else { @@ -295,11 +295,11 @@ fn handle_any_file<'scope>( // In case the file is inside a directory that is behind a symbolic link, // the unresolved origin path is used to construct a new path. // This is required to support ignore patterns to symbolic links. - let pglsp_path = if let Some(old_origin_path) = &origin_path { + let pglt_path = if let Some(old_origin_path) = &origin_path { if let Some(file_name) = path.file_name() { let new_origin_path = old_origin_path.join(file_name); origin_path = Some(new_origin_path.clone()); - PgLspPath::new(new_origin_path) + PgLTPath::new(new_origin_path) } else { ctx.push_diagnostic(Error::from(FileSystemDiagnostic { path: path.to_string_lossy().to_string(), @@ -309,7 +309,7 @@ fn handle_any_file<'scope>( return; } } else { - PgLspPath::new(&path) + PgLTPath::new(&path) }; // Performing this check here let's us skip unsupported @@ -317,7 +317,7 @@ fn handle_any_file<'scope>( // doing a directory traversal, but printing an error message if the // user explicitly requests an unsupported file to be handled. // This check also works for symbolic links. - if !ctx.can_handle(&pglsp_path) { + if !ctx.can_handle(&pglt_path) { return; } @@ -330,7 +330,7 @@ fn handle_any_file<'scope>( if file_type.is_file() { scope.spawn(move |_| { - ctx.store_path(PgLspPath::new(path)); + ctx.store_path(PgLTPath::new(path)); }); return; } diff --git a/crates/pglt_fs/src/lib.rs b/crates/pglt_fs/src/lib.rs index 7c225058c..7ac1ef7eb 100644 --- a/crates/pglt_fs/src/lib.rs +++ b/crates/pglt_fs/src/lib.rs @@ -7,7 +7,7 @@ mod path; pub use dir::ensure_cache_dir; pub use interner::PathInterner; -pub use path::PgLspPath; +pub use path::PgLTPath; pub use fs::{ AutoSearchResult, ConfigName, ErrorEntry, File, FileSystem, FileSystemDiagnostic, diff --git a/crates/pglt_fs/src/path.rs b/crates/pglt_fs/src/path.rs index 0889573c2..b1411c53d 100644 --- a/crates/pglt_fs/src/path.rs +++ b/crates/pglt_fs/src/path.rs @@ -23,7 +23,7 @@ use crate::ConfigName; )] // NOTE: The order of the variants is important, the one on the top has the highest priority pub enum FileKind { - /// A configuration file has the highest priority. It's usually `pglsp.toml` + /// A configuration file has the highest priority. It's usually `pglt.toml` /// /// Other third-party configuration files might be added in the future Config, @@ -89,7 +89,7 @@ impl From for FileKinds { feature = "serde", derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) )] -pub struct PgLspPath { +pub struct PgLTPath { path: PathBuf, /// Determines the kind of the file inside PGLSP. Some files are considered as configuration files, others as manifest files, and others as files to handle kind: FileKinds, @@ -97,7 +97,7 @@ pub struct PgLspPath { was_written: bool, } -impl Deref for PgLspPath { +impl Deref for PgLTPath { type Target = PathBuf; fn deref(&self) -> &Self::Target { @@ -105,13 +105,13 @@ impl Deref for PgLspPath { } } -impl PartialOrd for PgLspPath { +impl PartialOrd for PgLTPath { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } -impl Ord for PgLspPath { +impl Ord for PgLTPath { fn cmp(&self, other: &Self) -> Ordering { match self.kind.cmp(&other.kind) { Ordering::Equal => self.path.cmp(&other.path), @@ -120,7 +120,7 @@ impl Ord for PgLspPath { } } -impl PgLspPath { +impl PgLTPath { pub fn new(path_to_file: impl Into) -> Self { let path = path_to_file.into(); let kind = path.file_name().map(Self::priority).unwrap_or_default(); @@ -141,7 +141,7 @@ impl PgLspPath { } } - /// Creates a new [PgLspPath], marked as fixed + /// Creates a new [PgLTPath], marked as fixed pub fn to_written(&self) -> Self { Self { path: self.path.clone(), @@ -177,11 +177,11 @@ impl PgLspPath { } /// The priority of the file. - /// - `pglsp.toml` has the highest priority + /// - `pglt.toml` has the highest priority /// - `package.json` and `tsconfig.json`/`jsconfig.json` have the second-highest priority, and they are considered as manifest files /// - Other files are considered as files to handle fn priority(file_name: &OsStr) -> FileKinds { - if file_name == ConfigName::pglsp_toml() { + if file_name == ConfigName::pglt_toml() { FileKind::Config.into() } else { FileKind::Handleable.into() diff --git a/crates/pglt_lsp/src/handlers/text_document.rs b/crates/pglt_lsp/src/handlers/text_document.rs index bd30f8406..d777cf65d 100644 --- a/crates/pglt_lsp/src/handlers/text_document.rs +++ b/crates/pglt_lsp/src/handlers/text_document.rs @@ -53,11 +53,11 @@ pub(crate) async fn did_change( let url = params.text_document.uri; let version = params.text_document.version; - let pglsp_path = session.file_path(&url)?; + let pglt_path = session.file_path(&url)?; let old_doc = session.document(&url)?; let old_text = session.workspace.get_file_content(GetFileContentParams { - path: pglsp_path.clone(), + path: pglt_path.clone(), })?; let start = params @@ -74,7 +74,7 @@ pub(crate) async fn did_change( ); session.workspace.change_file(ChangeFileParams { - path: pglsp_path, + path: pglt_path, version, changes: params.content_changes[start..] .iter() @@ -103,11 +103,11 @@ pub(crate) async fn did_close( params: lsp_types::DidCloseTextDocumentParams, ) -> Result<()> { let url = params.text_document.uri; - let pglsp_path = session.file_path(&url)?; + let pglt_path = session.file_path(&url)?; session .workspace - .close_file(CloseFileParams { path: pglsp_path })?; + .close_file(CloseFileParams { path: pglt_path })?; session.remove_document(&url); diff --git a/crates/pglt_lsp/src/server.rs b/crates/pglt_lsp/src/server.rs index 697c1f287..cb8b8f93c 100644 --- a/crates/pglt_lsp/src/server.rs +++ b/crates/pglt_lsp/src/server.rs @@ -57,7 +57,7 @@ impl LSPServer { let mut capabilities = CapabilitySet::default(); capabilities.add_capability( - "pglsp_did_change_extension_settings", + "pglt_did_change_extension_settings", "workspace/didChangeConfiguration", if self.session.can_register_did_change_configuration() { CapabilityStatus::Enable(None) @@ -67,13 +67,13 @@ impl LSPServer { ); capabilities.add_capability( - "pglsp_did_change_workspace_settings", + "pglt_did_change_workspace_settings", "workspace/didChangeWatchedFiles", if let Some(base_path) = self.session.base_path() { CapabilityStatus::Enable(Some(json!(DidChangeWatchedFilesRegistrationOptions { watchers: vec![FileSystemWatcher { glob_pattern: GlobPattern::String(format!( - "{}/pglsp.toml", + "{}/pglt.toml", base_path.display() )), kind: Some(WatchKind::all()), @@ -147,7 +147,7 @@ impl LanguageServer for LSPServer { async fn initialized(&self, params: InitializedParams) { let _ = params; - info!("Attempting to load the configuration from 'pglsp.toml' file"); + info!("Attempting to load the configuration from 'pglt.toml' file"); futures::join!(self.session.load_workspace_settings()); @@ -271,9 +271,9 @@ type Sessions = Arc>>; macro_rules! workspace_method { ( $builder:ident, $method:ident ) => { $builder = $builder.custom_method( - concat!("pglsp/", stringify!($method)), + concat!("pglt/", stringify!($method)), |server: &LSPServer, params| { - let span = tracing::trace_span!(concat!("pglsp/", stringify!($method)), params = ?params).or_current(); + let span = tracing::trace_span!(concat!("pglt/", stringify!($method)), params = ?params).or_current(); tracing::info!("Received request: {}", stringify!($method)); let workspace = server.session.workspace.clone(); @@ -382,7 +382,7 @@ impl ServerFactory { }); // "shutdown" is not part of the Workspace API - builder = builder.custom_method("pglsp/shutdown", |server: &LSPServer, (): ()| { + builder = builder.custom_method("pglt/shutdown", |server: &LSPServer, (): ()| { info!("Sending shutdown signal"); server.session.broadcast_shutdown(); ready(Ok(Some(()))) diff --git a/crates/pglt_lsp/src/session.rs b/crates/pglt_lsp/src/session.rs index b592de48e..c8fa93189 100644 --- a/crates/pglt_lsp/src/session.rs +++ b/crates/pglt_lsp/src/session.rs @@ -7,7 +7,7 @@ use futures::StreamExt; use pglt_analyse::RuleCategoriesBuilder; use pglt_configuration::ConfigurationPathHint; use pglt_diagnostics::{DiagnosticExt, Error}; -use pglt_fs::{FileSystem, PgLspPath}; +use pglt_fs::{FileSystem, PgLTPath}; use pglt_lsp_converters::{negotiated_encoding, PositionEncoding, WideEncoding}; use pglt_workspace::configuration::{load_configuration, LoadedConfiguration}; use pglt_workspace::settings::PartialConfigurationExt; @@ -247,7 +247,7 @@ impl Session { /// contents changes. #[tracing::instrument(level = "trace", skip_all, fields(url = display(&url), diagnostic_count), err)] pub(crate) async fn update_diagnostics(&self, url: lsp_types::Url) -> Result<(), LspError> { - let pglsp_path = self.file_path(&url)?; + let pglt_path = self.file_path(&url)?; let doc = self.document(&url)?; if self.configuration_status().is_error() && !self.notified_broken_configuration() { self.set_notified_broken_configuration(); @@ -260,14 +260,14 @@ impl Session { let diagnostics: Vec = { let result = self.workspace.pull_diagnostics(PullDiagnosticsParams { - path: pglsp_path.clone(), + path: pglt_path.clone(), max_diagnostics: u64::MAX, categories: categories.build(), only: Vec::new(), skip: Vec::new(), })?; - tracing::trace!("pglsp diagnostics: {:#?}", result.diagnostics); + tracing::trace!("pglt diagnostics: {:#?}", result.diagnostics); result .diagnostics @@ -340,7 +340,7 @@ impl Session { self.documents.write().unwrap().remove(url); } - pub(crate) fn file_path(&self, url: &lsp_types::Url) -> Result { + pub(crate) fn file_path(&self, url: &lsp_types::Url) -> Result { let path_to_file = match url.to_file_path() { Err(_) => { // If we can't create a path, it's probably because the file doesn't exist. @@ -350,7 +350,7 @@ impl Session { Ok(path) => path, }; - Ok(PgLspPath::new(path_to_file)) + Ok(PgLTPath::new(path_to_file)) } /// True if the client supports dynamic registration of "workspace/didChangeConfiguration" requests @@ -398,14 +398,14 @@ impl Session { .map(|params| ¶ms.client_capabilities) } - /// This function attempts to read the `pglsp.toml` configuration file from + /// This function attempts to read the `pglt.toml` configuration file from /// the root URI and update the workspace settings accordingly #[tracing::instrument(level = "trace", skip(self))] pub(crate) async fn load_workspace_settings(&self) { // Providing a custom configuration path will not allow to support workspaces if let Some(config_path) = &self.config_path { let base_path = ConfigurationPathHint::FromUser(config_path.clone()); - let status = self.load_pglsp_configuration_file(base_path).await; + let status = self.load_pglt_configuration_file(base_path).await; self.set_configuration_status(status); } else if let Some(folders) = self.get_workspace_folders() { info!("Detected workspace folder."); @@ -416,7 +416,7 @@ impl Session { match base_path { Ok(base_path) => { let status = self - .load_pglsp_configuration_file(ConfigurationPathHint::FromWorkspace( + .load_pglt_configuration_file(ConfigurationPathHint::FromWorkspace( base_path, )) .await; @@ -435,12 +435,12 @@ impl Session { None => ConfigurationPathHint::default(), Some(path) => ConfigurationPathHint::FromLsp(path), }; - let status = self.load_pglsp_configuration_file(base_path).await; + let status = self.load_pglt_configuration_file(base_path).await; self.set_configuration_status(status); } } - async fn load_pglsp_configuration_file( + async fn load_pglt_configuration_file( &self, base_path: ConfigurationPathHint, ) -> ConfigurationStatus { diff --git a/crates/pglt_workspace/src/configuration.rs b/crates/pglt_workspace/src/configuration.rs index 2150829ba..cfe57393e 100644 --- a/crates/pglt_workspace/src/configuration.rs +++ b/crates/pglt_workspace/src/configuration.rs @@ -152,7 +152,7 @@ pub fn create_config( fs: &mut DynRef, configuration: PartialConfiguration, ) -> Result<(), WorkspaceError> { - let path = PathBuf::from(ConfigName::pglsp_toml()); + let path = PathBuf::from(ConfigName::pglt_toml()); if fs.path_exists(&path) { return Err(ConfigurationDiagnostic::new_already_exists().into()); diff --git a/crates/pglt_workspace/src/dome.rs b/crates/pglt_workspace/src/dome.rs index 42bed5864..b7742604d 100644 --- a/crates/pglt_workspace/src/dome.rs +++ b/crates/pglt_workspace/src/dome.rs @@ -1,4 +1,4 @@ -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use std::collections::btree_set::Iter; use std::collections::BTreeSet; use std::iter::{FusedIterator, Peekable}; @@ -7,16 +7,16 @@ use std::iter::{FusedIterator, Peekable}; /// specific paths like configuration files, manifests and more. #[derive(Debug, Default)] pub struct Dome { - paths: BTreeSet, + paths: BTreeSet, } impl Dome { - pub fn with_path(mut self, path: impl Into) -> Self { + pub fn with_path(mut self, path: impl Into) -> Self { self.paths.insert(path.into()); self } - pub fn new(paths: BTreeSet) -> Self { + pub fn new(paths: BTreeSet) -> Self { Self { paths } } @@ -26,17 +26,17 @@ impl Dome { } } - pub fn to_paths(self) -> BTreeSet { + pub fn to_paths(self) -> BTreeSet { self.paths } } pub struct DomeIterator<'a> { - iter: Peekable>, + iter: Peekable>, } impl<'a> DomeIterator<'a> { - pub fn next_config(&mut self) -> Option<&'a PgLspPath> { + pub fn next_config(&mut self) -> Option<&'a PgLTPath> { if let Some(path) = self.iter.peek() { if path.is_config() { self.iter.next() @@ -48,7 +48,7 @@ impl<'a> DomeIterator<'a> { } } - pub fn next_ignore(&mut self) -> Option<&'a PgLspPath> { + pub fn next_ignore(&mut self) -> Option<&'a PgLTPath> { if let Some(path) = self.iter.peek() { if path.is_ignore() { self.iter.next() @@ -62,7 +62,7 @@ impl<'a> DomeIterator<'a> { } impl<'a> Iterator for DomeIterator<'a> { - type Item = &'a PgLspPath; + type Item = &'a PgLTPath; fn next(&mut self) -> Option { self.iter.next() diff --git a/crates/pglt_workspace/src/workspace.rs b/crates/pglt_workspace/src/workspace.rs index 0ce930e0b..41139aac0 100644 --- a/crates/pglt_workspace/src/workspace.rs +++ b/crates/pglt_workspace/src/workspace.rs @@ -3,7 +3,7 @@ use std::{panic::RefUnwindSafe, path::PathBuf, sync::Arc}; pub use self::client::{TransportRequest, WorkspaceClient, WorkspaceTransport}; use pglt_analyse::RuleCategories; use pglt_configuration::{PartialConfiguration, RuleSelector}; -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use serde::{Deserialize, Serialize}; use text_size::{TextRange, TextSize}; @@ -14,26 +14,26 @@ mod server; #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct OpenFileParams { - pub path: PgLspPath, + pub path: PgLTPath, pub content: String, pub version: i32, } #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct CloseFileParams { - pub path: PgLspPath, + pub path: PgLTPath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct ChangeFileParams { - pub path: PgLspPath, + pub path: PgLTPath, pub version: i32, pub changes: Vec, } #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct PullDiagnosticsParams { - pub path: PgLspPath, + pub path: PgLTPath, pub categories: RuleCategories, pub max_diagnostics: u64, pub only: Vec, @@ -43,7 +43,7 @@ pub struct PullDiagnosticsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct CompletionParams { /// The File for which a completion is requested. - pub path: PgLspPath, + pub path: PgLTPath, /// The Cursor position in the file for which a completion is requested. pub position: TextSize, } @@ -81,7 +81,7 @@ impl ChangeParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct IsPathIgnoredParams { - pub pglsp_path: PgLspPath, + pub pglt_path: PgLTPath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] @@ -95,7 +95,7 @@ pub struct UpdateSettingsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct GetFileContentParams { - pub path: PgLspPath, + pub path: PgLTPath, } #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] @@ -170,7 +170,7 @@ where /// automatically on drop pub struct FileGuard<'app, W: Workspace + ?Sized> { workspace: &'app W, - path: PgLspPath, + path: PgLTPath, } impl<'app, W: Workspace + ?Sized> FileGuard<'app, W> { diff --git a/crates/pglt_workspace/src/workspace/client.rs b/crates/pglt_workspace/src/workspace/client.rs index 28672f170..f33f54ccc 100644 --- a/crates/pglt_workspace/src/workspace/client.rs +++ b/crates/pglt_workspace/src/workspace/client.rs @@ -81,7 +81,7 @@ where } pub fn shutdown(self) -> Result<(), WorkspaceError> { - self.request("pglsp/shutdown", ()) + self.request("pglt/shutdown", ()) } } @@ -90,23 +90,23 @@ where T: WorkspaceTransport + RefUnwindSafe + Send + Sync, { fn open_file(&self, params: OpenFileParams) -> Result<(), WorkspaceError> { - self.request("pglsp/open_file", params) + self.request("pglt/open_file", params) } fn close_file(&self, params: CloseFileParams) -> Result<(), WorkspaceError> { - self.request("pglsp/close_file", params) + self.request("pglt/close_file", params) } fn change_file(&self, params: super::ChangeFileParams) -> Result<(), WorkspaceError> { - self.request("pglsp/change_file", params) + self.request("pglt/change_file", params) } fn update_settings(&self, params: super::UpdateSettingsParams) -> Result<(), WorkspaceError> { - self.request("pglsp/update_settings", params) + self.request("pglt/update_settings", params) } fn is_path_ignored(&self, params: IsPathIgnoredParams) -> Result { - self.request("pglsp/is_path_ignored", params) + self.request("pglt/is_path_ignored", params) } fn server_info(&self) -> Option<&ServerInfo> { @@ -114,20 +114,20 @@ where } fn get_file_content(&self, params: GetFileContentParams) -> Result { - self.request("pglsp/get_file_content", params) + self.request("pglt/get_file_content", params) } fn pull_diagnostics( &self, params: super::PullDiagnosticsParams, ) -> Result { - self.request("pglsp/pull_diagnostics", params) + self.request("pglt/pull_diagnostics", params) } fn get_completions( &self, params: super::CompletionParams, ) -> Result { - self.request("pglsp/get_completions", params) + self.request("pglt/get_completions", params) } } diff --git a/crates/pglt_workspace/src/workspace/server.rs b/crates/pglt_workspace/src/workspace/server.rs index 4e2671c39..31ad999d5 100644 --- a/crates/pglt_workspace/src/workspace/server.rs +++ b/crates/pglt_workspace/src/workspace/server.rs @@ -11,7 +11,7 @@ use pg_query::PgQueryStore; use pglt_analyse::{AnalyserOptions, AnalysisFilter}; use pglt_analyser::{Analyser, AnalyserConfig, AnalyserContext}; use pglt_diagnostics::{serde::Diagnostic as SDiagnostic, Diagnostic, DiagnosticExt, Severity}; -use pglt_fs::{ConfigName, PgLspPath}; +use pglt_fs::{ConfigName, PgLTPath}; use pglt_typecheck::TypecheckParams; use schema_cache_manager::SchemaCacheManager; use tracing::info; @@ -47,7 +47,7 @@ pub(super) struct WorkspaceServer { schema_cache: SchemaCacheManager, /// Stores the document (text content + version number) associated with a URL - documents: DashMap, + documents: DashMap, tree_sitter: TreeSitterStore, pg_query: PgQueryStore, @@ -112,7 +112,7 @@ impl WorkspaceServer { fn is_ignored(&self, path: &Path) -> bool { let file_name = path.file_name().and_then(|s| s.to_str()); // Never ignore PGLSP's config file regardless `include`/`ignore` - (file_name != Some(ConfigName::pglsp_toml())) && + (file_name != Some(ConfigName::pglt_toml())) && // Apply top-level `include`/`ignore (self.is_ignored_by_top_level_config(path) || self.is_ignored_by_migration_config(path)) } @@ -261,7 +261,7 @@ impl Workspace for WorkspaceServer { } fn is_path_ignored(&self, params: IsPathIgnoredParams) -> Result { - Ok(self.is_ignored(params.pglsp_path.as_path())) + Ok(self.is_ignored(params.pglt_path.as_path())) } fn pull_diagnostics( diff --git a/crates/pglt_workspace/src/workspace/server/change.rs b/crates/pglt_workspace/src/workspace/server/change.rs index f51c4775b..435097bfd 100644 --- a/crates/pglt_workspace/src/workspace/server/change.rs +++ b/crates/pglt_workspace/src/workspace/server/change.rs @@ -391,7 +391,7 @@ mod tests { use crate::workspace::{ChangeFileParams, ChangeParams}; - use pglt_fs::PgLspPath; + use pglt_fs::PgLTPath; impl Document { pub fn get_text(&self, idx: usize) -> String { @@ -412,10 +412,10 @@ mod tests { #[test] fn within_statements() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id from users;\n\n\n\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), input.to_string(), 0); + let mut d = Document::new(PgLTPath::new("test.sql"), input.to_string(), 0); assert_eq!(d.positions.len(), 2); @@ -451,7 +451,7 @@ mod tests { #[test] fn julians_sample() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select\n *\nfrom\n test;\n\nselect\n\nalter table test\n\ndrop column id;"; let mut d = Document::new(path.clone(), input.to_string(), 0); @@ -536,10 +536,10 @@ mod tests { #[test] fn across_statements() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id from users;\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), input.to_string(), 0); + let mut d = Document::new(PgLTPath::new("test.sql"), input.to_string(), 0); assert_eq!(d.positions.len(), 2); @@ -575,10 +575,10 @@ mod tests { #[test] fn append_whitespace_to_statement() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id"; - let mut d = Document::new(PgLspPath::new("test.sql"), input.to_string(), 0); + let mut d = Document::new(PgLTPath::new("test.sql"), input.to_string(), 0); assert_eq!(d.positions.len(), 1); @@ -600,10 +600,10 @@ mod tests { #[test] fn apply_changes() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id from users;\nselect * from contacts;"; - let mut d = Document::new(PgLspPath::new("test.sql"), input.to_string(), 0); + let mut d = Document::new(PgLTPath::new("test.sql"), input.to_string(), 0); assert_eq!(d.positions.len(), 2); @@ -662,7 +662,7 @@ mod tests { #[test] fn apply_changes_at_end_of_statement() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id from\nselect * from contacts;"; let mut d = Document::new(path.clone(), input.to_string(), 1); @@ -694,7 +694,7 @@ mod tests { #[test] fn apply_changes_replacement() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let mut doc = Document::new(path.clone(), "".to_string(), 0); @@ -816,7 +816,7 @@ mod tests { #[test] fn apply_changes_within_statement() { let input = "select id from users;\nselect * from contacts;"; - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let mut doc = Document::new(path.clone(), input.to_string(), 0); @@ -867,7 +867,7 @@ mod tests { #[test] fn remove_outside_of_content() { - let path = PgLspPath::new("test.sql"); + let path = PgLTPath::new("test.sql"); let input = "select id from contacts;\n\nselect * from contacts;"; let mut d = Document::new(path.clone(), input.to_string(), 1); diff --git a/crates/pglt_workspace/src/workspace/server/document.rs b/crates/pglt_workspace/src/workspace/server/document.rs index c34d76913..a49a1609e 100644 --- a/crates/pglt_workspace/src/workspace/server/document.rs +++ b/crates/pglt_workspace/src/workspace/server/document.rs @@ -1,11 +1,11 @@ -use pglt_fs::PgLspPath; +use pglt_fs::PgLTPath; use text_size::TextRange; /// Global unique identifier for a statement #[derive(Debug, Hash, Eq, PartialEq, Clone)] pub(crate) struct Statement { /// Path of the document - pub(crate) path: PgLspPath, + pub(crate) path: PgLTPath, /// Unique id within the document pub(crate) id: StatementId, } @@ -15,7 +15,7 @@ pub type StatementId = usize; type StatementPos = (StatementId, TextRange); pub(crate) struct Document { - pub(crate) path: PgLspPath, + pub(crate) path: PgLTPath, pub(crate) content: String, pub(crate) version: i32, /// List of statements sorted by range.start() @@ -25,7 +25,7 @@ pub(crate) struct Document { } impl Document { - pub(crate) fn new(path: PgLspPath, content: String, version: i32) -> Self { + pub(crate) fn new(path: PgLTPath, content: String, version: i32) -> Self { let mut id_generator = IdGenerator::new(); let ranges: Vec = pglt_statement_splitter::split(&content) diff --git a/editors/code/package.json b/editors/code/package.json index ef72e2e72..c1ae259f3 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -85,7 +85,7 @@ "default": "off", "description": "Traces the communication between VS Code and the language server." }, - "pglsp.databaseUrl": { + "pglt.databaseUrl": { "type": "string", "default": "", "description": "Your Postgres Database URL" diff --git a/xtask/codegen/src/generate_new_analyser_rule.rs b/xtask/codegen/src/generate_new_analyser_rule.rs index be12b55ea..61fdcb87c 100644 --- a/xtask/codegen/src/generate_new_analyser_rule.rs +++ b/xtask/codegen/src/generate_new_analyser_rule.rs @@ -103,7 +103,7 @@ pub fn generate_new_analyser_rule(category: Category, rule_name: &str, group: &s // We sort rules to reduce conflicts between contributions made in parallel. let rule_line = match category { Category::Lint => format!( - r#" "lint/{group}/{rule_name_camel}": "https://pglsp.dev/linter/rules/{kebab_case_rule}","# + r#" "lint/{group}/{rule_name_camel}": "https://pglt.dev/linter/rules/{kebab_case_rule}","# ), }; let lint_start = match category {