Skip to content

Commit 3b078a0

Browse files
so far
2 parents 0c4ab8d + 1abf019 commit 3b078a0

File tree

761 files changed

+722641
-2501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

761 files changed

+722641
-2501
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ jobs:
207207
with:
208208
install-lib: false
209209
- name: Build main binary
210-
run: cargo build -p pgt_cli --release
210+
run: cargo build -p pgls_cli --release
211211
- name: Setup Bun
212212
uses: oven-sh/setup-bun@v2
213213
- name: Install JS dependencies

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
8686

8787
- name: 🛠️ Run Build
88-
run: cargo build -p pgt_cli --release --target ${{ matrix.config.target }}
88+
run: cargo build -p pgls_cli --release --target ${{ matrix.config.target }}
8989
env:
9090
# Strip all debug symbols from the resulting binaries
9191
RUSTFLAGS: "-C strip=symbols -C codegen-units=1"

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[submodule "crates/pgt_query/vendor/libpg_query"]
2-
path = crates/pgt_query/vendor/libpg_query
1+
[submodule "crates/pgls_query/vendor/libpg_query"]
2+
path = crates/pgls_query/vendor/libpg_query
33
url = https://github.com/pganalyze/libpg_query.git
44
branch = 17-latest

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"postgrestools.bin": "./target/debug/postgrestools"
2+
"postgres-language-server.bin": "./target/debug/postgres-language-server"
33
}

AGENTS.md

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ just test
2727
# or: cargo test run --no-fail-fast
2828

2929
# Test specific crate
30-
just test-crate pgt_lsp
30+
just test-crate pgls_lsp
3131

3232
# Run doc tests
3333
just test-doc
@@ -62,64 +62,64 @@ just new-crate <name>
6262
```
6363

6464
### CLI Usage
65-
The main CLI binary is `postgrestools`:
65+
The main CLI binary is `postgres-language-server` (legacy name: `postgrestools`):
6666
```bash
67-
cargo run -p pgt_cli -- check file.sql
67+
cargo run -p pgls_cli -- check file.sql
6868
# or after building:
69-
./target/release/postgrestools check file.sql
69+
./target/release/postgres-language-server check file.sql
7070
```
7171

7272
## Architecture
7373

7474
### Crate Structure
75-
The project uses a modular Rust workspace with crates prefixed with `pgt_`:
75+
The project uses a modular Rust workspace with crates prefixed with `pgls_`:
7676

7777
**Core Infrastructure:**
78-
- `pgt_workspace` - Main API and workspace management
79-
- `pgt_lsp` - Language Server Protocol implementation
80-
- `pgt_cli` - Command-line interface
81-
- `pgt_fs` - Virtual file system abstraction
82-
- `pgt_configuration` - Configuration management
78+
- `pgls_workspace` - Main API and workspace management
79+
- `pgls_lsp` - Language Server Protocol implementation
80+
- `pgls_cli` - Command-line interface
81+
- `pgls_fs` - Virtual file system abstraction
82+
- `pgls_configuration` - Configuration management
8383

8484
**Parser and Language Processing:**
85-
- `pgt_query` - Postgres query parsing (wraps libpg_query)
86-
- `pgt_lexer` - SQL tokenizer with whitespace handling
87-
- `pgt_statement_splitter` - Splits source into individual statements
88-
- `pgt_treesitter` - Tree-sitter integration for additional parsing
85+
- `pgls_query` - Postgres query parsing (wraps libpg_query)
86+
- `pgls_lexer` - SQL tokenizer with whitespace handling
87+
- `pgls_statement_splitter` - Splits source into individual statements
88+
- `pgls_treesitter` - Tree-sitter integration for additional parsing
8989

9090
**Features:**
91-
- `pgt_completions` - Autocompletion engine
92-
- `pgt_hover` - Hover information provider
93-
- `pgt_analyser` & `pgt_analyse` - Linting and analysis framework
94-
- `pgt_typecheck` - Type checking via EXPLAIN
95-
- `pgt_schema_cache` - In-memory database schema representation
91+
- `pgls_completions` - Autocompletion engine
92+
- `pgls_hover` - Hover information provider
93+
- `pgls_analyser` & `pgls_analyse` - Linting and analysis framework
94+
- `pgls_typecheck` - Type checking via EXPLAIN
95+
- `pgls_schema_cache` - In-memory database schema representation
9696

9797
**Utilities:**
98-
- `pgt_diagnostics` - Error and warning reporting
99-
- `pgt_console` - Terminal output and formatting
100-
- `pgt_text_edit` - Text manipulation utilities
101-
- `pgt_suppressions` - Rule suppression handling
98+
- `pgls_diagnostics` - Error and warning reporting
99+
- `pgls_console` - Terminal output and formatting
100+
- `pgls_text_edit` - Text manipulation utilities
101+
- `pgls_suppressions` - Rule suppression handling
102102

103103
### TypeScript Packages
104104
Located in `packages/` and `editors/`:
105105
- VSCode extension in `editors/code/`
106-
- Backend JSON-RPC bridge in `packages/@postgrestools/backend-jsonrpc/`
107-
- Main TypeScript package in `packages/@postgrestools/postgrestools/`
106+
- Backend JSON-RPC bridge in `packages/@postgres-language-server/backend-jsonrpc/` (legacy: `packages/@postgrestools/backend-jsonrpc/`)
107+
- Main TypeScript package in `packages/@postgres-language-server/postgres-language-server/` (legacy: `packages/@postgrestools/postgrestools/`)
108108

109109
### Database Integration
110110
The server connects to a Postgres database to build an in-memory schema cache containing tables, columns, functions, and type information. This enables accurate autocompletion and type checking.
111111

112112
### Statement Processing Flow
113113
1. Input source code is split into individual SQL statements
114-
2. Each statement is parsed using libpg_query (via `pgt_query`)
114+
2. Each statement is parsed using libpg_query (via `pgls_query`)
115115
3. Statements are analyzed against the schema cache
116116
4. Results are cached and updated incrementally on file changes
117117

118118
## Testing
119119

120120
### Test Data Location
121-
- SQL test cases: `crates/pgt_statement_splitter/tests/data/`
122-
- Analyzer test specs: `crates/pgt_analyser/tests/specs/`
121+
- SQL test cases: `crates/pgls_statement_splitter/tests/data/`
122+
- Analyzer test specs: `crates/pgls_analyser/tests/specs/`
123123
- Example SQL files: `example/`, `test.sql`
124124

125125
### Snapshot Testing
@@ -145,11 +145,26 @@ cargo insta review
145145
## Development Notes
146146

147147
### Code Generation
148-
Many parser structures are generated from PostgreSQL's protobuf definitions using procedural macros in `pgt_query_macros`. Run `just gen-lint` after modifying analyzer rules or configurations.
148+
Many parser structures are generated from PostgreSQL's protobuf definitions using procedural macros in `pgls_query_macros`. Run `just gen-lint` after modifying analyzer rules or configurations.
149149

150150
### Database Schema
151-
The `pgt_schema_cache` crate contains SQL queries in `src/queries/` that introspect the database schema to build the in-memory cache.
151+
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>`.

0 commit comments

Comments
 (0)