hledger-lsp 0.1.2 → 0.1.6
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 +91 -173
- package/out/features/codeActions.d.ts +16 -0
- package/out/features/codeActions.d.ts.map +1 -1
- package/out/features/codeActions.js +129 -0
- package/out/features/codeActions.js.map +1 -1
- package/out/features/codeLens.d.ts +29 -0
- package/out/features/codeLens.d.ts.map +1 -0
- package/out/features/codeLens.js +102 -0
- package/out/features/codeLens.js.map +1 -0
- package/out/features/completion.d.ts +16 -4
- package/out/features/completion.d.ts.map +1 -1
- package/out/features/completion.js +23 -10
- package/out/features/completion.js.map +1 -1
- package/out/features/definition.d.ts.map +1 -1
- package/out/features/definition.js +4 -4
- package/out/features/definition.js.map +1 -1
- package/out/features/foldingRanges.d.ts.map +1 -1
- package/out/features/foldingRanges.js +6 -2
- package/out/features/foldingRanges.js.map +1 -1
- package/out/features/formatter.d.ts +4 -20
- package/out/features/formatter.d.ts.map +1 -1
- package/out/features/formatter.js +271 -223
- package/out/features/formatter.js.map +1 -1
- package/out/features/formattingUtils.d.ts +38 -0
- package/out/features/formattingUtils.d.ts.map +1 -0
- package/out/features/formattingUtils.js +107 -0
- package/out/features/formattingUtils.js.map +1 -0
- package/out/features/hover.d.ts +0 -4
- package/out/features/hover.d.ts.map +1 -1
- package/out/features/hover.js +11 -20
- package/out/features/hover.js.map +1 -1
- package/out/features/inlayHints.d.ts +12 -6
- package/out/features/inlayHints.d.ts.map +1 -1
- package/out/features/inlayHints.js +202 -84
- package/out/features/inlayHints.js.map +1 -1
- package/out/features/semanticTokens.d.ts.map +1 -1
- package/out/features/semanticTokens.js +17 -14
- package/out/features/semanticTokens.js.map +1 -1
- package/out/features/symbols.d.ts.map +1 -1
- package/out/features/symbols.js +8 -5
- package/out/features/symbols.js.map +1 -1
- package/out/features/validator.d.ts +5 -4
- package/out/features/validator.d.ts.map +1 -1
- package/out/features/validator.js +145 -105
- package/out/features/validator.js.map +1 -1
- package/out/parser/ast.d.ts +48 -7
- package/out/parser/ast.d.ts.map +1 -1
- package/out/parser/ast.js +552 -363
- package/out/parser/ast.js.map +1 -1
- package/out/parser/document.d.ts +7 -0
- package/out/parser/document.d.ts.map +1 -0
- package/out/parser/document.js +70 -0
- package/out/parser/document.js.map +1 -0
- package/out/parser/includes.d.ts.map +1 -1
- package/out/parser/includes.js +21 -33
- package/out/parser/includes.js.map +1 -1
- package/out/parser/index.d.ts +8 -5
- package/out/parser/index.d.ts.map +1 -1
- package/out/parser/index.js +39 -14
- package/out/parser/index.js.map +1 -1
- package/out/server/configFile.d.ts +104 -0
- package/out/server/configFile.d.ts.map +1 -0
- package/out/server/configFile.js +231 -0
- package/out/server/configFile.js.map +1 -0
- package/out/server/settings.d.ts +13 -0
- package/out/server/settings.d.ts.map +1 -1
- package/out/server/settings.js +13 -3
- package/out/server/settings.js.map +1 -1
- package/out/server/workspace.d.ts +126 -0
- package/out/server/workspace.d.ts.map +1 -0
- package/out/server/workspace.js +599 -0
- package/out/server/workspace.js.map +1 -0
- package/out/server.js +435 -27
- package/out/server.js.map +1 -1
- package/out/types.d.ts +27 -12
- package/out/types.d.ts.map +1 -1
- package/out/types.js +12 -0
- package/out/types.js.map +1 -1
- package/out/utils/amountFormatter.d.ts +14 -0
- package/out/utils/amountFormatter.d.ts.map +1 -0
- package/out/utils/amountFormatter.js +55 -0
- package/out/utils/amountFormatter.js.map +1 -0
- package/out/utils/balanceCalculator.d.ts +32 -0
- package/out/utils/balanceCalculator.d.ts.map +1 -0
- package/out/utils/balanceCalculator.js +93 -0
- package/out/utils/balanceCalculator.js.map +1 -0
- package/out/utils/index.js +1 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration file support for hledger LSP
|
|
4
|
+
*
|
|
5
|
+
* Allows users to specify workspace configuration via .hledger-lsp.json files.
|
|
6
|
+
* Config files can be placed at any level in the directory hierarchy and are
|
|
7
|
+
* discovered by walking up from the document location.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.discoverConfigFile = discoverConfigFile;
|
|
44
|
+
exports.loadConfigFile = loadConfigFile;
|
|
45
|
+
exports.resolveRootFile = resolveRootFile;
|
|
46
|
+
exports.mergeConfig = mergeConfig;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const uri_1 = require("../utils/uri");
|
|
50
|
+
/**
|
|
51
|
+
* Default configuration values
|
|
52
|
+
*/
|
|
53
|
+
const DEFAULT_CONFIG = {
|
|
54
|
+
rootFile: undefined, // No default root file
|
|
55
|
+
include: ['**/*.journal', '**/*.hledger'],
|
|
56
|
+
exclude: ['**/node_modules/**', '**/.git/**', '**/.*'],
|
|
57
|
+
workspace: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
eagerParsing: true,
|
|
60
|
+
autoDetectRoot: true
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Discover .hledger-lsp.json by walking up the directory tree
|
|
65
|
+
*
|
|
66
|
+
* @param startUri - URI of the document to start searching from
|
|
67
|
+
* @param workspaceRoot - URI of the workspace root (optional, stops search here)
|
|
68
|
+
* @returns Path to the config file, or null if not found
|
|
69
|
+
*/
|
|
70
|
+
function discoverConfigFile(startUri, workspaceRoot) {
|
|
71
|
+
let currentDir = path.dirname((0, uri_1.toFilePath)(startUri));
|
|
72
|
+
const workspaceRootPath = workspaceRoot ? (0, uri_1.toFilePath)(workspaceRoot) : null;
|
|
73
|
+
// Walk up the directory tree
|
|
74
|
+
while (true) {
|
|
75
|
+
const configPath = path.join(currentDir, '.hledger-lsp.json');
|
|
76
|
+
if (fs.existsSync(configPath)) {
|
|
77
|
+
return configPath;
|
|
78
|
+
}
|
|
79
|
+
// Stop at workspace root if provided
|
|
80
|
+
if (workspaceRootPath && currentDir === workspaceRootPath) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
// Stop at filesystem root
|
|
84
|
+
const parentDir = path.dirname(currentDir);
|
|
85
|
+
if (parentDir === currentDir) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
currentDir = parentDir;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Load and validate a config file
|
|
94
|
+
*
|
|
95
|
+
* @param configPath - Absolute path to the config file
|
|
96
|
+
* @returns Loaded configuration with validation warnings
|
|
97
|
+
* @throws Error if the config file is invalid JSON or cannot be read
|
|
98
|
+
*/
|
|
99
|
+
function loadConfigFile(configPath) {
|
|
100
|
+
const warnings = [];
|
|
101
|
+
// Read and parse JSON
|
|
102
|
+
let rawConfig;
|
|
103
|
+
try {
|
|
104
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
105
|
+
rawConfig = JSON.parse(content);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error instanceof SyntaxError) {
|
|
109
|
+
throw new Error(`Invalid JSON in ${configPath}: ${error.message}`);
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`Failed to read ${configPath}: ${error}`);
|
|
112
|
+
}
|
|
113
|
+
// Validate and normalize config
|
|
114
|
+
const config = {};
|
|
115
|
+
// Validate rootFile
|
|
116
|
+
if (rawConfig.rootFile !== undefined) {
|
|
117
|
+
if (typeof rawConfig.rootFile !== 'string') {
|
|
118
|
+
warnings.push('rootFile should be a string, ignoring');
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
config.rootFile = rawConfig.rootFile;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Validate include
|
|
125
|
+
if (rawConfig.include !== undefined) {
|
|
126
|
+
if (!Array.isArray(rawConfig.include)) {
|
|
127
|
+
warnings.push('include should be an array, using defaults');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const validPatterns = rawConfig.include.filter((p) => typeof p === 'string');
|
|
131
|
+
if (validPatterns.length !== rawConfig.include.length) {
|
|
132
|
+
warnings.push('Some include patterns are not strings, ignoring them');
|
|
133
|
+
}
|
|
134
|
+
config.include = validPatterns.length > 0 ? validPatterns : DEFAULT_CONFIG.include;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Validate exclude
|
|
138
|
+
if (rawConfig.exclude !== undefined) {
|
|
139
|
+
if (!Array.isArray(rawConfig.exclude)) {
|
|
140
|
+
warnings.push('exclude should be an array, using defaults');
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const validPatterns = rawConfig.exclude.filter((p) => typeof p === 'string');
|
|
144
|
+
if (validPatterns.length !== rawConfig.exclude.length) {
|
|
145
|
+
warnings.push('Some exclude patterns are not strings, ignoring them');
|
|
146
|
+
}
|
|
147
|
+
config.exclude = validPatterns.length > 0 ? validPatterns : DEFAULT_CONFIG.exclude;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Validate workspace settings
|
|
151
|
+
if (rawConfig.workspace !== undefined) {
|
|
152
|
+
if (typeof rawConfig.workspace !== 'object' || rawConfig.workspace === null) {
|
|
153
|
+
warnings.push('workspace should be an object, using defaults');
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
config.workspace = {};
|
|
157
|
+
if (rawConfig.workspace.enabled !== undefined) {
|
|
158
|
+
if (typeof rawConfig.workspace.enabled !== 'boolean') {
|
|
159
|
+
warnings.push('workspace.enabled should be a boolean, using default');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
config.workspace.enabled = rawConfig.workspace.enabled;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (rawConfig.workspace.eagerParsing !== undefined) {
|
|
166
|
+
if (typeof rawConfig.workspace.eagerParsing !== 'boolean') {
|
|
167
|
+
warnings.push('workspace.eagerParsing should be a boolean, using default');
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
config.workspace.eagerParsing = rawConfig.workspace.eagerParsing;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (rawConfig.workspace.autoDetectRoot !== undefined) {
|
|
174
|
+
if (typeof rawConfig.workspace.autoDetectRoot !== 'boolean') {
|
|
175
|
+
warnings.push('workspace.autoDetectRoot should be a boolean, using default');
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
config.workspace.autoDetectRoot = rawConfig.workspace.autoDetectRoot;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const configDir = path.dirname(configPath);
|
|
184
|
+
return {
|
|
185
|
+
config,
|
|
186
|
+
configPath,
|
|
187
|
+
configDir,
|
|
188
|
+
warnings
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Resolve root file path relative to config directory
|
|
193
|
+
*
|
|
194
|
+
* @param config - The loaded configuration
|
|
195
|
+
* @param configDir - Directory containing the config file
|
|
196
|
+
* @returns Absolute file URI, or null if not configured
|
|
197
|
+
*/
|
|
198
|
+
function resolveRootFile(config, configDir) {
|
|
199
|
+
if (!config.rootFile) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const absPath = path.isAbsolute(config.rootFile)
|
|
203
|
+
? config.rootFile
|
|
204
|
+
: path.resolve(configDir, config.rootFile);
|
|
205
|
+
return (0, uri_1.toFileUri)(absPath);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Merge configuration from file with runtime settings
|
|
209
|
+
*
|
|
210
|
+
* Priority (highest to lowest):
|
|
211
|
+
* 1. Runtime settings (from VS Code configuration)
|
|
212
|
+
* 2. Config file settings
|
|
213
|
+
* 3. Default settings
|
|
214
|
+
*
|
|
215
|
+
* @param fileConfig - Configuration from .hledger-lsp.json
|
|
216
|
+
* @param runtimeSettings - Settings from VS Code
|
|
217
|
+
* @returns Merged configuration
|
|
218
|
+
*/
|
|
219
|
+
function mergeConfig(fileConfig, runtimeSettings) {
|
|
220
|
+
return {
|
|
221
|
+
rootFile: runtimeSettings?.rootFile ?? fileConfig.rootFile ?? DEFAULT_CONFIG.rootFile,
|
|
222
|
+
include: runtimeSettings?.include ?? fileConfig.include ?? DEFAULT_CONFIG.include,
|
|
223
|
+
exclude: runtimeSettings?.exclude ?? fileConfig.exclude ?? DEFAULT_CONFIG.exclude,
|
|
224
|
+
workspace: {
|
|
225
|
+
enabled: runtimeSettings?.workspace?.enabled ?? fileConfig.workspace?.enabled ?? DEFAULT_CONFIG.workspace.enabled,
|
|
226
|
+
eagerParsing: runtimeSettings?.workspace?.eagerParsing ?? fileConfig.workspace?.eagerParsing ?? DEFAULT_CONFIG.workspace.eagerParsing,
|
|
227
|
+
autoDetectRoot: runtimeSettings?.workspace?.autoDetectRoot ?? fileConfig.workspace?.autoDetectRoot ?? DEFAULT_CONFIG.workspace.autoDetectRoot
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=configFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../src/server/configFile.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FH,gDA2BC;AASD,wCA8FC;AASD,0CASC;AAcD,kCAcC;AA3QD,uCAAyB;AACzB,2CAA6B;AAC7B,sCAAqD;AAsDrD;;GAEG;AACH,MAAM,cAAc,GAA+B;IACjD,QAAQ,EAAE,SAAgB,EAAE,uBAAuB;IACnD,OAAO,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,OAAO,CAAC;IACtD,SAAS,EAAE;QACT,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;KACrB;CACF,CAAC;AAgBF;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,QAAgB,EAAE,aAAsB;IACzE,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAA,gBAAU,EAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,MAAM,iBAAiB,GAAG,aAAa,CAAC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AAI,cAAc,CAAC,OAAO;QACjF,SAAS,EAAE;YACT,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,IAAI,cAAc,CAAC,SAAS,CAAC,OAAO;YACjH,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,IAAI,UAAU,CAAC,SAAS,EAAE,YAAY,IAAI,cAAc,CAAC,SAAS,CAAC,YAAY;YACrI,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,IAAI,UAAU,CAAC,SAAS,EAAE,cAAc,IAAI,cAAc,CAAC,SAAS,CAAC,cAAc;SAC9I;KACF,CAAC;AACJ,CAAC"}
|
package/out/server/settings.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface HledgerSettings {
|
|
|
17
17
|
emptyDescriptions?: boolean;
|
|
18
18
|
includeFiles?: boolean;
|
|
19
19
|
circularIncludes?: boolean;
|
|
20
|
+
markAllUndeclaredInstances?: boolean;
|
|
20
21
|
};
|
|
21
22
|
severity?: {
|
|
22
23
|
undeclaredAccounts?: 'error' | 'warning' | 'information' | 'hint';
|
|
@@ -48,8 +49,20 @@ export interface HledgerSettings {
|
|
|
48
49
|
showRunningBalances?: boolean;
|
|
49
50
|
showCostConversions?: boolean;
|
|
50
51
|
};
|
|
52
|
+
codeLens?: {
|
|
53
|
+
showTransactionCounts?: boolean;
|
|
54
|
+
};
|
|
55
|
+
workspace?: {
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
eagerParsing?: boolean;
|
|
58
|
+
autoDetectRoot?: boolean;
|
|
59
|
+
};
|
|
51
60
|
}
|
|
52
61
|
export declare const defaultSettings: HledgerSettings;
|
|
62
|
+
/**
|
|
63
|
+
* Deep merge two objects, with values from 'source' overriding 'target'
|
|
64
|
+
*/
|
|
65
|
+
export declare function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T;
|
|
53
66
|
/**
|
|
54
67
|
* Get settings for a document. If the client does not support workspace/configuration
|
|
55
68
|
* the default settings are returned.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAChC,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,qBA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AAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,2BAA2B,CAAC,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,UAAU,CAAC,EAAE;QACX,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,qBAAqB,CAAC,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,eA0D7B,CAAC;AAKF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAmBzF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,0BAA0B,EAAE,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,CAqB5I;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
package/out/server/settings.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultSettings = void 0;
|
|
4
|
+
exports.deepMerge = deepMerge;
|
|
4
5
|
exports.getDocumentSettings = getDocumentSettings;
|
|
5
6
|
exports.clearDocumentSettings = clearDocumentSettings;
|
|
6
7
|
exports.clearAllDocumentSettings = clearAllDocumentSettings;
|
|
@@ -22,6 +23,7 @@ exports.defaultSettings = {
|
|
|
22
23
|
emptyDescriptions: true,
|
|
23
24
|
includeFiles: true,
|
|
24
25
|
circularIncludes: true,
|
|
26
|
+
markAllUndeclaredInstances: true,
|
|
25
27
|
},
|
|
26
28
|
severity: {
|
|
27
29
|
undeclaredAccounts: 'warning',
|
|
@@ -49,9 +51,17 @@ exports.defaultSettings = {
|
|
|
49
51
|
assertionDecimalAlignColumn: 70,
|
|
50
52
|
},
|
|
51
53
|
inlayHints: {
|
|
52
|
-
showInferredAmounts:
|
|
53
|
-
showRunningBalances:
|
|
54
|
-
showCostConversions:
|
|
54
|
+
showInferredAmounts: false,
|
|
55
|
+
showRunningBalances: false,
|
|
56
|
+
showCostConversions: false,
|
|
57
|
+
},
|
|
58
|
+
codeLens: {
|
|
59
|
+
showTransactionCounts: false,
|
|
60
|
+
},
|
|
61
|
+
workspace: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
eagerParsing: true,
|
|
64
|
+
autoDetectRoot: true,
|
|
55
65
|
}
|
|
56
66
|
};
|
|
57
67
|
// Cache the settings of all open documents
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":";;;AAgIA,8BAmBC;AAMD,kDAqBC;AAED,sDAEC;AAED,4DAEC;AAxHY,QAAA,eAAe,GAAoB;IAC9C,mBAAmB,EAAE,IAAI;IACzB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,KAAK;QACvB,qBAAqB,EAAE,IAAI;QAC3B,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAA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B,6CAA6C,QAAQ,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,CAC/F,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,qBAAqB,CAAC,QAAgB;IACpD,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,wBAAwB;IACtC,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Connection } from 'vscode-languageserver/node';
|
|
2
|
+
import { HledgerParser, FileReader } from '../parser/index';
|
|
3
|
+
import { ParsedDocument } from '../types';
|
|
4
|
+
import { HledgerLspConfig } from './configFile';
|
|
5
|
+
export declare class WorkspaceManager {
|
|
6
|
+
private workspaceFolders;
|
|
7
|
+
private journalFiles;
|
|
8
|
+
private includeGraph;
|
|
9
|
+
private reverseGraph;
|
|
10
|
+
private rootFile;
|
|
11
|
+
private workspaceCache;
|
|
12
|
+
private config;
|
|
13
|
+
private configPath;
|
|
14
|
+
private metrics;
|
|
15
|
+
private parser;
|
|
16
|
+
private fileReader;
|
|
17
|
+
private connection;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize the WorkspaceManager with workspace folders and dependencies.
|
|
20
|
+
* This discovers all journal files, builds the include graph, and identifies root files.
|
|
21
|
+
* Optionally loads configuration from .hledger-lsp.json if present.
|
|
22
|
+
*/
|
|
23
|
+
initialize(workspaceFolders: string[], parser: HledgerParser, fileReader: FileReader, connection: Connection, runtimeConfig?: Partial<HledgerLspConfig>): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Discover and load configuration from .hledger-lsp.json
|
|
26
|
+
*/
|
|
27
|
+
private loadConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Discover all .journal and .hledger files in a workspace folder.
|
|
30
|
+
* Uses fast-glob to find files, using patterns from config.
|
|
31
|
+
*/
|
|
32
|
+
private discoverJournalFiles;
|
|
33
|
+
/**
|
|
34
|
+
* Build the include graph by parsing each discovered file for include directives.
|
|
35
|
+
* This creates both forward (file → includes) and reverse (file → included by) mappings.
|
|
36
|
+
*
|
|
37
|
+
* IMPORTANT: We parse WITHOUT following includes to get only DIRECT includes,
|
|
38
|
+
* not transitive ones. This ensures the graph accurately represents the include structure.
|
|
39
|
+
*/
|
|
40
|
+
private buildIncludeGraph;
|
|
41
|
+
/**
|
|
42
|
+
* Identify the single root file using the following algorithm:
|
|
43
|
+
* 1. If explicitly configured in config, use that
|
|
44
|
+
* 2. If autoDetectRoot is enabled, use heuristics to find the best root:
|
|
45
|
+
* a. Prefer files with NO parents (not included by anyone)
|
|
46
|
+
* b. Among those, prefer the one that includes the most files
|
|
47
|
+
* c. If multiple candidates, prefer one with "main" or "all" in the name
|
|
48
|
+
* d. If still tied, use alphabetically first
|
|
49
|
+
* 3. If no suitable root found, return null (workspace features disabled)
|
|
50
|
+
*/
|
|
51
|
+
private identifyRootFile;
|
|
52
|
+
/**
|
|
53
|
+
* Get the root file for a given file URI.
|
|
54
|
+
* Returns the single root file if it transitively includes this file, or null otherwise.
|
|
55
|
+
*
|
|
56
|
+
* Algorithm:
|
|
57
|
+
* 1. If no root file identified, return null
|
|
58
|
+
* 2. If the root file transitively includes this file (or is the file itself), return the root
|
|
59
|
+
* 3. Otherwise return null (file is not part of the workspace's include graph)
|
|
60
|
+
*/
|
|
61
|
+
getRootForFile(uri: string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a root file transitively includes a target file.
|
|
64
|
+
* Uses BFS to traverse the include graph.
|
|
65
|
+
*/
|
|
66
|
+
private rootIncludesFile;
|
|
67
|
+
/**
|
|
68
|
+
* Get the workspace folder that contains the given URI.
|
|
69
|
+
* Returns null if the file is outside all workspace folders.
|
|
70
|
+
*
|
|
71
|
+
* Edge case handling: Files outside workspace folders will return null,
|
|
72
|
+
* which triggers a fallback to document-mode parsing. This is intentional
|
|
73
|
+
* and allows the LSP to work with files opened outside the workspace.
|
|
74
|
+
*/
|
|
75
|
+
private getWorkspaceFolder;
|
|
76
|
+
/**
|
|
77
|
+
* Parse the workspace from the root file.
|
|
78
|
+
* Returns a cached ParsedDocument if available, otherwise parses and caches.
|
|
79
|
+
*/
|
|
80
|
+
parseWorkspace(force?: boolean): ParsedDocument | null;
|
|
81
|
+
/**
|
|
82
|
+
* Invalidate the cache for a file.
|
|
83
|
+
* Clears the workspace cache if the root file transitively includes this file.
|
|
84
|
+
*/
|
|
85
|
+
invalidateFile(uri: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get diagnostic information about the workspace.
|
|
88
|
+
* Useful for troubleshooting and performance monitoring.
|
|
89
|
+
*/
|
|
90
|
+
getDiagnosticInfo(): {
|
|
91
|
+
totalFiles: number;
|
|
92
|
+
rootFile: string | null;
|
|
93
|
+
cached: boolean;
|
|
94
|
+
configFile: string | null;
|
|
95
|
+
performance: {
|
|
96
|
+
initializationTime: number;
|
|
97
|
+
cacheHits: number;
|
|
98
|
+
cacheMisses: number;
|
|
99
|
+
cacheHitRate: string;
|
|
100
|
+
averageParseTime: number;
|
|
101
|
+
totalParseTime: number;
|
|
102
|
+
parseCount: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Log diagnostic information to the console.
|
|
107
|
+
* Useful for debugging and performance analysis.
|
|
108
|
+
*/
|
|
109
|
+
logDiagnostics(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Generate a text-based tree representation of the workspace.
|
|
112
|
+
*/
|
|
113
|
+
getWorkspaceTree(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Generate a structured representation of the workspace for better tooling integration.
|
|
116
|
+
* Returns an array of entries with display text and absolute file paths.
|
|
117
|
+
*/
|
|
118
|
+
getWorkspaceTreeStructured(): Array<{
|
|
119
|
+
display: string;
|
|
120
|
+
path: string;
|
|
121
|
+
uri: string;
|
|
122
|
+
}>;
|
|
123
|
+
private collectTreeEntries;
|
|
124
|
+
private printTree;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/server/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAoE,MAAM,cAAc,CAAC;AAElH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,cAAc,CAA+B;IAGrD,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,UAAU,CAAuB;IAGzC,OAAO,CAAC,OAAO,CAMb;IAGF,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,UAAU,CAAc;IAEhC;;;;OAIG;IACG,UAAU,CACd,gBAAgB,EAAE,MAAM,EAAE,EAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,aAAa,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC;IAmDhB;;OAEG;YACW,UAAU;IAwCxB;;;OAGG;YACW,oBAAoB;IA2BlC;;;;;;OAMG;YACW,iBAAiB;IAiG/B;;;;;;;;;OASG;IACH,OAA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