Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/e4e/flag #2344

Merged
merged 18 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions clients/cobol-lsp-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,19 @@
"iso646jp"
]
},
"cobol-lsp.cpy-manager.endevor-dependencies": {
"type": "string",
"enum": [
"COBOL LS",
"ENDEVOR"
],
"enumDescriptions": [
"Retrieve copybooks from mainframe data sets and USS files specified in the COBOL Language Support extension settings",
"Retrieve copybooks from locations specified in the Endevor element processor group."
],
"description": "The method that is used to retrieve remote copybooks for elements opened in Explorer for Endevor.",
"default": "COBOL LS"
},
"cobol-lsp.subroutine-manager.paths-local": {
"type": "array",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe("Test the copybook message handler", () => {
});
it("checks E4E downloaded member copybooks are resolved", async () => {
vscode.workspace.getConfiguration = jest.fn().mockReturnValue({
get: jest.fn().mockReturnValue(""),
get: jest.fn().mockReturnValue("ENDEVOR"),
});
(vscode.workspace.workspaceFolders as any) = undefined;
(globSync as any) = jest.fn().mockImplementation((x: any) => [x]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ describe("e4e copybook service tests", () => {

it("check getE4EClient assembles client correctly / check getE4EClient returns already assembled client once called with same Uri ", async () => {
E4ECopybookService.getE4EAPI = jest.fn().mockReturnValue(e4eMock);
vscode.workspace.getConfiguration = jest.fn().mockReturnValue({
get: jest.fn().mockReturnValue("ENDEVOR"),
});
await E4ECopybookService.getE4EClient("document-uri");
const spyApi = jest.spyOn(E4ECopybookService, "getE4EAPI");
expect(spyApi).toHaveBeenCalledTimes(1);
Expand All @@ -40,4 +43,12 @@ describe("e4e copybook service tests", () => {
await E4ECopybookService.getE4EClient("new-uri");
expect(spyApi).toHaveBeenCalledTimes(2);
});
it("checks getE4EClient returns undefined when zowe settings is being used to retrieve copybooks", async () => {
vscode.workspace.getConfiguration = jest.fn().mockReturnValue({
get: jest.fn().mockReturnValue("COBOL LS"),
});
expect(await E4ECopybookService.getE4EClient("document-uri")).toEqual(
undefined,
);
});
});
2 changes: 2 additions & 0 deletions clients/cobol-lsp-vscode-extension/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const E4E_FOLDER: string = ".e4e";
export const DATASET = "dataset";
export const ENVIRONMENT = "environment";
export const USE_MAP = "MAP";
export const SETTINGS_CPY_NDVR_DEPENDENCIES = "endevor-dependencies";
export const ENDEVOR_PROCESSOR = "ENDEVOR";

export enum PUNCH_CARD {
SEQUENCE_AREA_END_POS = 6,
Expand Down
14 changes: 12 additions & 2 deletions clients/cobol-lsp-vscode-extension/src/services/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
* Broadcom, Inc. - initial API and implementation
*/

import * as fs from "node:fs";
import * as path from "node:path";
import * as vscode from "vscode";
import { Utils } from "./util/Utils";
import {
COPYBOOK_EXTENSIONS,
PATHS_LOCAL_KEY,
Expand All @@ -34,6 +32,7 @@ import {
SETTINGS_COMPILE_OPTIONS,
DIALECT_LIBS,
COBOL_PRGM_LAYOUT,
SETTINGS_CPY_NDVR_DEPENDENCIES,
} from "../constants";
import cobolSnippets = require("../services/snippetcompletion/cobolSnippets.json");
import { DialectRegistry, DIALECT_REGISTRY_SECTION } from "./DialectRegistry";
Expand Down Expand Up @@ -364,4 +363,15 @@ export class SettingsService {
}
return result;
}
/**
* Gives the configured endevor dependecy from settings.
*
* @returns returns configured endevor dependency
*/
public static getCopybookEndevorDependencySettings(): string | undefined {
const setting: string | undefined = vscode.workspace
.getConfiguration(SETTINGS_CPY_SECTION)
.get(SETTINGS_CPY_NDVR_DEPENDENCIES);
return setting;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

import * as vscode from "vscode";
import { DownloadStrategyResolver } from "./downloader/DownloadStrategyResolver";
import { PROVIDE_PROFILE_MSG } from "../../constants";
import { ENDEVOR_PROCESSOR, PROVIDE_PROFILE_MSG } from "../../constants";
import { ProfileUtils } from "../util/ProfileUtils";
import { DownloadUtil } from "./downloader/DownloadUtil";
import { E4ECopybookService } from "./E4ECopybookService";
import { E4E } from "../../type/e4eApi";
import { SettingsService } from "../Settings";

export class CopybookName {
constructor(public name: string, public dialect: string) {}
Expand Down Expand Up @@ -108,10 +109,15 @@ export class CopybookDownloadService {
documentUri: string,
copybookNames: CopybookName[],
): Promise<boolean> {
const e4eApi = await E4ECopybookService.getE4EAPI();
if (e4eApi && e4eApi.isEndevorElement(documentUri)) {
const e4eClient = await E4ECopybookService.getE4EClient(documentUri);
return e4eClient ? true : false;
if (
this.e4eAPI &&
this.e4eAPI.isEndevorElement(documentUri) &&
SettingsService.getCopybookEndevorDependencySettings() ==
ENDEVOR_PROCESSOR
) {
return (await E4ECopybookService.getE4EClient(documentUri))
? true
: false;
}
if (
!DownloadUtil.areCopybookDownloadConfigurationsPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
DATASET,
E4E_FOLDER,
E4E_SCHEME,
ENDEVOR_PROCESSOR,
ENVIRONMENT,
USE_MAP,
ZOWE_FOLDER,
Expand All @@ -48,7 +49,11 @@ export async function resolveCopybookHandler(
): Promise<string | undefined> {
let result: string | undefined;
const e4eApi = await E4ECopybookService.getE4EAPI();
if (e4eApi && e4eApi.isEndevorElement(documentUri)) {
if (
e4eApi &&
e4eApi.isEndevorElement(documentUri) &&
SettingsService.getCopybookEndevorDependencySettings() == ENDEVOR_PROCESSOR
) {
result = await getE4ECopyBookLocation(
copybookName,
documentUri,
Expand Down Expand Up @@ -172,7 +177,7 @@ async function getE4ECopyBookLocation(
documentUri: string,
storagePath: string,
outputChannel: vscode.OutputChannel,
) {
): Promise<string | undefined> {
const config = await E4ECopybookService.getE4EClient(
documentUri,
outputChannel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import * as vscode from "vscode";
import {
DATASET,
ENDEVOR_PROCESSOR,
ENVIRONMENT,
OUTPUT_MSG_SEARCH_LOCATION,
} from "../../constants";
Expand All @@ -28,6 +29,7 @@ import {
EndevorType,
} from "../../type/e4eApi.d";
import { Utils } from "../util/Utils";
import { SettingsService } from "../Settings";

export class E4ECopybookService {
private static E4EConfigs = new Map<string, e4eResponse>();
Expand All @@ -51,6 +53,10 @@ export class E4ECopybookService {
uri: string,
outputChannel?: vscode.OutputChannel,
): Promise<e4eResponse | undefined> {
const e4eSettings = SettingsService.getCopybookEndevorDependencySettings();
if (e4eSettings != ENDEVOR_PROCESSOR) {
return undefined;
}
const config = this.E4EConfigs.get(uri);
if (config) {
return config;
Expand Down
Loading