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
19 changes: 16 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,27 @@ jobs:
uses: oven-sh/setup-bun@v2
- name: Install JS dependencies
run: bun install
- name: Build backend-jsonrpc

- name: Build backend-jsonrpc (deprecated)
working-directory: packages/@postgrestools/backend-jsonrpc
run: bun run build
- name: Run backend-jsonrpc test
- name: Run backend-jsonrpc test (deprecated)
working-directory: packages/@postgrestools/backend-jsonrpc
run: bun run test
- name: Run cli test
- name: Run cli test (deprecated)
working-directory: packages/@postgrestools/postgrestools
run: bun run test

- name: Build backend-jsonrpc
working-directory: packages/@postgres-language-server/backend-jsonrpc
run: bun run build
- name: Run backend-jsonrpc test
working-directory: packages/@postgres-language-server/backend-jsonrpc
run: bun run test
- name: Run cli test
working-directory: packages/@postgres-language-server/cli
run: bun run test

codegen:
name: Check Codegen
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -259,6 +270,8 @@ jobs:
run: cargo run -p xtask_codegen -- analyser
- name: Run the configuration codegen
run: cargo run -p xtask_codegen -- configuration
- name: Run the bindings codegen
run: cargo run -p xtask_codegen -- bindings
- name: Run the docs codegen
run: cargo run -p docs_codegen
- name: Check for git diff -- run "just ready" if you see an error
Expand Down
44 changes: 44 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@
"typescript": "^5",
},
},
"packages/@postgres-language-server/backend-jsonrpc": {
"name": "@postgres-language-server/backend-jsonrpc",
"optionalDependencies": {
"@postgres-language-server/cli-darwin-arm64": "<placeholder>",
"@postgres-language-server/cli-darwin-x64": "<placeholder>",
"@postgres-language-server/cli-linux-arm64": "<placeholder>",
"@postgres-language-server/cli-linux-x64": "<placeholder>",
"@postgres-language-server/cli-win32-arm64": "<placeholder>",
"@postgres-language-server/cli-win32-x64": "<placeholder>",
},
},
"packages/@postgres-language-server/cli": {
"name": "@postgres-language-server/cli",
"bin": {
"postgres-language-server": "bin/postgres-language-server",
},
"optionalDependencies": {
"@postgres-language-server/cli-aarch64-apple-darwin": "<placeholder>",
"@postgres-language-server/cli-aarch64-linux-gnu": "<placeholder>",
"@postgres-language-server/cli-aarch64-windows-msvc": "<placeholder>",
"@postgres-language-server/cli-x86_64-apple-darwin": "<placeholder>",
"@postgres-language-server/cli-x86_64-linux-gnu": "<placeholder>",
"@postgres-language-server/cli-x86_64-linux-musl": "<placeholder>",
"@postgres-language-server/cli-x86_64-windows-msvc": "<placeholder>",
},
},
"packages/@postgrestools/backend-jsonrpc": {
"name": "@postgrestools/backend-jsonrpc",
"optionalDependencies": {
Expand Down Expand Up @@ -57,6 +83,24 @@

"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],

"@postgres-language-server/backend-jsonrpc": ["@postgres-language-server/backend-jsonrpc@workspace:packages/@postgres-language-server/backend-jsonrpc"],

"@postgres-language-server/cli": ["@postgres-language-server/cli@workspace:packages/@postgres-language-server/cli"],

"@postgres-language-server/cli-aarch64-apple-darwin": ["@postgres-language-server/cli-aarch64-apple-darwin@0.17.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-0Umsb4yuHyI8D9oZkkpa6H4aZXMAAMLa7qbOrHRP9IMML4mKp5B9wkCiyvgd1ZKRP82UQBZnVjh53AGXky4Jdw=="],

"@postgres-language-server/cli-aarch64-linux-gnu": ["@postgres-language-server/cli-aarch64-linux-gnu@0.17.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-ye8IQLNLyJK4hR5tx8rKh1tEO1Sb+Dw574cbBG++K46LTZAdRq5/IQrNkIfDzFdgU+HMK3QYfm54cgudYeVVlQ=="],

"@postgres-language-server/cli-aarch64-windows-msvc": ["@postgres-language-server/cli-aarch64-windows-msvc@0.17.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-FkOjgvN7+vq0RvwVD/effFjKgH1mrAVMnV+3eO9bdZ6jCXpPesGOyCvyhf59IzoqmvIMyEeKJzjOUcXxWPmdZg=="],

"@postgres-language-server/cli-x86_64-apple-darwin": ["@postgres-language-server/cli-x86_64-apple-darwin@0.17.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-B79kZ9tz8fvGihv4W/cyCFzw5Wz95HlqF1hnNTBocJtf8Nvo9h6RDWoUEYliBjRp37gcdV945ZjV2RHHxdKMTw=="],

"@postgres-language-server/cli-x86_64-linux-gnu": ["@postgres-language-server/cli-x86_64-linux-gnu@0.17.1", "", { "os": "linux", "cpu": "x64" }, "sha512-lh5Lg/Cc18+232NRd1OZqdpJzuJMW6lrwkC6RKYiiTzxUfRq7uRV8qI0NNnp5cyKiyDO90cpQQ8fjepTaMzh9A=="],

"@postgres-language-server/cli-x86_64-linux-musl": ["@postgres-language-server/cli-x86_64-linux-musl@0.17.1", "", { "os": "linux", "cpu": "x64" }, "sha512-YH5Znq0urRUxtdsbyDu6Dcg5x9qhgDqTl7gCVY/LmVrPnHfP2I6gU/TJT21B5sDTSadjwZ73AbXimLmlwG6HPA=="],

"@postgres-language-server/cli-x86_64-windows-msvc": ["@postgres-language-server/cli-x86_64-windows-msvc@0.17.1", "", { "os": "win32", "cpu": "x64" }, "sha512-o2uIx0Vi3iEBFKKnz024JicgovJZWpM9G4WbQxf3r9IQlZPWvDXknlX7rNPQDnQTFRIUg8bpjZpjEvDFHMmuGg=="],

"@postgrestools/backend-jsonrpc": ["@postgrestools/backend-jsonrpc@workspace:packages/@postgrestools/backend-jsonrpc"],

"@postgrestools/cli-aarch64-apple-darwin": ["@postgrestools/cli-aarch64-apple-darwin@0.13.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-LqgpsiupuNR1m8rSqcMdwep1UsSG5z7RZ9MYHODBB0+AsN/e1YzcyutqGeKs+AfDBdKdv7QmSbpf7KruBYL+tg=="],
Expand Down
24 changes: 12 additions & 12 deletions crates/pgls_analyse/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,34 @@ impl ActionCategory {
match self {
ActionCategory::QuickFix(tag) => {
if tag.is_empty() {
Cow::Borrowed("quickfix.pgt")
Cow::Borrowed("quickfix.pgls")
} else {
Cow::Owned(format!("quickfix.pgt.{tag}"))
Cow::Owned(format!("quickfix.pgls.{tag}"))
}
}

ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pgt"),
ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.pgls"),
ActionCategory::Refactor(RefactorKind::Extract) => {
Cow::Borrowed("refactor.extract.pgt")
Cow::Borrowed("refactor.extract.pgls")
}
ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.pgt"),
ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.pgls"),
ActionCategory::Refactor(RefactorKind::Rewrite) => {
Cow::Borrowed("refactor.rewrite.pgt")
Cow::Borrowed("refactor.rewrite.pgls")
}
ActionCategory::Refactor(RefactorKind::Other(tag)) => {
Cow::Owned(format!("refactor.{tag}.pgt"))
Cow::Owned(format!("refactor.{tag}.pgls"))
}

ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pgt"),
ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.pgt"),
ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.pgls"),
ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.pgls"),
ActionCategory::Source(SourceActionKind::OrganizeImports) => {
Cow::Borrowed("source.organizeImports.pgt")
Cow::Borrowed("source.organizeImports.pgls")
}
ActionCategory::Source(SourceActionKind::Other(tag)) => {
Cow::Owned(format!("source.{tag}.pgt"))
Cow::Owned(format!("source.{tag}.pgls"))
}

ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pgt")),
ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.pgls")),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/pgls_cli/src/cli_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct CliOptions {

#[bpaf(
env("PGT_LOG_LEVEL"),
env("PGLS_LOG_LEVEL"),
long("log-level"),
argument("none|debug|info|warn|error"),
fallback(LoggingLevel::default()),
Expand Down
20 changes: 10 additions & 10 deletions crates/pgls_cli/src/commands/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ async fn start_lsp_proxy(
/// 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
/// `pgt-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary
/// `pgls-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary
/// directory)
fn setup_tracing_subscriber(
log_path: Option<PathBuf>,
log_file_name_prefix: Option<String>,
log_level: Option<String>,
log_kind: Option<String>,
) {
let pgls_log_path = log_path.unwrap_or(pgls_fs::ensure_cache_dir().join("pgt-logs"));
let pgls_log_path = log_path.unwrap_or(pgls_fs::ensure_cache_dir().join("pgls-logs"));

let appender_builder = tracing_appender::rolling::RollingFileAppender::builder();

Expand All @@ -200,7 +200,7 @@ fn setup_tracing_subscriber(
.build(pgls_log_path)
.expect("Failed to start the logger for the daemon.");

let filter = PgtLoggingFilter::from(log_level);
let filter = PgLSLoggingFilter::from(log_level);

let log_kind = log_kind.unwrap_or("hierarchical".into());

Expand Down Expand Up @@ -241,16 +241,16 @@ pub fn default_pgls_log_path() -> PathBuf {
.or_else(|| env.pgls_log_path.value())
{
Some(directory) => PathBuf::from(directory),
None => pgls_fs::ensure_cache_dir().join("pgt-logs"),
None => pgls_fs::ensure_cache_dir().join("pgls-logs"),
}
}

/// Tracing Filter with two rules:
/// For all crates starting with pgt*, use `PGT_LOG_LEVEL` or CLI option or "info" as default
/// For all crates starting with pgls*, use `PGLS_LOG_LEVEL` or CLI option or "info" as default
/// For all other crates, use "info"
struct PgtLoggingFilter(LevelFilter);
struct PgLSLoggingFilter(LevelFilter);

impl From<Option<String>> for PgtLoggingFilter {
impl From<Option<String>> for PgLSLoggingFilter {
fn from(value: Option<String>) -> Self {
Self(
value
Expand All @@ -269,9 +269,9 @@ impl From<Option<String>> for PgtLoggingFilter {
}
}

impl PgtLoggingFilter {
impl PgLSLoggingFilter {
fn is_enabled(&self, meta: &Metadata<'_>) -> bool {
let filter = if meta.target().starts_with("pgt") {
let filter = if meta.target().starts_with("pgls") {
self.0
} else {
LevelFilter::INFO
Expand All @@ -281,7 +281,7 @@ impl PgtLoggingFilter {
}
}

impl<S> Filter<S> for PgtLoggingFilter {
impl<S> Filter<S> for PgLSLoggingFilter {
fn enabled(&self, meta: &Metadata<'_>, _cx: &Context<'_, S>) -> bool {
self.is_enabled(meta)
}
Expand Down
26 changes: 24 additions & 2 deletions crates/pgls_cli/src/commands/dblint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::time::Instant;

use crate::cli_options::CliOptions;
use crate::reporter::Report;
use crate::{CliDiagnostic, CliSession, VcsIntegration};
use pgls_configuration::PartialConfiguration;
use pgls_diagnostics::Error;
use pgls_workspace::features::diagnostics::{PullDatabaseDiagnosticsParams, PullDiagnosticsResult};

pub fn dblint(
mut session: CliSession,
Expand All @@ -10,9 +14,27 @@ pub fn dblint(
) -> Result<(), CliDiagnostic> {
let configuration = session.prepare_with_config(cli_options, cli_configuration)?;
session.setup_workspace(configuration, VcsIntegration::Disabled)?;
let workspace = session.workspace();

let max_diagnostics = if cli_options.reporter.is_default() {
cli_options.max_diagnostics.into()
} else {
u32::MAX
};

let start = Instant::now();

let PullDiagnosticsResult {
diagnostics,
skipped_diagnostics,
} = workspace.pull_db_diagnostics(PullDatabaseDiagnosticsParams { max_diagnostics })?;

// TODO: Implement actual dblint logic here
let report = Report::new(vec![], std::time::Duration::new(0, 0), 0, None);
let report = Report::new(
diagnostics.into_iter().map(Error::from).collect(),
start.elapsed(),
skipped_diagnostics,
None,
);

session.report("dblint", cli_options, &report)
}
8 changes: 4 additions & 4 deletions crates/pgls_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub enum PgLSCommand {
long("log-path"),
argument("PATH"),
hide_usage,
fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")),
fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")),
)]
log_path: PathBuf,
/// Allows to set a custom file path to the configuration file,
Expand Down Expand Up @@ -136,7 +136,7 @@ pub enum PgLSCommand {
long("log-path"),
argument("PATH"),
hide_usage,
fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")),
fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")),
)]
log_path: PathBuf,
/// Allows to set a custom file path to the configuration file,
Expand Down Expand Up @@ -178,11 +178,11 @@ pub enum PgLSCommand {
long("log-path"),
argument("PATH"),
hide_usage,
fallback(pgls_fs::ensure_cache_dir().join("pgt-logs")),
fallback(pgls_fs::ensure_cache_dir().join("pgls-logs")),
)]
log_path: PathBuf,

/// Allows to change the log level. Default is debug. This will only affect "pgt*" crates. All others are logged with info level.
/// Allows to change the log level. Default is debug. This will only affect "pgls*" crates. All others are logged with info level.
#[bpaf(
env("PGT_LOG_LEVEL"),
env("PGLS_LOG_LEVEL"),
Expand Down
2 changes: 1 addition & 1 deletion crates/pgls_cli/src/execute/process_file/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) fn check_with_guard<'ctx>(
.into_iter()
.map(Error::from)
.collect(),
skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics as u32,
skipped_diagnostics: pull_diagnostics_result.skipped_diagnostics,
});
}

Expand Down
4 changes: 2 additions & 2 deletions crates/pgls_cli/src/execute/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) fn traverse(

let (duration, evaluated_paths, diagnostics) = thread::scope(|s| {
let handler = thread::Builder::new()
.name(String::from("pgt::console"))
.name(String::from("pgls::console"))
.spawn_scoped(s, || printer.run(receiver, recv_files))
.expect("failed to spawn console thread");

Expand Down Expand Up @@ -121,7 +121,7 @@ fn init_thread_pool() {
static INIT_ONCE: Once = Once::new();
INIT_ONCE.call_once(|| {
rayon::ThreadPoolBuilder::new()
.thread_name(|index| format!("pgt::worker_{index}"))
.thread_name(|index| format!("pgls::worker_{index}"))
.build_global()
.expect("failed to initialize the global thread pool");
});
Expand Down
6 changes: 3 additions & 3 deletions crates/pgls_cli/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,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 `pgt`
/// - All spans and events at level debug in crates whose name starts with `pgls`
struct LoggingFilter {
level: LoggingLevel,
}

/// Tracing filter used for spans emitted by `pgt*` crates
/// Tracing filter used for spans emitted by `pgls*` crates
const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) {
LevelFilter::TRACE
} else {
Expand All @@ -106,7 +106,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("pgt") {
let filter = if meta.target().starts_with("pgls") {
if let Some(level) = self.level.to_filter_level() {
level
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/pgls_cli/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl WorkspaceTransport for SocketTransport {

self.pending_requests.insert(request.id, send);

let is_shutdown = request.method == "pgt/shutdown";
let is_shutdown = request.method == "pgls/shutdown";

let request = JsonRpcRequest {
jsonrpc: Cow::Borrowed("2.0"),
Expand Down
4 changes: 2 additions & 2 deletions crates/pgls_cli/src/service/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing::{Instrument, debug, info};
/// Returns the filesystem path of the global socket used to communicate with
/// the server daemon
fn get_socket_name() -> PathBuf {
pgls_fs::ensure_cache_dir().join(format!("pgt-socket-{}", pgls_configuration::VERSION))
pgls_fs::ensure_cache_dir().join(format!("pgls-socket-{}", pgls_configuration::VERSION))
}

#[allow(dead_code)]
Expand All @@ -32,7 +32,7 @@ pub(crate) fn enumerate_pipes() -> io::Result<impl Iterator<Item = String>> {
let file_name = entry.file_name()?;
let file_name = file_name.to_str()?;

let version = file_name.strip_prefix("pgt-socket")?;
let version = file_name.strip_prefix("pgls-socket")?;
if version.is_empty() {
Some(String::new())
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/pgls_cli/src/service/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\pgt-service-{}", pgls_configuration::VERSION)
format!(r"\\.\pipe\pgls-service-{}", pgls_configuration::VERSION)
}

#[allow(dead_code)]
Expand All @@ -35,7 +35,7 @@ pub(crate) fn enumerate_pipes() -> io::Result<impl Iterator<Item = String>> {
let file_name = entry.file_name()?;
let file_name = file_name.to_str()?;

let version = file_name.strip_prefix("pgt-service")?;
let version = file_name.strip_prefix("pgls-service")?;
if version.is_empty() {
Some(String::new())
} else {
Expand Down
Loading