drccrd opened a new pull request, #3717:
URL: https://github.com/apache/incubator-kie-tools/pull/3717

   Closes: #3714 
   
   ## What this does
   
   Groups are resolved in four tiers, each falling through to the next:
   
   | | Source | Notes |
   |---|---|---|
   | 1 | `drools.lsp.grouping` setting | Nothing on disk required |
   | 2 | `drl-lsp-kbases.json` | Same content as the setting, for grouping a 
team wants committed |
   | 3 | `META-INF/kmodule.xml` | The `packages`/`includes` attributes the 
build already uses |
   | 4 | Containing directory | Today's behaviour |
   
   **Tier 3 is what makes this useful with no configuration at all.** A 
conventional project already declares its kbases, so the editor's idea of scope 
matches the build's by construction rather than by convention.
   
   **Tier 4 means this cannot regress anyone.** An unconfigured workspace 
resolves to exactly the same siblings as before.
   
   The SPI is now installable by drop-in: resolvers are discovered through 
`ServiceLoader`, and a third-party provider is preferred over the shipped one, 
so an alternative grouping model needs only a jar on the classpath.
   
   See the extension README for the config format and a worked example.
   
   ## Notes for reviewers
   
   **The kbase matcher is a deliberate port, not a reimplementation.** 
`KieBasePackages` reproduces `KieBuilderImpl#isPackageInKieBase` and 
`#isPackageInKieBaseOrIncludedKieBases`. It is reproduced rather than called 
because `drools-completion` carries no dependency on `drools-compiler`, and 
pulling the rule compiler into the language-server process to answer a 
string-matching question is not a trade worth making. The javadoc names the 
normative source, and the tests are written against that method's branches — 
including the first-match-wins ordering that makes a trailing negation a no-op.
   
   **Naming follows the layering rather than one vocabulary.** The SPI, the 
protocol and the commands stay generic ("group") because they serve whatever 
resolver is installed, and a host may group by something that is not a kbase at 
all. Each group instead carries what the resolver knows about it — `Group(name, 
files, kind, declaredIn)` — where `kind` is set only when the resolver can be 
more specific. The shipped resolver reports `"KIE base"` for a group read from 
a `kmodule.xml` and leaves it null otherwise, so a project that never wrote a 
kmodule descriptor is never shown kmodule vocabulary. `declaredIn` names the 
declaring file, which is the fastest answer to "why is this file in scope?".
   
   **File discovery is the client's job where the client can do it.** The 
extension enumerates with `vscode.workspace.findFiles`, which already applies 
the user's `files.exclude`, `search.exclude` and ignore files, and sends the 
result in `initializationOptions`. The server keeps a walk only as a fallback 
for other clients; its skip-list is limited to `node_modules`, `.git`, `.svn`, 
`.hg`. Build-output copies are filtered separately and always, since a compiled 
DRL under `target/classes` would otherwise shadow the source being edited.
   
   **Existing files touched, and why:**
   
   - `WorkspaceSiblingResolver` — five default methods added; the interface is 
still implementable with one method.
   - `WorkspaceSiblingResolvers` — `ServiceLoader` discovery, same-directory 
default unchanged.
   - `DroolsLspServer` — three `drools/*` methods, `initializationOptions` 
parsing, and a diagnostics refresh.
   - `extension.ts` — wiring only.
   
   No dependency changes.
   
   ## Protocol additions
   
   | Method | Direction | Purpose |
   |---|---|---|
   | `drools/fileGroups` | request | Group map for the UI |
   | `drools/setFileGroup` | notification | Pin a file to a group |
   | `drools/setGroupingConfig` | notification | Settings changed |
   | `drools/setWorkspaceFiles` | notification | Client's file enumeration |
   | `drools/fileGroupsChanged` | server → client | Groups reloaded; re-read |
   
   Diagnostics here are pull-based, so the server requests 
`workspace/diagnostic/refresh` whenever grouping changes.
   
   ## Testing
   
   49 new tests; 324 green across `drools-parser`, `drools-completion` and 
`drools-lsp-server`.
   
   - `KieBasePackagesTest` — a table driven off `KieBuilderImpl`'s branches: 
empty packages, negation ordering, `.*` prefix matching, resources-root 
stripping, kbase-name-relative patterns, `includes` cycles.
   - `DrlPackageReaderTest` — declared-package extraction (comments, string 
literals, missing semicolon) and path-derived fallback.
   - `ConfiguredGroupingResolverTest` — each tier, precedence between them, 
adopted manifests with key aliases, duplicate-name merging, pinning, 
provenance, client-supplied file lists, and degenerate workspaces 
(unconfigured, malformed config, null root).
   
   Manually verified in VS Code against a real rule set: settings-declared 
grouping, adopting existing manifests, pinning, and live reload on config 
change.
   
   ## Not included
   
   Two pre-existing issues found while testing, deliberately left out (can add 
if it suits):
   
   - `pack:prod` uses `$npm_package_version`, which does not expand on Windows 
and leaks into the VSIX filename.
   - The package has no `.vscode/launch.json`, so there is no configured F5 
flow for it.
   
   Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to