Skip to content

Commit d312a49

Browse files
authored
feat: Resolve local copybooks automatically if no configuration is provided (#2665)
1 parent 5719394 commit d312a49

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

clients/cobol-lsp-vscode-extension/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@
266266
"items": {
267267
"type": "string"
268268
},
269+
"default": [
270+
"**"
271+
],
269272
"description": "Default list of local paths to search for copybooks",
270273
"uniqueItems": true
271274
},

clients/cobol-lsp-vscode-extension/src/test/suite/lsp.spec.copybooks.test.ts

+54
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,58 @@ suite("Integration Test Suite: Copybooks", function () {
171171
})
172172
.timeout(helper.TEST_TIMEOUT)
173173
.slow(1000);
174+
175+
suite("Default copybook configuration", () => {
176+
suite("default configuration - local configuration path not set", () => {
177+
suiteSetup(async () => {
178+
await helper.updateConfig("default.json");
179+
await helper.activate();
180+
});
181+
182+
test("Local copybooks are resolved from local subfolders if no configuration is provided", async () => {
183+
const editor = await helper.showDocument("USERC1N1.cbl");
184+
185+
let diagnostics: vscode.Diagnostic[] = [];
186+
await helper.waitFor(() => {
187+
diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
188+
return (
189+
diagnostics.length > 0 &&
190+
diagnostics.some((d) => d.message === "Errors inside the copybook")
191+
);
192+
});
193+
194+
assert.strictEqual(
195+
diagnostics.filter((d) => d.message === "BOOK1N: Copybook not found")
196+
.length,
197+
0,
198+
);
199+
});
200+
});
201+
202+
suite("local copybook path is configured", () => {
203+
suiteSetup(async () => {
204+
await helper.updateConfig("testing.json");
205+
await helper.activate();
206+
});
207+
208+
test("Only folder from configuration is used for local copybook resolution", async () => {
209+
const editor = await helper.showDocument("USERC1N1.cbl");
210+
211+
let diagnostics: vscode.Diagnostic[] = [];
212+
await helper.waitFor(() => {
213+
diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
214+
return (
215+
diagnostics.length > 0 &&
216+
diagnostics.some((d) => d.message === "BOOK1N: Copybook not found")
217+
);
218+
});
219+
220+
assert.strictEqual(
221+
diagnostics.filter((d) => d.message === "BOOK1N: Copybook not found")
222+
.length,
223+
1,
224+
);
225+
});
226+
});
227+
});
174228
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)