Skip to content

Commit 838fade

Browse files
Ajit Pratap Singhclaude
authored andcommitted
fix: complete implementation of PR #132 review feedback
HIGH Priority: - Add 60+ unit tests for command functions, validation, error handling - Enhance error messaging with platform-specific guidance - Add configuration validation with helpful suggestions MEDIUM Priority: - Add opt-in telemetry with user consent (disabled by default) - Enhance TextMate grammar with database-specific features (MySQL, SQL Server, Oracle, SQLite specific syntax) - Make timeouts fully configurable via settings LOW Priority: - Add workspace settings support (resource/window scopes) - Enhance documentation with 10+ troubleshooting scenarios - Add performance metrics collection for LSP operations New files: - src/utils/validation.ts - Configuration validation - src/utils/errors.ts - Enhanced error messages - src/utils/telemetry.ts - Opt-in telemetry - src/utils/metrics.ts - Performance metrics - src/test/unit/commands.test.ts - Unit tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 368df3d commit 838fade

10 files changed

Lines changed: 2863 additions & 105 deletions

File tree

vscode-extension/README.md

Lines changed: 254 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Hover over SQL keywords to see documentation and usage examples.
2626
### SQL Analysis
2727
Analyze query complexity, find potential issues, and get optimization suggestions.
2828

29-
## Supported SQL Dialects
30-
31-
- PostgreSQL
32-
- MySQL
33-
- SQL Server
34-
- Oracle
35-
- SQLite
36-
- Generic SQL
29+
### Multi-Dialect Support
30+
Full support for database-specific syntax:
31+
- **PostgreSQL**: Dollar-quoted strings, JSONB operators, array operations, window functions
32+
- **MySQL**: Backtick identifiers, LIMIT/OFFSET syntax, GROUP_CONCAT, hash comments
33+
- **SQL Server**: Bracket identifiers, TOP clause, CROSS/OUTER APPLY, TRY/CATCH
34+
- **Oracle**: CONNECT BY hierarchical queries, ROWNUM, DECODE, MODEL clause
35+
- **SQLite**: Lightweight syntax, ATTACH/DETACH, FTS full-text search
36+
- **Generic SQL**: Standard SQL-99 compliance
3737

3838
## Requirements
3939

@@ -49,19 +49,57 @@ gosqlx --version
4949

5050
Make sure `gosqlx` is in your system PATH.
5151

52+
### Platform-Specific Installation
53+
54+
**macOS/Linux:**
55+
```bash
56+
# Add Go bin to PATH (add to ~/.bashrc or ~/.zshrc)
57+
export PATH="$PATH:$(go env GOPATH)/bin"
58+
59+
# Reload shell
60+
source ~/.bashrc # or source ~/.zshrc
61+
```
62+
63+
**Windows:**
64+
```powershell
65+
# Add Go bin to PATH (run in PowerShell as Admin)
66+
$env:Path += ";$(go env GOPATH)\bin"
67+
68+
# Or permanently via System Properties > Environment Variables
69+
# Add: %USERPROFILE%\go\bin
70+
```
71+
5272
## Extension Settings
5373

5474
This extension contributes the following settings:
5575

56-
| Setting | Default | Description |
57-
|---------|---------|-------------|
58-
| `gosqlx.enable` | `true` | Enable GoSQLX language server |
59-
| `gosqlx.executablePath` | `gosqlx` | Path to the gosqlx executable |
60-
| `gosqlx.trace.server` | `off` | Traces communication with the language server |
61-
| `gosqlx.format.indentSize` | `2` | Number of spaces for indentation |
62-
| `gosqlx.format.uppercaseKeywords` | `true` | Convert keywords to uppercase |
63-
| `gosqlx.validation.enable` | `true` | Enable real-time SQL validation |
64-
| `gosqlx.dialect` | `generic` | SQL dialect for validation |
76+
| Setting | Default | Scope | Description |
77+
|---------|---------|-------|-------------|
78+
| `gosqlx.enable` | `true` | Resource | Enable GoSQLX language server |
79+
| `gosqlx.executablePath` | `gosqlx` | Machine | Path to the gosqlx executable |
80+
| `gosqlx.trace.server` | `off` | Window | Traces communication with the language server |
81+
| `gosqlx.format.indentSize` | `2` | Resource | Number of spaces for indentation |
82+
| `gosqlx.format.uppercaseKeywords` | `true` | Resource | Convert keywords to uppercase |
83+
| `gosqlx.validation.enable` | `true` | Resource | Enable real-time SQL validation |
84+
| `gosqlx.dialect` | `generic` | Resource | SQL dialect for validation |
85+
| `gosqlx.timeouts.startup` | `10000` | Window | Language server startup timeout (ms) |
86+
| `gosqlx.timeouts.validation` | `5000` | Window | Executable validation timeout (ms) |
87+
| `gosqlx.timeouts.analysis` | `30000` | Window | SQL analysis timeout (ms) |
88+
| `gosqlx.telemetry.enable` | `false` | Global | Enable anonymous usage telemetry |
89+
| `gosqlx.performance.showStatusBar` | `false` | Window | Show performance metrics in status bar |
90+
| `gosqlx.performance.collectMetrics` | `true` | Window | Collect performance metrics |
91+
92+
### Workspace Settings
93+
94+
Settings with `Resource` scope can be configured per-workspace in `.vscode/settings.json`:
95+
96+
```json
97+
{
98+
"gosqlx.dialect": "postgresql",
99+
"gosqlx.format.indentSize": 4,
100+
"gosqlx.format.uppercaseKeywords": false
101+
}
102+
```
65103

66104
## Commands
67105

@@ -72,6 +110,8 @@ This extension contributes the following settings:
72110
| `GoSQLX: Analyze SQL` | Analyze query complexity and structure |
73111
| `GoSQLX: Restart Language Server` | Restart the GoSQLX language server |
74112
| `GoSQLX: Show Output Channel` | Show the GoSQLX output channel |
113+
| `GoSQLX: Show Performance Metrics` | Display performance statistics |
114+
| `GoSQLX: Validate Configuration` | Check configuration for errors |
75115

76116
## Performance
77117

@@ -87,28 +127,211 @@ GoSQLX delivers exceptional performance:
87127

88128
### Language server not starting
89129

90-
1. Ensure `gosqlx` is installed and in your PATH:
130+
**Symptom**: Status bar shows "GoSQLX: Executable not found"
131+
132+
1. **Verify gosqlx is installed:**
91133
```bash
134+
# macOS/Linux
92135
which gosqlx
93136
gosqlx --version
137+
138+
# Windows
139+
where gosqlx
140+
gosqlx --version
141+
```
142+
143+
2. **Check PATH configuration:**
144+
```bash
145+
# macOS/Linux - verify GOPATH/bin is in PATH
146+
echo $PATH | grep -o "$(go env GOPATH)/bin"
147+
148+
# If not found, add to shell profile:
149+
echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> ~/.bashrc
150+
source ~/.bashrc
94151
```
95152

96-
2. Check the GoSQLX output channel for errors:
153+
3. **Specify full path in settings:**
154+
```json
155+
{
156+
"gosqlx.executablePath": "/full/path/to/gosqlx"
157+
}
158+
```
159+
160+
4. **Check the output channel:**
97161
- Open Command Palette (`Ctrl+Shift+P`)
98162
- Run "GoSQLX: Show Output Channel"
99163

100-
3. Try specifying the full path in settings:
164+
### Permission denied errors
165+
166+
**Symptom**: "EACCES" or "permission denied" errors
167+
168+
**macOS/Linux:**
169+
```bash
170+
# Check permissions
171+
ls -la $(which gosqlx)
172+
173+
# Fix permissions
174+
chmod +x $(which gosqlx)
175+
```
176+
177+
**Windows:**
178+
- Run VS Code as Administrator
179+
- Check Windows Defender/antivirus settings
180+
- Verify the executable is not blocked (Properties > Unblock)
181+
182+
### Timeout errors
183+
184+
**Symptom**: "Analysis timed out" or "startup timeout"
185+
186+
1. **Increase timeout settings:**
101187
```json
102188
{
103-
"gosqlx.executablePath": "/path/to/gosqlx"
189+
"gosqlx.timeouts.startup": 30000,
190+
"gosqlx.timeouts.analysis": 60000
104191
}
105192
```
106193

194+
2. **Check system resources:**
195+
- Close resource-intensive applications
196+
- Check CPU/memory usage
197+
198+
3. **Try with simpler SQL:**
199+
- Complex queries may take longer
200+
- Break down large queries for analysis
201+
107202
### Validation not working
108203

109-
1. Ensure the file has a `.sql` extension
110-
2. Check that `gosqlx.validation.enable` is `true`
111-
3. Restart the language server
204+
**Symptom**: No syntax errors shown for invalid SQL
205+
206+
1. **Verify language detection:**
207+
- Ensure the file has a `.sql` extension
208+
- Check status bar shows "SQL" as language
209+
210+
2. **Check validation is enabled:**
211+
```json
212+
{
213+
"gosqlx.validation.enable": true
214+
}
215+
```
216+
217+
3. **Restart the language server:**
218+
- Run "GoSQLX: Restart Language Server"
219+
220+
4. **Verify dialect setting:**
221+
- Some syntax is dialect-specific
222+
- Try `"gosqlx.dialect": "generic"`
223+
224+
### Formatting issues
225+
226+
**Symptom**: Format command does nothing or produces unexpected results
227+
228+
1. **Check for syntax errors:**
229+
- Files with syntax errors may not format correctly
230+
- Fix errors first, then format
231+
232+
2. **Verify language server is running:**
233+
- Status bar should show "GoSQLX" (not error state)
234+
- Try restarting the server
235+
236+
3. **Check format settings:**
237+
```json
238+
{
239+
"gosqlx.format.indentSize": 2,
240+
"gosqlx.format.uppercaseKeywords": true
241+
}
242+
```
243+
244+
### Remote development issues
245+
246+
**Symptom**: Extension not working in Remote SSH/WSL/Container
247+
248+
1. **Install gosqlx in remote environment:**
249+
```bash
250+
# Run in remote terminal
251+
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latest
252+
```
253+
254+
2. **Configure remote PATH:**
255+
- Add Go bin to PATH in remote shell profile
256+
- Restart remote VS Code window
257+
258+
3. **Use remote-specific settings:**
259+
```json
260+
// Remote settings
261+
{
262+
"gosqlx.executablePath": "/home/user/go/bin/gosqlx"
263+
}
264+
```
265+
266+
### Connection reset errors
267+
268+
**Symptom**: "ECONNRESET" or "connection reset"
269+
270+
1. **Restart VS Code:**
271+
- Close all VS Code windows
272+
- Reopen the workspace
273+
274+
2. **Check for zombie processes:**
275+
```bash
276+
# macOS/Linux
277+
ps aux | grep gosqlx
278+
kill <pid> # if found
279+
280+
# Windows
281+
tasklist | findstr gosqlx
282+
taskkill /F /PID <pid>
283+
```
284+
285+
3. **Check system sleep/resume:**
286+
- Connections may break after sleep
287+
- Restart language server after wake
288+
289+
### Version mismatch errors
290+
291+
**Symptom**: "JSON parse error" or unexpected responses
292+
293+
1. **Update gosqlx:**
294+
```bash
295+
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latest
296+
```
297+
298+
2. **Verify version:**
299+
```bash
300+
gosqlx --version
301+
```
302+
303+
3. **Check extension version:**
304+
- Update extension to latest version
305+
- Restart VS Code
306+
307+
### Debug logging
308+
309+
For persistent issues, enable verbose logging:
310+
311+
```json
312+
{
313+
"gosqlx.trace.server": "verbose"
314+
}
315+
```
316+
317+
Then check the output channel for detailed logs.
318+
319+
## Telemetry
320+
321+
GoSQLX can collect anonymous usage data to help improve the extension. This is **disabled by default**.
322+
323+
When enabled:
324+
- **What we collect**: Command usage counts, operation durations, error codes
325+
- **What we NEVER collect**: SQL content, file paths, personal information
326+
327+
To opt in:
328+
```json
329+
{
330+
"gosqlx.telemetry.enable": true
331+
}
332+
```
333+
334+
Telemetry also respects VS Code's global telemetry setting.
112335

113336
## Contributing
114337

@@ -125,8 +348,13 @@ GNU Affero General Public License v3.0 (AGPL-3.0) - see [LICENSE](https://github
125348
Initial release:
126349
- Real-time SQL validation
127350
- SQL formatting with customizable options
128-
- Syntax highlighting for SQL
351+
- Syntax highlighting for SQL with multi-dialect support
129352
- Intelligent autocomplete
130353
- Hover documentation
131354
- SQL analysis command
132-
- Multi-dialect support
355+
- Multi-dialect support (PostgreSQL, MySQL, SQL Server, Oracle, SQLite)
356+
- Configurable timeouts
357+
- Performance metrics
358+
- Configuration validation
359+
- Enhanced error messaging with actionable suggestions
360+
- Workspace settings support

0 commit comments

Comments
 (0)