Skip to content

Commit a072fe1

Browse files
committed
chore: rename PgTPath
1 parent 1ff2ee1 commit a072fe1

File tree

24 files changed

+132
-117
lines changed

24 files changed

+132
-117
lines changed

AGENTS.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,21 @@ Many parser structures are generated from PostgreSQL's protobuf definitions usin
150150
### Database Schema
151151
The `pgls_schema_cache` crate contains SQL queries in `src/queries/` that introspect the database schema to build the in-memory cache.
152152

153-
### Multi-Platform Support
153+
### Code Refactoring Tools
154+
The project has `ast-grep` available for advanced code search and refactoring tasks. ast-grep is a structural search/replace tool that understands code syntax, making it useful for:
155+
- Renaming types, functions, or variables across the codebase
156+
- Finding and replacing code patterns
157+
- Performing structural code transformations
158+
159+
Example usage:
160+
```bash
161+
# Search for a pattern
162+
ast-grep --pattern 'struct $NAME { $$$FIELDS }'
163+
164+
# Replace a pattern across files
165+
ast-grep --pattern 'OldType' --rewrite 'NewType' --update-all
166+
```
167+
168+
### Multi-Platform Support
154169
The project includes platform-specific allocators and build configurations for Windows, macOS, and Linux.
155170
- Seeing the Treesitter tree for an SQL query can be helpful to debug and implement features. To do this, create a file with an SQL query, and run `just tree-print <file.sql>`.

crates/pgls_cli/src/execute/process_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::execute::config::ExecutionMode;
55
use crate::execute::walk::TraversalOptions;
66
use check::check_file;
77
use pgls_diagnostics::Error;
8-
use pgls_fs::PgTPath;
8+
use pgls_fs::PgLSPath;
99
use std::marker::PhantomData;
1010
use std::ops::Deref;
1111

@@ -103,7 +103,7 @@ impl<'ctx, 'app> Deref for SharedTraversalOptions<'ctx, 'app> {
103103
/// diagnostics were emitted, or compare the formatted code with the original
104104
/// content of the file and emit a diff or write the new content to the disk if
105105
/// write mode is enabled
106-
pub(crate) fn process_file(ctx: &TraversalOptions, pgls_path: &PgTPath) -> FileResult {
106+
pub(crate) fn process_file(ctx: &TraversalOptions, pgls_path: &PgLSPath) -> FileResult {
107107
tracing::trace_span!("process_file", path = ?pgls_path).in_scope(move || {
108108
let shared_context = &SharedTraversalOptions::new(ctx);
109109

crates/pgls_cli/src/execute/process_file/workspace_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::execute::diagnostics::{ResultExt, ResultIoExt};
22
use crate::execute::process_file::SharedTraversalOptions;
33
use pgls_diagnostics::{Error, category};
4-
use pgls_fs::{File, OpenOptions, PgTPath};
4+
use pgls_fs::{File, OpenOptions, PgLSPath};
55
use pgls_workspace::workspace::{FileGuard, OpenFileParams};
66
use pgls_workspace::{Workspace, WorkspaceError};
77
use std::path::{Path, PathBuf};
@@ -24,7 +24,7 @@ impl<'ctx, 'app> WorkspaceFile<'ctx, 'app> {
2424
ctx: &SharedTraversalOptions<'ctx, 'app>,
2525
path: &Path,
2626
) -> Result<Self, Error> {
27-
let pgls_path = PgTPath::new(path);
27+
let pgls_path = PgLSPath::new(path);
2828
let open_options = OpenOptions::default()
2929
.read(true)
3030
.write(ctx.config.allows_writes());

crates/pgls_cli/src/execute/walk.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::reporter::{Report, TraversalData};
55
use crate::{CliDiagnostic, CliSession};
66
use crossbeam::channel::{Receiver, Sender, unbounded};
77
use pgls_diagnostics::{DiagnosticExt, Error, Resource};
8-
use pgls_fs::{FileSystem, PathInterner, PgTPath};
8+
use pgls_fs::{FileSystem, PathInterner, PgLSPath};
99
use pgls_fs::{TraversalContext, TraversalScope};
1010
use pgls_workspace::dome::Dome;
1111
use pgls_workspace::workspace::IsPathIgnoredParams;
@@ -133,7 +133,7 @@ fn traverse_inputs(
133133
fs: &dyn FileSystem,
134134
inputs: Vec<OsString>,
135135
ctx: &TraversalOptions,
136-
) -> (Duration, BTreeSet<PgTPath>) {
136+
) -> (Duration, BTreeSet<PgLSPath>) {
137137
let start = Instant::now();
138138
fs.traversal(Box::new(move |scope: &dyn TraversalScope| {
139139
for input in inputs {
@@ -299,11 +299,11 @@ pub(crate) struct TraversalOptions<'ctx, 'app> {
299299
pub(crate) remaining_diagnostics: &'ctx AtomicU32,
300300

301301
/// List of paths that should be processed
302-
pub(crate) evaluated_paths: RwLock<BTreeSet<PgTPath>>,
302+
pub(crate) evaluated_paths: RwLock<BTreeSet<PgLSPath>>,
303303
}
304304

305305
impl TraversalOptions<'_, '_> {
306-
pub(crate) fn increment_changed(&self, path: &PgTPath) {
306+
pub(crate) fn increment_changed(&self, path: &PgLSPath) {
307307
self.changed.fetch_add(1, Ordering::Relaxed);
308308
self.evaluated_paths
309309
.write()
@@ -329,15 +329,15 @@ impl TraversalContext for TraversalOptions<'_, '_> {
329329
&self.interner
330330
}
331331

332-
fn evaluated_paths(&self) -> BTreeSet<PgTPath> {
332+
fn evaluated_paths(&self) -> BTreeSet<PgLSPath> {
333333
self.evaluated_paths.read().unwrap().clone()
334334
}
335335

336336
fn push_diagnostic(&self, error: Error) {
337337
self.push_message(error);
338338
}
339339

340-
fn can_handle(&self, pgls_path: &PgTPath) -> bool {
340+
fn can_handle(&self, pgls_path: &PgLSPath) -> bool {
341341
let path = pgls_path.as_path();
342342

343343
let is_valid_file = self.fs.path_is_file(path)
@@ -372,22 +372,22 @@ impl TraversalContext for TraversalOptions<'_, '_> {
372372
true
373373
}
374374

375-
fn handle_path(&self, path: PgTPath) {
375+
fn handle_path(&self, path: PgLSPath) {
376376
handle_file(self, &path)
377377
}
378378

379-
fn store_path(&self, path: PgTPath) {
379+
fn store_path(&self, path: PgLSPath) {
380380
self.evaluated_paths
381381
.write()
382382
.unwrap()
383-
.insert(PgTPath::new(path.as_path()));
383+
.insert(PgLSPath::new(path.as_path()));
384384
}
385385
}
386386

387387
/// This function wraps the [process_file] function implementing the traversal
388388
/// in a [catch_unwind] block and emit diagnostics in case of error (either the
389389
/// traversal function returns Err or panics)
390-
fn handle_file(ctx: &TraversalOptions, path: &PgTPath) {
390+
fn handle_file(ctx: &TraversalOptions, path: &PgLSPath) {
391391
match catch_unwind(move || process_file(ctx, path)) {
392392
Ok(Ok(FileStatus::Changed)) => {
393393
ctx.increment_changed(path);

crates/pgls_cli/src/reporter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::cli_options::{CliOptions, CliReporter};
77
use crate::diagnostics::CliDiagnostic;
88
use pgls_console::Console;
99
use pgls_diagnostics::{Error, Severity};
10-
use pgls_fs::PgTPath;
10+
use pgls_fs::PgLSPath;
1111
use std::collections::BTreeSet;
1212
use std::path::PathBuf;
1313
use std::time::Duration;
@@ -54,7 +54,7 @@ impl From<CliReporter> for ReportMode {
5454

5555
#[derive(Debug)]
5656
pub struct TraversalData {
57-
pub evaluated_paths: BTreeSet<PgTPath>,
57+
pub evaluated_paths: BTreeSet<PgLSPath>,
5858
pub changed: usize,
5959
pub unchanged: usize,
6060
pub matches: usize,

crates/pgls_cli/src/reporter/terminal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use pgls_console::fmt::Formatter;
44
use pgls_console::{Console, ConsoleExt, fmt, markup};
55
use pgls_diagnostics::advice::ListAdvice;
66
use pgls_diagnostics::{Diagnostic, Error, PrintDiagnostic};
7-
use pgls_fs::PgTPath;
7+
use pgls_fs::PgLSPath;
88
use std::borrow::Cow;
99
use std::collections::BTreeSet;
1010

@@ -51,7 +51,7 @@ fn log_diagnostics(console: &mut dyn Console, config: &ReportConfig, diagnostics
5151
}
5252
}
5353

54-
fn log_evaluated_paths(console: &mut dyn Console, evaluated_paths: &BTreeSet<PgTPath>) {
54+
fn log_evaluated_paths(console: &mut dyn Console, evaluated_paths: &BTreeSet<PgLSPath>) {
5555
let evaluated_paths_diagnostic = EvaluatedPathsDiagnostic {
5656
advice: ListAdvice {
5757
list: evaluated_paths

crates/pgls_fs/src/fs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{PathInterner, PgTPath};
1+
use crate::{PathInterner, PgLSPath};
22
pub use memory::{ErrorEntry, MemoryFileSystem};
33
pub use os::OsFileSystem;
44
use oxc_resolver::{Resolution, ResolveError};
@@ -313,18 +313,18 @@ pub trait TraversalContext: Sync {
313313
/// Checks if the traversal context can handle a particular path, used as
314314
/// an optimization to bail out of scheduling a file handler if it wouldn't
315315
/// be able to process the file anyway
316-
fn can_handle(&self, path: &PgTPath) -> bool;
316+
fn can_handle(&self, path: &PgLSPath) -> bool;
317317

318318
/// This method will be called by the traversal for each file it finds
319319
/// where [TraversalContext::can_handle] returned true
320-
fn handle_path(&self, path: PgTPath);
320+
fn handle_path(&self, path: PgLSPath);
321321

322322
/// This method will be called by the traversal for each file it finds
323323
/// where [TraversalContext::store_path] returned true
324-
fn store_path(&self, path: PgTPath);
324+
fn store_path(&self, path: PgLSPath);
325325

326326
/// Returns the paths that should be handled
327-
fn evaluated_paths(&self) -> BTreeSet<PgTPath>;
327+
fn evaluated_paths(&self) -> BTreeSet<PgLSPath>;
328328
}
329329

330330
impl<T> FileSystem for Arc<T>

crates/pgls_fs/src/fs/memory.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use parking_lot::{Mutex, RawMutex, RwLock, lock_api::ArcMutexGuard};
1111
use pgls_diagnostics::{Error, Severity};
1212

1313
use crate::fs::OpenOptions;
14-
use crate::{FileSystem, PgTPath, TraversalContext, TraversalScope};
14+
use crate::{FileSystem, PgLSPath, TraversalContext, TraversalScope};
1515

1616
use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic};
1717

@@ -307,7 +307,7 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> {
307307

308308
if should_process_file {
309309
let _ = ctx.interner().intern_path(path.into());
310-
let pgls_path = PgTPath::new(path);
310+
let pgls_path = PgLSPath::new(path);
311311
if !ctx.can_handle(&pgls_path) {
312312
continue;
313313
}
@@ -338,7 +338,7 @@ impl<'scope> TraversalScope<'scope> for MemoryTraversalScope<'scope> {
338338
}
339339

340340
fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) {
341-
context.handle_path(PgTPath::new(path));
341+
context.handle_path(PgLSPath::new(path));
342342
}
343343
}
344344

@@ -354,7 +354,7 @@ mod tests {
354354
use parking_lot::Mutex;
355355
use pgls_diagnostics::Error;
356356

357-
use crate::{FileSystem, MemoryFileSystem, PathInterner, PgTPath, TraversalContext};
357+
use crate::{FileSystem, MemoryFileSystem, PathInterner, PgLSPath, TraversalContext};
358358
use crate::{OpenOptions, fs::FileSystemExt};
359359

360360
#[test]
@@ -521,7 +521,7 @@ mod tests {
521521

522522
struct TestContext {
523523
interner: PathInterner,
524-
visited: Mutex<BTreeSet<PgTPath>>,
524+
visited: Mutex<BTreeSet<PgLSPath>>,
525525
}
526526

527527
impl TraversalContext for TestContext {
@@ -533,19 +533,19 @@ mod tests {
533533
panic!("unexpected error {err:?}")
534534
}
535535

536-
fn can_handle(&self, _: &PgTPath) -> bool {
536+
fn can_handle(&self, _: &PgLSPath) -> bool {
537537
true
538538
}
539539

540-
fn handle_path(&self, path: PgTPath) {
540+
fn handle_path(&self, path: PgLSPath) {
541541
self.visited.lock().insert(path.to_written());
542542
}
543543

544-
fn store_path(&self, path: PgTPath) {
544+
fn store_path(&self, path: PgLSPath) {
545545
self.visited.lock().insert(path);
546546
}
547547

548-
fn evaluated_paths(&self) -> BTreeSet<PgTPath> {
548+
fn evaluated_paths(&self) -> BTreeSet<PgLSPath> {
549549
let lock = self.visited.lock();
550550
lock.clone()
551551
}
@@ -566,8 +566,8 @@ mod tests {
566566
swap(&mut visited, ctx.visited.get_mut());
567567

568568
assert_eq!(visited.len(), 2);
569-
assert!(visited.contains(&PgTPath::new("dir1/file1")));
570-
assert!(visited.contains(&PgTPath::new("dir1/file2")));
569+
assert!(visited.contains(&PgLSPath::new("dir1/file1")));
570+
assert!(visited.contains(&PgLSPath::new("dir1/file2")));
571571

572572
// Traverse a single file
573573
fs.traversal(Box::new(|scope| {
@@ -578,6 +578,6 @@ mod tests {
578578
swap(&mut visited, ctx.visited.get_mut());
579579

580580
assert_eq!(visited.len(), 1);
581-
assert!(visited.contains(&PgTPath::new("dir2/file2")));
581+
assert!(visited.contains(&PgLSPath::new("dir2/file2")));
582582
}
583583
}

crates/pgls_fs/src/fs/os.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use super::{BoxedTraversal, ErrorKind, File, FileSystemDiagnostic};
33
use crate::fs::OpenOptions;
44
use crate::{
5-
FileSystem, PgTPath,
5+
FileSystem, PgLSPath,
66
fs::{TraversalContext, TraversalScope},
77
};
88
use oxc_resolver::{Resolution, ResolveError, ResolveOptions, Resolver};
@@ -211,7 +211,7 @@ impl<'scope> TraversalScope<'scope> for OsTraversalScope<'scope> {
211211

212212
fn handle(&self, context: &'scope dyn TraversalContext, path: PathBuf) {
213213
self.scope.spawn(move |_| {
214-
context.handle_path(PgTPath::new(path));
214+
context.handle_path(PgLSPath::new(path));
215215
});
216216
}
217217
}
@@ -289,7 +289,7 @@ fn handle_any_file<'scope>(
289289
}
290290

291291
if file_type.is_symlink() {
292-
if !ctx.can_handle(&PgTPath::new(path.clone())) {
292+
if !ctx.can_handle(&PgLSPath::new(path.clone())) {
293293
return;
294294
}
295295
let Ok((target_path, target_file_type)) = expand_symbolic_link(path.clone(), ctx) else {
@@ -320,7 +320,7 @@ fn handle_any_file<'scope>(
320320
if let Some(file_name) = path.file_name() {
321321
let new_origin_path = old_origin_path.join(file_name);
322322
origin_path = Some(new_origin_path.clone());
323-
PgTPath::new(new_origin_path)
323+
PgLSPath::new(new_origin_path)
324324
} else {
325325
ctx.push_diagnostic(Error::from(FileSystemDiagnostic {
326326
path: path.to_string_lossy().to_string(),
@@ -330,7 +330,7 @@ fn handle_any_file<'scope>(
330330
return;
331331
}
332332
} else {
333-
PgTPath::new(&path)
333+
PgLSPath::new(&path)
334334
};
335335

336336
// Performing this check here let's us skip unsupported
@@ -351,7 +351,7 @@ fn handle_any_file<'scope>(
351351

352352
if file_type.is_file() {
353353
scope.spawn(move |_| {
354-
ctx.store_path(PgTPath::new(path));
354+
ctx.store_path(PgLSPath::new(path));
355355
});
356356
return;
357357
}

crates/pgls_fs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod path;
77

88
pub use dir::ensure_cache_dir;
99
pub use interner::PathInterner;
10-
pub use path::PgTPath;
10+
pub use path::PgLSPath;
1111

1212
pub use fs::{
1313
AutoSearchResult, ConfigName, ErrorEntry, File, FileSystem, FileSystemDiagnostic,

0 commit comments

Comments
 (0)