feat(code-action): add code action to open noogle.dev docs for lib functions#764
Conversation
inclyc
left a comment
There was a problem hiding this comment.
Since we have a growing number of code actions and their functionalities are quite independent, I suggest we create a dedicated CodeActions subdirectory under Controller. We could then move each action into its own file. I'd recommend doing the same for the test directory as well, since the test files are starting to get a bit crowded, WDYT?
|
@inclyc |
fadb950 to
73a4136
Compare
…nctions Add a new code action to open noogle.dev documentation for `lib.*` function paths directly from the editor. When the cursor is on a `lib.X` or `lib.X.Y.Z` expression, the action opens the corresponding noogle.dev documentation page in the user's browser via `window/showDocument`. Examples: - lib.optionalString → Opens https://noogle.dev/f/lib/optionalString - lib.strings.optionalString → Opens https://noogle.dev/f/lib/strings/optionalString Implementation includes: - `addNoogleDocAction`: Provides code actions for lib.* paths - `buildNoogleUrl`: Constructs noogle.dev URLs for function paths - `onCodeActionResolve`: Triggers documentation display via window/showDocument - Protocol serialization updates for CodeAction.data field - Registration of codeAction/resolve and window/showDocument methods
73a4136 to
b553207
Compare
- Add externalUri field to ShowDocumentParams for non-file URIs - Update serialization to prefer externalUri over uri when set - Adjust code actions to use externalUri for external links - Enable resolveProvider and refactor codeActionKinds in LifeTime
inclyc
left a comment
There was a problem hiding this comment.
Overall, this PR LGTM, but I think there are a few points that could be improved:
- Support for
withscopes: Variables introduced viawith(e.g.,with lib; mkAfter), which are essentially members oflib, don't seem to be supported yet. - Hover Integration: I usually expect to see "open docs" within the hover content (when mousing over). It might be worth checking nixd#745 to see if we can share some common code between "open in noogle" and that implementation.
|
Thanks review! You're right, so I'll fix it. |
|
The current handling of with scopes via |
|
Understood. |
…ed files
Extract code action implementations from CodeAction.cpp into a dedicated
CodeActions/ subdirectory with separate files for each action type:
- AttrName.{h,cpp}: Quote/unquote attribute name actions
- FlattenAttrs.{h,cpp}: Flatten nested attribute set action
- JsonToNix.{h,cpp}: JSON to Nix conversion action
- NoogleDoc.{h,cpp}: Noogle documentation link action
- PackAttrs.{h,cpp}: Pack dotted paths to nested set actions
- Utils.{h,cpp}: Shared utilities (identifier validation, escaping, etc.)
This improves maintainability as the number of code actions grows,
following the suggestion from PR #764 review.
Move 63 test files from flat structure into category subdirectories to improve discoverability and match the source code organization: - attr-name/: Quote/unquote attribute name tests (14 files) - flatten-attrs/: Flatten nested attribute set tests (7 files) - json-to-nix/: JSON to Nix conversion tests (13 files) - noogle-doc/: Noogle documentation link tests (4 files) - pack-attrs/: Pack dotted paths tests (24 files) - quick-fix/: Quick fix diagnostic tests (1 file) This addresses the test directory organization suggested in PR #764 review.
…ed files
Extract code action implementations from CodeAction.cpp into a dedicated
CodeActions/ subdirectory with separate files for each action type:
- AttrName.{h,cpp}: Quote/unquote attribute name actions
- FlattenAttrs.{h,cpp}: Flatten nested attribute set action
- JsonToNix.{h,cpp}: JSON to Nix conversion action
- NoogleDoc.{h,cpp}: Noogle documentation link action
- PackAttrs.{h,cpp}: Pack dotted paths to nested set actions
- Utils.{h,cpp}: Shared utilities (identifier validation, escaping, etc.)
This improves maintainability as the number of code actions grows,
following the suggestion from PR #764 review.
Move 63 test files from flat structure into category subdirectories to improve discoverability and match the source code organization: - attr-name/: Quote/unquote attribute name tests (14 files) - flatten-attrs/: Flatten nested attribute set tests (7 files) - json-to-nix/: JSON to Nix conversion tests (13 files) - noogle-doc/: Noogle documentation link tests (4 files) - pack-attrs/: Pack dotted paths tests (24 files) - quick-fix/: Quick fix diagnostic tests (1 file) This addresses the test directory organization suggested in PR #764 review.
…nd test subdirectories (#765) ## Summary This PR addresses the file structure suggestion from PR #764 review. ### Commits 1. **refactor(code-action): extract code action implementations to dedicated files** c68c266 - Extract from `CodeAction.cpp` into `Controller/CodeActions/` subdirectory - Create dedicated files: AttrName, FlattenAttrs, JsonToNix, NoogleDoc, PackAttrs, Utils 2. **test(code-action): reorganize test files into category subdirectories** 078ba02 - Move 63 test files into 6 category subdirectories - Categories: attr-name, flatten-attrs, json-to-nix, noogle-doc, pack-attrs, quick-fix ### Motivation The growing number of code actions warrants a dedicated subdirectory structure for better maintainability. ### Testing - All unit tests pass - All regression tests pass --------- Co-authored-by: Yingchi Long <longyingchi24s@ict.ac.cn>
Summary
Add a new code action to open noogle.dev documentation for
lib.*function paths directly from the editor.When the cursor is on a
lib.Xorlib.X.Y.Zexpression, the action opens the corresponding noogle.dev documentation page in the user's browser viawindow/showDocument.Example:
lib.optionalString→ Openshttps://noogle.dev/f/lib/optionalStringlib.strings.optionalString→ Openshttps://noogle.dev/f/lib/strings/optionalStringChanges
onCodeActionResolvehandler andShowDocumentcallbackbuildNoogleUrl()andaddNoogleDocAction()functionscodeAction/resolveandwindow/showDocumentmethodsCodeAction.data,ShowDocumentParams,ShowDocumentResultBehavior
Action offered when:
ExprSelectwith base variablelibAction NOT offered when:
libvariable without selectionlib.${x})pkgs.hello)Test Plan
noogle-lib-simple.md- Basiclib.Xpathnoogle-lib-nested.md- Nestedlib.X.Ypathnoogle-lib-var-only.md- Negative: justlibvariablenoogle-not-lib.md- Negative: non-lib selectRelated