java-functional-lsp 0.4.0__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.claude-plugin/plugin.json +1 -1
  2. java_functional_lsp-0.4.2/.githooks/pre-commit +21 -0
  3. java_functional_lsp-0.4.2/.githooks/pre-push +19 -0
  4. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/PKG-INFO +56 -3
  5. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/README.md +55 -2
  6. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/SKILL.md +26 -2
  7. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/package-lock.json +485 -0
  8. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/package.json +1 -1
  9. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/hooks/java_linter_reminder.py +3 -5
  10. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/pyproject.toml +2 -1
  11. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/scripts/generate-formula.py +6 -6
  12. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/__init__.py +1 -1
  13. java_functional_lsp-0.4.2/src/java_functional_lsp/__main__.py +5 -0
  14. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/server.py +58 -27
  15. java_functional_lsp-0.4.2/tests/test_e2e.py +351 -0
  16. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/uv.lock +15 -1
  17. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/CODEOWNERS +0 -0
  18. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
  19. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
  20. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  21. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/SECURITY.md +0 -0
  22. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/dependabot.yml +0 -0
  23. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/release-drafter.yml +0 -0
  24. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/publish.yml +0 -0
  25. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/release-drafter.yml +0 -0
  26. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/stale.yml +0 -0
  27. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/test.yml +0 -0
  28. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/update-homebrew.yml +0 -0
  29. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.github/workflows/vscode-ext.yml +0 -0
  30. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/.gitignore +0 -0
  31. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/CONTRIBUTING.md +0 -0
  32. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/LICENSE +0 -0
  33. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/commands/lint-java.md +0 -0
  34. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/intellij/README.md +0 -0
  35. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/intellij/lsp4ij-template.json +0 -0
  36. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/.vscodeignore +0 -0
  37. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/README.md +0 -0
  38. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/src/extension.ts +0 -0
  39. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/editors/vscode/tsconfig.json +0 -0
  40. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/hooks/hooks.json +0 -0
  41. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/scripts/ensure-lsp.sh +0 -0
  42. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/__init__.py +0 -0
  43. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/base.py +0 -0
  44. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/exception_checker.py +0 -0
  45. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/mutation_checker.py +0 -0
  46. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/null_checker.py +0 -0
  47. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/analyzers/spring_checker.py +0 -0
  48. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/cli.py +0 -0
  49. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/src/java_functional_lsp/proxy.py +0 -0
  50. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/__init__.py +0 -0
  51. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/conftest.py +0 -0
  52. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_base.py +0 -0
  53. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_cli.py +0 -0
  54. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_config.py +0 -0
  55. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_exception_checker.py +0 -0
  56. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_mutation_checker.py +0 -0
  57. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_null_checker.py +0 -0
  58. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_proxy.py +0 -0
  59. {java_functional_lsp-0.4.0 → java_functional_lsp-0.4.2}/tests/test_spring_checker.py +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "java-functional-lsp",
3
3
  "description": "Java LSP with functional programming rules enforcement — null safety, immutability, no exceptions, Spring best practices. Wraps jdtls for full Java language support.",
4
- "version": "0.4.0"
4
+ "version": "0.4.1"
5
5
  }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+ # Pre-commit: run lint, format check, type check, and tests.
3
+ # Bypass with: git commit --no-verify
4
+
5
+ set -e
6
+
7
+ echo "Running pre-commit checks..."
8
+
9
+ echo " Lint..."
10
+ uv run ruff check src/ tests/
11
+
12
+ echo " Format..."
13
+ uv run ruff format --check src/ tests/
14
+
15
+ echo " Type check..."
16
+ uv run mypy src/
17
+
18
+ echo " Tests..."
19
+ uv run pytest -q
20
+
21
+ echo "All checks passed."
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ # Prevent direct pushes to main/master — all changes must go through PRs.
3
+
4
+ protected_branches=("main" "master")
5
+ current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
6
+
7
+ for branch in "${protected_branches[@]}"; do
8
+ if [ "$current_branch" = "$branch" ]; then
9
+ echo "ERROR: Direct push to '$branch' is not allowed."
10
+ echo "Create a feature branch and open a pull request instead."
11
+ echo ""
12
+ echo " git checkout -b feat/my-change"
13
+ echo " git push -u origin feat/my-change"
14
+ echo " gh pr create"
15
+ echo ""
16
+ echo "To bypass (emergency only): git push --no-verify"
17
+ exit 1
18
+ fi
19
+ done
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: java-functional-lsp
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Java LSP server enforcing functional programming best practices — null safety, immutability, no exceptions
5
5
  Project-URL: Homepage, https://github.com/aviadshiber/java-functional-lsp
6
6
  Project-URL: Repository, https://github.com/aviadshiber/java-functional-lsp
@@ -109,13 +109,24 @@ See [editors/intellij/README.md](editors/intellij/README.md) for detailed instru
109
109
 
110
110
  ### Claude Code
111
111
 
112
- Install as a plugin directly from GitHub:
112
+ **Step 1: Enable LSP support** (required, one-time):
113
+
114
+ Add to `~/.claude/settings.json`:
115
+ ```json
116
+ {
117
+ "env": {
118
+ "ENABLE_LSP_TOOL": "1"
119
+ }
120
+ }
121
+ ```
122
+
123
+ **Step 2: Install the plugin:**
113
124
 
114
125
  ```bash
115
126
  claude plugin add https://github.com/aviadshiber/java-functional-lsp.git
116
127
  ```
117
128
 
118
- This registers the LSP server, adds auto-install hooks, and provides the `/lint-java` command.
129
+ This registers the LSP server, adds auto-install hooks, a PostToolUse hook that reminds Claude to fix violations on every `.java` file edit, and the `/lint-java` command.
119
130
 
120
131
  Or manually add to your Claude Code config:
121
132
 
@@ -130,6 +141,43 @@ Or manually add to your Claude Code config:
130
141
  }
131
142
  ```
132
143
 
144
+ **Alternative: project-level `.lsp.json`** — instead of installing the plugin or editing global config, add a `.lsp.json` file at your project root:
145
+
146
+ ```json
147
+ {
148
+ "java-functional": {
149
+ "command": "java-functional-lsp",
150
+ "extensionToLanguage": { ".java": "java" }
151
+ }
152
+ }
153
+ ```
154
+
155
+ This is useful for CI environments, containers, or ensuring all team members get the LSP server without individual setup. The `java-functional-lsp` binary must still be installed (`pip install java-functional-lsp` or `brew install aviadshiber/tap/java-functional-lsp`).
156
+
157
+ **Step 3: Nudge Claude to prefer LSP** (recommended):
158
+
159
+ Add to `~/.claude/rules/code-intelligence.md`:
160
+ ```markdown
161
+ # Code Intelligence
162
+
163
+ Prefer LSP over Grep/Glob/Read for code navigation:
164
+ - goToDefinition / goToImplementation to jump to source
165
+ - findReferences to see all usages across the codebase
166
+ - hover for type info without reading the file
167
+
168
+ After writing or editing code, check LSP diagnostics before
169
+ moving on. Fix any type errors or missing imports immediately.
170
+ ```
171
+
172
+ **Troubleshooting:**
173
+
174
+ | Issue | Fix |
175
+ |-------|-----|
176
+ | No diagnostics appear | Ensure `ENABLE_LSP_TOOL=1` is set, restart Claude Code |
177
+ | "java-functional-lsp not found" | Run `brew install aviadshiber/tap/java-functional-lsp` |
178
+ | Plugin not active | Run `claude plugin list` to verify, then `/reload-plugins` |
179
+ | Diagnostics slow on first open | Normal — tree-sitter parses on first load, then incremental |
180
+
133
181
  ### Other Editors
134
182
 
135
183
  Any LSP client that supports stdio transport can use this server. Point it to the `java-functional-lsp` command for `java` files.
@@ -177,6 +225,7 @@ The server speaks the Language Server Protocol (LSP) via stdio, making it compat
177
225
  git clone https://github.com/aviadshiber/java-functional-lsp.git
178
226
  cd java-functional-lsp
179
227
  uv sync
228
+ git config core.hooksPath .githooks
180
229
 
181
230
  # Run checks
182
231
  uv run ruff check src/ tests/
@@ -185,6 +234,10 @@ uv run mypy src/
185
234
  uv run pytest
186
235
  ```
187
236
 
237
+ Git hooks in `.githooks/` enforce quality automatically:
238
+ - **pre-commit** — runs lint, format, type check, and tests before each commit
239
+ - **pre-push** — blocks direct pushes to main (use feature branches + PRs)
240
+
188
241
  See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
189
242
 
190
243
  ## License
@@ -81,13 +81,24 @@ See [editors/intellij/README.md](editors/intellij/README.md) for detailed instru
81
81
 
82
82
  ### Claude Code
83
83
 
84
- Install as a plugin directly from GitHub:
84
+ **Step 1: Enable LSP support** (required, one-time):
85
+
86
+ Add to `~/.claude/settings.json`:
87
+ ```json
88
+ {
89
+ "env": {
90
+ "ENABLE_LSP_TOOL": "1"
91
+ }
92
+ }
93
+ ```
94
+
95
+ **Step 2: Install the plugin:**
85
96
 
86
97
  ```bash
87
98
  claude plugin add https://github.com/aviadshiber/java-functional-lsp.git
88
99
  ```
89
100
 
90
- This registers the LSP server, adds auto-install hooks, and provides the `/lint-java` command.
101
+ This registers the LSP server, adds auto-install hooks, a PostToolUse hook that reminds Claude to fix violations on every `.java` file edit, and the `/lint-java` command.
91
102
 
92
103
  Or manually add to your Claude Code config:
93
104
 
@@ -102,6 +113,43 @@ Or manually add to your Claude Code config:
102
113
  }
103
114
  ```
104
115
 
116
+ **Alternative: project-level `.lsp.json`** — instead of installing the plugin or editing global config, add a `.lsp.json` file at your project root:
117
+
118
+ ```json
119
+ {
120
+ "java-functional": {
121
+ "command": "java-functional-lsp",
122
+ "extensionToLanguage": { ".java": "java" }
123
+ }
124
+ }
125
+ ```
126
+
127
+ This is useful for CI environments, containers, or ensuring all team members get the LSP server without individual setup. The `java-functional-lsp` binary must still be installed (`pip install java-functional-lsp` or `brew install aviadshiber/tap/java-functional-lsp`).
128
+
129
+ **Step 3: Nudge Claude to prefer LSP** (recommended):
130
+
131
+ Add to `~/.claude/rules/code-intelligence.md`:
132
+ ```markdown
133
+ # Code Intelligence
134
+
135
+ Prefer LSP over Grep/Glob/Read for code navigation:
136
+ - goToDefinition / goToImplementation to jump to source
137
+ - findReferences to see all usages across the codebase
138
+ - hover for type info without reading the file
139
+
140
+ After writing or editing code, check LSP diagnostics before
141
+ moving on. Fix any type errors or missing imports immediately.
142
+ ```
143
+
144
+ **Troubleshooting:**
145
+
146
+ | Issue | Fix |
147
+ |-------|-----|
148
+ | No diagnostics appear | Ensure `ENABLE_LSP_TOOL=1` is set, restart Claude Code |
149
+ | "java-functional-lsp not found" | Run `brew install aviadshiber/tap/java-functional-lsp` |
150
+ | Plugin not active | Run `claude plugin list` to verify, then `/reload-plugins` |
151
+ | Diagnostics slow on first open | Normal — tree-sitter parses on first load, then incremental |
152
+
105
153
  ### Other Editors
106
154
 
107
155
  Any LSP client that supports stdio transport can use this server. Point it to the `java-functional-lsp` command for `java` files.
@@ -149,6 +197,7 @@ The server speaks the Language Server Protocol (LSP) via stdio, making it compat
149
197
  git clone https://github.com/aviadshiber/java-functional-lsp.git
150
198
  cd java-functional-lsp
151
199
  uv sync
200
+ git config core.hooksPath .githooks
152
201
 
153
202
  # Run checks
154
203
  uv run ruff check src/ tests/
@@ -157,6 +206,10 @@ uv run mypy src/
157
206
  uv run pytest
158
207
  ```
159
208
 
209
+ Git hooks in `.githooks/` enforce quality automatically:
210
+ - **pre-commit** — runs lint, format, type check, and tests before each commit
211
+ - **pre-push** — blocks direct pushes to main (use feature branches + PRs)
212
+
160
213
  See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
161
214
 
162
215
  ## License
@@ -59,6 +59,10 @@ Create `.java-functional-lsp.json` in your project root:
59
59
  - `throw-statement`/`catch-rethrow` auto-suppressed in `@Bean` methods
60
60
  - `mutable-dto` suggests `@ConstructorBinding` for `@ConfigurationProperties` classes
61
61
 
62
+ ## Automatic Enforcement
63
+
64
+ The plugin includes a PostToolUse hook that fires on every Read/Edit/Write of `.java` files. If diagnostics appear, Claude is prompted to fix them immediately without explanation.
65
+
62
66
  ## On-Demand Linting
63
67
 
64
68
  Use `/lint-java <path>` to force-run the linter on specific files or directories.
@@ -74,8 +78,28 @@ To release a new version:
74
78
  5. CI automatically publishes to PyPI and builds the VS Code extension `.vsix`
75
79
  6. Run `python3 scripts/generate-formula.py <version>` and update the Homebrew tap
76
80
 
81
+ ## Enabling LSP in Claude Code
82
+
83
+ LSP support requires `ENABLE_LSP_TOOL=1` in `~/.claude/settings.json`:
84
+ ```json
85
+ { "env": { "ENABLE_LSP_TOOL": "1" } }
86
+ ```
87
+
88
+ For containers or CI, add a `.lsp.json` at the project root instead of installing the plugin:
89
+ ```json
90
+ { "java-functional": { "command": "java-functional-lsp", "extensionToLanguage": { ".java": "java" } } }
91
+ ```
92
+
93
+ To nudge Claude to act on diagnostics, add to your project's `CLAUDE.md`:
94
+ ```
95
+ After writing or editing Java code, check LSP diagnostics before moving on.
96
+ Fix any violations immediately — do not explain, just apply the fix.
97
+ ```
98
+
77
99
  ## Troubleshooting
78
100
 
101
+ - **No diagnostics in Claude Code**: Ensure `ENABLE_LSP_TOOL=1` is set, restart Claude Code
79
102
  - **"java-functional-lsp not found"**: Run `brew install aviadshiber/tap/java-functional-lsp`
80
- - **No completions/hover**: Install jdtls: `brew install jdtls`
81
- - **Too many warnings**: Create `.java-functional-lsp.json` to tune severity or disable noisy rules
103
+ - **No completions/hover**: Install jdtls: `brew install jdtls` (requires JDK 21+)
104
+ - **Too many warnings**: Create `.java-functional-lsp.json` with `excludes` or per-rule severity
105
+ - **Plugin not active**: Run `claude plugin list` to verify, then `/reload-plugins`