hledger-lsp 0.3.0 → 0.4.0
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.
- package/README.md +72 -56
- package/out/features/callHierarchy.d.ts +34 -0
- package/out/features/callHierarchy.d.ts.map +1 -0
- package/out/features/callHierarchy.js +200 -0
- package/out/features/callHierarchy.js.map +1 -0
- package/out/features/documentLinks.d.ts.map +1 -1
- package/out/features/documentLinks.js +5 -32
- package/out/features/documentLinks.js.map +1 -1
- package/out/features/findReferences.d.ts.map +1 -1
- package/out/features/findReferences.js +65 -0
- package/out/features/findReferences.js.map +1 -1
- package/out/features/foldingRanges.d.ts +4 -0
- package/out/features/foldingRanges.d.ts.map +1 -1
- package/out/features/foldingRanges.js +60 -0
- package/out/features/foldingRanges.js.map +1 -1
- package/out/features/formatter.d.ts.map +1 -1
- package/out/features/formatter.js +50 -6
- package/out/features/formatter.js.map +1 -1
- package/out/features/inlayHints.d.ts +1 -0
- package/out/features/inlayHints.d.ts.map +1 -1
- package/out/features/inlayHints.js +41 -1
- package/out/features/inlayHints.js.map +1 -1
- package/out/features/semanticTokens.d.ts +10 -0
- package/out/features/semanticTokens.d.ts.map +1 -1
- package/out/features/semanticTokens.js +84 -0
- package/out/features/semanticTokens.js.map +1 -1
- package/out/features/symbols.d.ts.map +1 -1
- package/out/features/symbols.js +69 -0
- package/out/features/symbols.js.map +1 -1
- package/out/features/validator.d.ts +13 -0
- package/out/features/validator.d.ts.map +1 -1
- package/out/features/validator.js +258 -0
- package/out/features/validator.js.map +1 -1
- package/out/parser/ast.d.ts +27 -1
- package/out/parser/ast.d.ts.map +1 -1
- package/out/parser/ast.js +319 -0
- package/out/parser/ast.js.map +1 -1
- package/out/parser/index.d.ts.map +1 -1
- package/out/parser/index.js +68 -2
- package/out/parser/index.js.map +1 -1
- package/out/server/workspace.d.ts +23 -1
- package/out/server/workspace.d.ts.map +1 -1
- package/out/server/workspace.js +82 -7
- package/out/server/workspace.js.map +1 -1
- package/out/server.js +24 -0
- package/out/server.js.map +1 -1
- package/out/types.d.ts +32 -0
- package/out/types.d.ts.map +1 -1
- package/out/utils/documentMerge.d.ts.map +1 -1
- package/out/utils/documentMerge.js +6 -0
- package/out/utils/documentMerge.js.map +1 -1
- package/out/utils/includeRange.d.ts +18 -0
- package/out/utils/includeRange.d.ts.map +1 -0
- package/out/utils/includeRange.js +51 -0
- package/out/utils/includeRange.js.map +1 -0
- package/out/utils/index.d.ts +6 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +12 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# hledger Language Server
|
|
2
2
|
|
|
3
|
-
A Language Server Protocol
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) implementation for [hledger](https://hledger.org/) plain text accounting;
|
|
4
|
+
bringing IDE-grade tooling to your journal files.
|
|
5
|
+
|
|
6
|
+
Completion, validation, formatting, navigation, semantic highlighting, inlay
|
|
7
|
+
hints, and more — in any editor that supports LSP.
|
|
8
|
+
|
|
9
|
+
**Editor plugins**: [VS Code](https://marketplace.visualstudio.com/items?itemName=patrickt.hledger-lsp-vscode) · [Neovim](https://github.com/ptimoney/hledger-nvim) · [Any LSP client](#other-editors)
|
|
6
10
|
|
|
7
11
|
<!--toc:start-->
|
|
8
12
|
- [hledger Language Server](#hledger-language-server)
|
|
@@ -12,8 +16,6 @@ plugins for [vscode](https://marketplace.visualstudio.com/items?itemName=patrick
|
|
|
12
16
|
- [Standalone Formatter](#standalone-formatter)
|
|
13
17
|
- [Other Options](#other-options)
|
|
14
18
|
- [IDE Integration](#ide-integration)
|
|
15
|
-
- [VS Code](#vs-code)
|
|
16
|
-
- [Neovim](#neovim)
|
|
17
19
|
- [Other Editors](#other-editors)
|
|
18
20
|
- [Features](#features)
|
|
19
21
|
- [Code Completion](#code-completion)
|
|
@@ -43,8 +45,8 @@ plugins for [vscode](https://marketplace.visualstudio.com/items?itemName=patrick
|
|
|
43
45
|
- [Project Structure](#project-structure)
|
|
44
46
|
- [Development Commands](#development-commands)
|
|
45
47
|
- [Contributing](#contributing)
|
|
48
|
+
- [Related Projects](#related-projects)
|
|
46
49
|
- [License](#license)
|
|
47
|
-
- [Links](#links)
|
|
48
50
|
<!--toc:end-->
|
|
49
51
|
|
|
50
52
|
## Installation
|
|
@@ -88,6 +90,7 @@ hledger-lsp --format myfile.journal -o myfile.journal
|
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
The formatter applies default formatting settings:
|
|
93
|
+
|
|
91
94
|
- 4-space indentation for postings
|
|
92
95
|
- Decimal point alignment at column 52
|
|
93
96
|
- Normalized transaction header spacing
|
|
@@ -101,22 +104,17 @@ hledger-lsp --version # Show version
|
|
|
101
104
|
|
|
102
105
|
## IDE Integration
|
|
103
106
|
|
|
104
|
-
This language server
|
|
105
|
-
|
|
106
|
-
### VS Code
|
|
107
|
-
|
|
108
|
-
**Extension**: [hledger-vscode](https://marketplace.visualstudio.com/items?itemName=patrickt.hledger-lsp-vscode)
|
|
109
|
-
|
|
110
|
-
**GitHub**: [hledger-vscode](https://github.com/ptimoney/hledger-vscode)
|
|
111
|
-
|
|
112
|
-
Install from the VS Code Marketplace or Extensions view. The extension provides
|
|
113
|
-
all LSP features with zero configuration.
|
|
114
|
-
|
|
115
|
-
### Neovim
|
|
107
|
+
This language server works with any LSP-compatible editor. First-party plugins
|
|
108
|
+
are available for VS Code and Neovim:
|
|
116
109
|
|
|
117
|
-
|
|
110
|
+
| Editor | Plugin | Install |
|
|
111
|
+
|---------|----------------|----------------------------------|
|
|
112
|
+
| **VS Code** | [hledger-vscode](https://github.com/ptimoney/hledger-vscode) | [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=patrickt.hledger-lsp-vscode) |
|
|
113
|
+
| **Neovim** | [hledger-nvim](https://github.com/ptimoney/hledger-nvim) | Plugin manager (lazy.nvim, etc.) |
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
Both plugins provide all LSP features with zero configuration. The VS Code
|
|
116
|
+
extension also includes a workspace graph tree view; the Neovim plugin includes
|
|
117
|
+
a workspace graph floating window.
|
|
120
118
|
|
|
121
119
|
### Other Editors
|
|
122
120
|
|
|
@@ -133,8 +131,8 @@ The server can be used with any LSP client. Example configuration:
|
|
|
133
131
|
|
|
134
132
|
## Features
|
|
135
133
|
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
Comprehensive IDE support for hledger journal files, including regular
|
|
135
|
+
transactions, periodic transactions (`~`), and auto posting rules (`=`):
|
|
138
136
|
|
|
139
137
|
### Code Completion
|
|
140
138
|
|
|
@@ -173,6 +171,10 @@ and tags
|
|
|
173
171
|
- **Empty descriptions** - Warn about transactions with no description
|
|
174
172
|
- **Include files** - Detect missing include files
|
|
175
173
|
- **Circular includes** - Detect circular include dependencies
|
|
174
|
+
- **Periodic transactions** - Balance and missing-amount checks for `~` periodic
|
|
175
|
+
transaction rules (same rules as regular transactions)
|
|
176
|
+
- **Auto postings** - Undeclared account/commodity checks for `=` auto posting
|
|
177
|
+
rules (balance checks are skipped since auto postings are partial by design)
|
|
176
178
|
|
|
177
179
|
### Include Directive Support
|
|
178
180
|
|
|
@@ -190,8 +192,8 @@ special characters (e.g., "Cloud Storage", "My Documents (2025)")
|
|
|
190
192
|
|
|
191
193
|
### Navigation
|
|
192
194
|
|
|
193
|
-
- **Document symbols** - Outline view showing directives
|
|
194
|
-
postings
|
|
195
|
+
- **Document symbols** - Outline view showing directives, transactions, periodic
|
|
196
|
+
transactions (`~`), and auto posting rules (`=`) with their postings
|
|
195
197
|
- **Workspace symbols** - Project-wide search across all accounts, payees,
|
|
196
198
|
commodities, tags, and transactions
|
|
197
199
|
- **Go to definition** - Jump to declarations for accounts, payees, commodities,
|
|
@@ -242,11 +244,13 @@ definitions) and readonly items (dates, amounts)
|
|
|
242
244
|
their hierarchical nature
|
|
243
245
|
- **Tag detection** - Automatic highlighting of tags within comments (key:value
|
|
244
246
|
pairs)
|
|
247
|
+
- **Periodic & auto postings** - `~` and `=` operators, period expressions,
|
|
248
|
+
queries, and their postings are all semantically highlighted
|
|
245
249
|
|
|
246
250
|
### Inlay Hints
|
|
247
251
|
|
|
248
252
|
- **Inferred amounts** - Show calculated amounts for postings without explicit
|
|
249
|
-
amounts
|
|
253
|
+
amounts (including periodic transaction postings)
|
|
250
254
|
- **Running balances** - Display running balances per account and commodity
|
|
251
255
|
after each posting
|
|
252
256
|
- **Cost conversions** - Show total cost in target commodity for postings with
|
|
@@ -266,8 +270,8 @@ involved in on transaction headers
|
|
|
266
270
|
|
|
267
271
|
### Editor Integration
|
|
268
272
|
|
|
269
|
-
- **Folding ranges** - Collapse/expand transactions
|
|
270
|
-
multi-line comment blocks
|
|
273
|
+
- **Folding ranges** - Collapse/expand transactions, periodic transactions,
|
|
274
|
+
and auto posting rules to hide postings; fold multi-line comment blocks
|
|
271
275
|
- **Document links** - Clickable include paths that open the referenced file
|
|
272
276
|
(supports relative and absolute paths)
|
|
273
277
|
- **Selection range** - Smart text selection expansion: Word → Account → Posting
|
|
@@ -294,7 +298,8 @@ problems to report per file
|
|
|
294
298
|
|
|
295
299
|
Most validation settings default to `true` and can be individually disabled:
|
|
296
300
|
|
|
297
|
-
- `validation.balance` (default: true): Verify transactions balance to zero per
|
|
301
|
+
- `validation.balance` (default: true): Verify transactions balance to zero per
|
|
302
|
+
commodity
|
|
298
303
|
- `validation.requireExplicitCosts` (default: **false**): Require explicit `@` or
|
|
299
304
|
`@@` cost notation for multi-commodity transactions. When disabled (default), the
|
|
300
305
|
LSP auto-infers costs like hledger's `autobalanced` mode. When enabled, mirrors
|
|
@@ -400,7 +405,8 @@ configuration override settings from the config file.
|
|
|
400
405
|
|
|
401
406
|
**Performance Tips:**
|
|
402
407
|
|
|
403
|
-
- For large workspaces (>100 files), use `exclude` patterns to skip unnecessary
|
|
408
|
+
- For large workspaces (>100 files), use `exclude` patterns to skip unnecessary
|
|
409
|
+
files
|
|
404
410
|
- Disable `eagerParsing` if initialization is slow
|
|
405
411
|
- Check LSP server logs for performance warnings and metrics
|
|
406
412
|
|
|
@@ -441,8 +447,8 @@ for aligning decimal points in amounts
|
|
|
441
447
|
position for aligning decimal points in balance assertions
|
|
442
448
|
- `formatting.signPosition` (string, default: "after-symbol"): Where to place the
|
|
443
449
|
negative sign for prefix commodities. Options: `"after-symbol"` (e.g., `$-100.00`)
|
|
444
|
-
or `"before-symbol"` (e.g., `-$100.00`). This affects how amounts are displayed
|
|
445
|
-
hover information, inlay hints, and other LSP features. Does not affect postfix
|
|
450
|
+
or `"before-symbol"` (e.g., `-$100.00`). This affects how amounts are displayed
|
|
451
|
+
in hover information, inlay hints, and other LSP features. Does not affect postfix
|
|
446
452
|
commodities (e.g., `-100.00 EUR`), which always show the sign before the number.
|
|
447
453
|
- `formatting.showPositivesSign` (boolean, default: false): Whether to show a `+`
|
|
448
454
|
sign for positive amounts
|
|
@@ -467,12 +473,6 @@ for future features):
|
|
|
467
473
|
- `codeLens.showTransactionCounts` (boolean, default: false): Show transaction
|
|
468
474
|
counts for each account on transaction headers
|
|
469
475
|
|
|
470
|
-
## Known Limitations
|
|
471
|
-
|
|
472
|
-
- Auto postings and periodic transactions are broadly unsupported. Though we try
|
|
473
|
-
to avoid breaking them. Please report any breaking issues, and consider suggestions
|
|
474
|
-
or contributions for any deeper integration
|
|
475
|
-
|
|
476
476
|
## Development
|
|
477
477
|
|
|
478
478
|
### Prerequisites
|
|
@@ -507,7 +507,7 @@ hledger-lsp/
|
|
|
507
507
|
│ ├── features/ # LSP feature implementations
|
|
508
508
|
│ ├── server/ # Server infrastructure
|
|
509
509
|
│ └── utils/ # Utility functions
|
|
510
|
-
├── tests/ # Test suite (
|
|
510
|
+
├── tests/ # Test suite (1380+ test cases)
|
|
511
511
|
├── out/ # Compiled JavaScript output
|
|
512
512
|
└── package.json
|
|
513
513
|
```
|
|
@@ -545,11 +545,14 @@ npx jest --testNamePattern="balance"
|
|
|
545
545
|
|
|
546
546
|
### Developing with the VS Code extension
|
|
547
547
|
|
|
548
|
-
When working on the language server and the VS Code extension together you have
|
|
548
|
+
When working on the language server and the VS Code extension together you have
|
|
549
|
+
two convenient workflows:
|
|
549
550
|
|
|
550
551
|
- Preferred: sibling local build
|
|
551
552
|
|
|
552
|
-
If you have the `hledger-vscode` extension checked out next to this repo (as
|
|
553
|
+
If you have the `hledger-vscode` extension checked out next to this repo (as
|
|
554
|
+
siblings), the extension will prefer a local built server at
|
|
555
|
+
`../hledger-lsp/out/server.js`.
|
|
553
556
|
|
|
554
557
|
Steps:
|
|
555
558
|
|
|
@@ -565,11 +568,14 @@ When working on the language server and the VS Code extension together you have
|
|
|
565
568
|
npm run compile
|
|
566
569
|
```
|
|
567
570
|
|
|
568
|
-
Then open the `hledger-vscode` folder in VS Code and press F5 to launch the
|
|
571
|
+
Then open the `hledger-vscode` folder in VS Code and press F5 to launch the
|
|
572
|
+
Extension Development Host. The extension will detect the local
|
|
573
|
+
`out/server.js` and use it when starting the language client.
|
|
569
574
|
|
|
570
575
|
- Alternative: `npm link`
|
|
571
576
|
|
|
572
|
-
If you prefer to keep the projects separate or want the extension to pick up a
|
|
577
|
+
If you prefer to keep the projects separate or want the extension to pick up a
|
|
578
|
+
locally-installed (linked) package, use `npm link`:
|
|
573
579
|
|
|
574
580
|
```bash
|
|
575
581
|
# In language server repo
|
|
@@ -583,34 +589,44 @@ When working on the language server and the VS Code extension together you have
|
|
|
583
589
|
npm run compile
|
|
584
590
|
```
|
|
585
591
|
|
|
586
|
-
This makes `require.resolve('hledger-lsp/out/server.js')` resolve to your
|
|
592
|
+
This makes `require.resolve('hledger-lsp/out/server.js')` resolve to your
|
|
593
|
+
local linked package.
|
|
587
594
|
|
|
588
595
|
Notes and tips
|
|
589
596
|
|
|
590
|
-
- After building the server and extension, use **Developer: Reload Window** in
|
|
591
|
-
|
|
597
|
+
- After building the server and extension, use **Developer: Reload Window** in
|
|
598
|
+
the extension host or the `hledgerLanguageServer.reload` command (provided by
|
|
599
|
+
the extension) to restart the language client so changes propagate.
|
|
600
|
+
- The server now logs the semantic token legend on initialize. Open
|
|
601
|
+
**View → Output** and select the `hledger Language Server` output channel to
|
|
602
|
+
see messages such as:
|
|
592
603
|
|
|
593
604
|
Semantic tokens legend: {"tokenTypes":["namespace","keyword","class","variable","property","type","number","string","comment","operator"],"tokenModifiers":["declaration","readonly","deprecated"]}
|
|
594
605
|
|
|
595
606
|
- Running tests:
|
|
596
607
|
- Server tests (in `hledger-lsp`): `npm test` (or `npx jest <path>`)
|
|
597
|
-
- Extension tests (in `hledger-vscode`): `npm test` — these use mocked
|
|
598
|
-
|
|
599
|
-
|
|
608
|
+
- Extension tests (in `hledger-vscode`): `npm test` — these use mocked
|
|
609
|
+
`vscode` and `vscode-languageclient` modules so they don't require a real
|
|
610
|
+
server binary.
|
|
600
611
|
|
|
612
|
+
If you want an explicit server path override, set up a quick environment
|
|
613
|
+
variable in your debug launch configuration or use `npm link` as described above.
|
|
601
614
|
|
|
602
615
|
## Contributing
|
|
603
616
|
|
|
604
617
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
605
618
|
|
|
606
|
-
|
|
619
|
+
For bug reports and feature requests, [open an issue](https://github.com/ptimoney/hledger-lsp/issues).
|
|
607
620
|
|
|
608
|
-
|
|
621
|
+
## Related Projects
|
|
622
|
+
|
|
623
|
+
| Project | Description |
|
|
624
|
+
|---------|-------------|
|
|
625
|
+
| [hledger-vscode](https://github.com/ptimoney/hledger-vscode) | VS Code extension — install from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=patrickt.hledger-lsp-vscode) |
|
|
626
|
+
| [hledger-nvim](https://github.com/ptimoney/hledger-nvim) | Neovim plugin with LSP integration and workspace graph |
|
|
627
|
+
| [hledger](https://hledger.org/) | The plain text accounting tool this server supports |
|
|
628
|
+
| [LSP Specification](https://microsoft.github.io/language-server-protocol/) | The protocol this server implements |
|
|
609
629
|
|
|
610
|
-
##
|
|
630
|
+
## License
|
|
611
631
|
|
|
612
|
-
|
|
613
|
-
- **Neovim Plugin**: [hledger-nvim](https://github.com/ptimoney/hledger-nvim)
|
|
614
|
-
- **Report Issues**: [GitHub Issues](https://github.com/ptimoney/hledger-lsp/issues)
|
|
615
|
-
- **hledger**: [Official Documentation](https://hledger.org/)
|
|
616
|
-
- **LSP Specification**: [Language Server Protocol](https://microsoft.github.io/language-server-protocol/)
|
|
632
|
+
MIT
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call Hierarchy provider for hledger journal files.
|
|
3
|
+
*
|
|
4
|
+
* Maps include relationships onto LSP Call Hierarchy:
|
|
5
|
+
* - "Incoming calls" = files that include this file
|
|
6
|
+
* - "Outgoing calls" = files this file includes
|
|
7
|
+
*
|
|
8
|
+
* This gives users built-in editor navigation (VS Code Call Hierarchy pane,
|
|
9
|
+
* Neovim LSP call hierarchy pickers) with no client-side code needed.
|
|
10
|
+
*/
|
|
11
|
+
import { CallHierarchyItem, CallHierarchyIncomingCall, CallHierarchyOutgoingCall } from 'vscode-languageserver/node';
|
|
12
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
13
|
+
import { ParsedDocument, FileReader } from '../types';
|
|
14
|
+
import { WorkspaceManager } from '../server/workspace';
|
|
15
|
+
export declare class CallHierarchyProvider {
|
|
16
|
+
/**
|
|
17
|
+
* Prepare call hierarchy items at the given position.
|
|
18
|
+
*
|
|
19
|
+
* - If the cursor is on an include directive line: return item(s) for the included file(s)
|
|
20
|
+
* - Otherwise: return a CallHierarchyItem for the current file
|
|
21
|
+
* - Returns null if the file isn't in the workspace
|
|
22
|
+
*/
|
|
23
|
+
prepareCallHierarchy(document: TextDocument, line: number, _character: number, parsedDoc: ParsedDocument, workspaceManager: WorkspaceManager): CallHierarchyItem[] | null;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve incoming calls (files that include the given item's file).
|
|
26
|
+
*/
|
|
27
|
+
resolveIncomingCalls(item: CallHierarchyItem, workspaceManager: WorkspaceManager, fileReader: FileReader): CallHierarchyIncomingCall[] | null;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve outgoing calls (files that the given item's file includes).
|
|
30
|
+
*/
|
|
31
|
+
resolveOutgoingCalls(item: CallHierarchyItem, workspaceManager: WorkspaceManager, fileReader: FileReader): CallHierarchyOutgoingCall[] | null;
|
|
32
|
+
}
|
|
33
|
+
export declare const callHierarchyProvider: CallHierarchyProvider;
|
|
34
|
+
//# sourceMappingURL=callHierarchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callHierarchy.d.ts","sourceRoot":"","sources":["../../src/features/callHierarchy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EAG1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGlE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0BvD,qBAAa,qBAAqB;IAChC;;;;;;OAMG;IACH,oBAAoB,CAClB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,cAAc,EACzB,gBAAgB,EAAE,gBAAgB,GACjC,iBAAiB,EAAE,GAAG,IAAI;IAwC7B;;OAEG;IACH,oBAAoB,CAClB,IAAI,EAAE,iBAAiB,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,GACrB,yBAAyB,EAAE,GAAG,IAAI;IA2CrC;;OAEG;IACH,oBAAoB,CAClB,IAAI,EAAE,iBAAiB,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,GACrB,yBAAyB,EAAE,GAAG,IAAI;CAqDtC;AAED,eAAO,MAAM,qBAAqB,uBAA8B,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Call Hierarchy provider for hledger journal files.
|
|
4
|
+
*
|
|
5
|
+
* Maps include relationships onto LSP Call Hierarchy:
|
|
6
|
+
* - "Incoming calls" = files that include this file
|
|
7
|
+
* - "Outgoing calls" = files this file includes
|
|
8
|
+
*
|
|
9
|
+
* This gives users built-in editor navigation (VS Code Call Hierarchy pane,
|
|
10
|
+
* Neovim LSP call hierarchy pickers) with no client-side code needed.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.callHierarchyProvider = exports.CallHierarchyProvider = void 0;
|
|
47
|
+
const node_1 = require("vscode-languageserver/node");
|
|
48
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const includeRange_1 = require("../utils/includeRange");
|
|
51
|
+
const uri_1 = require("../utils/uri");
|
|
52
|
+
/**
|
|
53
|
+
* Create a CallHierarchyItem for a file URI.
|
|
54
|
+
*/
|
|
55
|
+
function createFileItem(fileUri) {
|
|
56
|
+
const filePath = (0, uri_1.toFilePath)(fileUri);
|
|
57
|
+
const name = path.basename(filePath);
|
|
58
|
+
// Use the full range of the file (line 0, char 0) since we represent the whole file
|
|
59
|
+
const wholeFileRange = {
|
|
60
|
+
start: { line: 0, character: 0 },
|
|
61
|
+
end: { line: 0, character: 0 }
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
name,
|
|
65
|
+
kind: node_1.SymbolKind.File,
|
|
66
|
+
uri: fileUri.toString(),
|
|
67
|
+
detail: filePath,
|
|
68
|
+
range: wholeFileRange,
|
|
69
|
+
selectionRange: wholeFileRange,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
class CallHierarchyProvider {
|
|
73
|
+
/**
|
|
74
|
+
* Prepare call hierarchy items at the given position.
|
|
75
|
+
*
|
|
76
|
+
* - If the cursor is on an include directive line: return item(s) for the included file(s)
|
|
77
|
+
* - Otherwise: return a CallHierarchyItem for the current file
|
|
78
|
+
* - Returns null if the file isn't in the workspace
|
|
79
|
+
*/
|
|
80
|
+
prepareCallHierarchy(document, line, _character, parsedDoc, workspaceManager) {
|
|
81
|
+
const documentUri = vscode_uri_1.URI.parse(document.uri);
|
|
82
|
+
if (!workspaceManager.isKnownFile(documentUri)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const lines = document.getText().split('\n');
|
|
86
|
+
const lineText = lines[line];
|
|
87
|
+
// Check if we're on an include directive line
|
|
88
|
+
if (lineText !== undefined) {
|
|
89
|
+
const includeDirectives = parsedDoc.directives.filter(d => d.type === 'include' && d.line === line && d.sourceUri?.toString() === documentUri.toString());
|
|
90
|
+
if (includeDirectives.length > 0) {
|
|
91
|
+
// Get the resolved targets for these include directives
|
|
92
|
+
const allDirectives = workspaceManager.getIncludeDirectivesForFile(documentUri);
|
|
93
|
+
const items = [];
|
|
94
|
+
for (const directive of includeDirectives) {
|
|
95
|
+
const matched = allDirectives.find(d => d.directive.line === directive.line);
|
|
96
|
+
if (matched) {
|
|
97
|
+
for (const targetUri of matched.targets) {
|
|
98
|
+
items.push(createFileItem(targetUri));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (items.length > 0) {
|
|
103
|
+
return items;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Default: return the current file
|
|
108
|
+
return [createFileItem(documentUri)];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolve incoming calls (files that include the given item's file).
|
|
112
|
+
*/
|
|
113
|
+
resolveIncomingCalls(item, workspaceManager, fileReader) {
|
|
114
|
+
const itemUri = vscode_uri_1.URI.parse(item.uri);
|
|
115
|
+
const parentUris = workspaceManager.getFilesIncluding(itemUri);
|
|
116
|
+
if (parentUris.length === 0) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
const result = [];
|
|
120
|
+
for (const parentUri of parentUris) {
|
|
121
|
+
const parentDoc = fileReader(parentUri);
|
|
122
|
+
if (!parentDoc)
|
|
123
|
+
continue;
|
|
124
|
+
const parentLines = parentDoc.getText().split('\n');
|
|
125
|
+
const fromRanges = [];
|
|
126
|
+
// Find include directive lines in parent that point to this file
|
|
127
|
+
const parentDirectives = workspaceManager.getIncludeDirectivesForFile(parentUri);
|
|
128
|
+
for (const { directive, targets } of parentDirectives) {
|
|
129
|
+
const pointsToItem = targets.some(t => t.toString() === itemUri.toString());
|
|
130
|
+
if (pointsToItem && directive.line !== undefined) {
|
|
131
|
+
const lineText = parentLines[directive.line];
|
|
132
|
+
if (lineText) {
|
|
133
|
+
const includeRange = (0, includeRange_1.getIncludePathRange)(lineText, directive.line);
|
|
134
|
+
if (includeRange) {
|
|
135
|
+
fromRanges.push(includeRange.range);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (fromRanges.length > 0) {
|
|
141
|
+
result.push({
|
|
142
|
+
from: createFileItem(parentUri),
|
|
143
|
+
fromRanges,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Resolve outgoing calls (files that the given item's file includes).
|
|
151
|
+
*/
|
|
152
|
+
resolveOutgoingCalls(item, workspaceManager, fileReader) {
|
|
153
|
+
const sourceUri = vscode_uri_1.URI.parse(item.uri);
|
|
154
|
+
const directives = workspaceManager.getIncludeDirectivesForFile(sourceUri);
|
|
155
|
+
if (directives.length === 0) {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
const sourceDoc = fileReader(sourceUri);
|
|
159
|
+
if (!sourceDoc)
|
|
160
|
+
return [];
|
|
161
|
+
const sourceLines = sourceDoc.getText().split('\n');
|
|
162
|
+
// Group by target URI since glob includes can resolve to multiple files with same directive range
|
|
163
|
+
const targetMap = new Map();
|
|
164
|
+
for (const { directive, targets } of directives) {
|
|
165
|
+
if (directive.line === undefined)
|
|
166
|
+
continue;
|
|
167
|
+
const lineText = sourceLines[directive.line];
|
|
168
|
+
if (!lineText)
|
|
169
|
+
continue;
|
|
170
|
+
const includeRange = (0, includeRange_1.getIncludePathRange)(lineText, directive.line);
|
|
171
|
+
if (!includeRange)
|
|
172
|
+
continue;
|
|
173
|
+
for (const targetUri of targets) {
|
|
174
|
+
const key = targetUri.toString();
|
|
175
|
+
let entry = targetMap.get(key);
|
|
176
|
+
if (!entry) {
|
|
177
|
+
entry = { uri: targetUri, fromRanges: [] };
|
|
178
|
+
targetMap.set(key, entry);
|
|
179
|
+
}
|
|
180
|
+
// Avoid duplicate ranges (same directive pointing to same target)
|
|
181
|
+
const alreadyHas = entry.fromRanges.some(r => r.start.line === includeRange.range.start.line &&
|
|
182
|
+
r.start.character === includeRange.range.start.character);
|
|
183
|
+
if (!alreadyHas) {
|
|
184
|
+
entry.fromRanges.push(includeRange.range);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const result = [];
|
|
189
|
+
for (const { uri, fromRanges } of targetMap.values()) {
|
|
190
|
+
result.push({
|
|
191
|
+
to: createFileItem(uri),
|
|
192
|
+
fromRanges,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.CallHierarchyProvider = CallHierarchyProvider;
|
|
199
|
+
exports.callHierarchyProvider = new CallHierarchyProvider();
|
|
200
|
+
//# sourceMappingURL=callHierarchy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callHierarchy.js","sourceRoot":"","sources":["../../src/features/callHierarchy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAMoC;AAEpC,2CAAiC;AACjC,2CAA6B;AAG7B,wDAA4D;AAC5D,sCAA0C;AAE1C;;GAEG;AACH,SAAS,cAAc,CAAC,OAAY;IAClC,MAAM,QAAQ,GAAG,IAAA,gBAAU,EAAC,OAAO,CAAC,CAAC;IACrC,MAAM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AAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI;oBAC9C,CAAC,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAC9D,CAAC;gBACF,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC;gBACvB,UAAU;aACX,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AApKD,sDAoKC;AAEY,QAAA,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLinks.d.ts","sourceRoot":"","sources":["../../src/features/documentLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"documentLinks.d.ts","sourceRoot":"","sources":["../../src/features/documentLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C,qBAAa,qBAAqB;IAChC;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,GAAG,YAAY,EAAE;CA0BxF;AAED,eAAO,MAAM,qBAAqB,uBAA8B,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.documentLinksProvider = exports.DocumentLinksProvider = void 0;
|
|
10
10
|
const uri_1 = require("../utils/uri");
|
|
11
|
+
const includeRange_1 = require("../utils/includeRange");
|
|
11
12
|
const vscode_uri_1 = require("vscode-uri");
|
|
12
13
|
class DocumentLinksProvider {
|
|
13
14
|
/**
|
|
@@ -23,41 +24,13 @@ class DocumentLinksProvider {
|
|
|
23
24
|
const line = lines[directive.line];
|
|
24
25
|
if (!line)
|
|
25
26
|
continue;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const keywordIndex = line.indexOf(includeKeyword);
|
|
29
|
-
if (keywordIndex === -1)
|
|
30
|
-
continue;
|
|
31
|
-
// The path starts after 'include ' (with space)
|
|
32
|
-
const pathStart = keywordIndex + includeKeyword.length;
|
|
33
|
-
// Skip whitespace after 'include'
|
|
34
|
-
let actualPathStart = pathStart;
|
|
35
|
-
while (actualPathStart < line.length && /\s/.test(line[actualPathStart])) {
|
|
36
|
-
actualPathStart++;
|
|
37
|
-
}
|
|
38
|
-
// Find the end of the path (end of line or start of comment)
|
|
39
|
-
let pathEnd = actualPathStart;
|
|
40
|
-
while (pathEnd < line.length) {
|
|
41
|
-
const char = line[pathEnd];
|
|
42
|
-
if (char === ';' || char === '#') {
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
pathEnd++;
|
|
46
|
-
}
|
|
47
|
-
// Trim trailing whitespace
|
|
48
|
-
while (pathEnd > actualPathStart && /\s/.test(line[pathEnd - 1])) {
|
|
49
|
-
pathEnd--;
|
|
50
|
-
}
|
|
51
|
-
const includePath = line.substring(actualPathStart, pathEnd).trim();
|
|
52
|
-
if (!includePath)
|
|
27
|
+
const includeRange = (0, includeRange_1.getIncludePathRange)(line, directive.line);
|
|
28
|
+
if (!includeRange)
|
|
53
29
|
continue;
|
|
54
30
|
// Resolve the include path to a full URI
|
|
55
|
-
const resolvedUri = (0, uri_1.resolveIncludePath)(
|
|
31
|
+
const resolvedUri = (0, uri_1.resolveIncludePath)(includeRange.path, documentUri);
|
|
56
32
|
links.push({
|
|
57
|
-
range:
|
|
58
|
-
start: { line: directive.line, character: actualPathStart },
|
|
59
|
-
end: { line: directive.line, character: pathEnd }
|
|
60
|
-
},
|
|
33
|
+
range: includeRange.range,
|
|
61
34
|
target: resolvedUri.toString()
|
|
62
35
|
});
|
|
63
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLinks.js","sourceRoot":"","sources":["../../src/features/documentLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,sCAAkD;AAClD,2CAAiC;AAEjC,MAAa,qBAAqB;IAChC;;OAEG;IACH,oBAAoB,CAAC,QAAsB,EAAE,SAAyB;QACpE,MAAM,KAAK,GAAmB,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,WAAW,GAAQ,gBAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEjD,0CAA0C;QAC1C,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;YAC7C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACjE,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACnC,IAAI,CAAC,IAAI;oBAAE,SAAS;gBAEpB,
|
|
1
|
+
{"version":3,"file":"documentLinks.js","sourceRoot":"","sources":["../../src/features/documentLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,sCAAkD;AAClD,wDAA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