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

Replace Code for IBM i onEvent by subscribe #558

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@
"types": "npx -p typescript tsc ./src/extension.ts --excludeDirectories ./src/testing --declaration --allowJs --emitDeclarationOnly --outDir types --esModuleInterop -t es2020 --moduleResolution node"
},
"devDependencies": {
"@halcyontech/vscode-ibmi-types": "^2.11.0",
"@halcyontech/vscode-ibmi-types": "^2.12",
"@types/node": "20.x",
"@types/parse-gitignore": "^1.0.2",
"@types/tar": "^6.1.13",
Expand Down
8 changes: 4 additions & 4 deletions src/projectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/

import { Validator, ValidatorResult } from "jsonschema";
import { EventEmitter, ExtensionContext, FileType, StatusBarAlignment, StatusBarItem, Uri, WorkspaceFolder, commands, l10n, window, workspace } from "vscode";
import * as path from "path";
import { EventEmitter, ExtensionContext, FileType, StatusBarAlignment, StatusBarItem, Uri, WorkspaceFolder, commands, l10n, window, workspace } from "vscode";
import { ConfigurationManager, ConfigurationSection } from "./configurationManager";
import { IProject } from "./iproject";
import { IProjectT } from "./iProjectT";
import Project from "./views/projectExplorer/project";
import { ProjectExplorerTreeItem } from "./views/projectExplorer/projectExplorerTreeItem";
import { IProjectT } from "./iProjectT";

/**
* Project explorer schema ids:
Expand Down Expand Up @@ -445,7 +445,7 @@ export class ProjectManager {
const subIProjectUris: Uri[] = [];
const subDirectoryUris = (await workspace.fs.readDirectory(uri))
.filter((folder) => folder[1] === FileType.Directory)
.map((folder) => Uri.joinPath(uri, folder[0]))
.map((folder) => Uri.joinPath(uri, folder[0]));
for await (const uri of subDirectoryUris) {
try {
const iprojUri = Uri.file(path.join(uri.fsPath, 'iproj.json'));
Expand All @@ -458,7 +458,7 @@ export class ProjectManager {
// Project not found
}

if (currentDepth != scanDepth) {
if (currentDepth !== scanDepth) {
subIProjectUris.push(...(await this.scanSubIProjects(uri, scanDepth, currentDepth)));
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
* (c) Copyright IBM Corp. 2023
*/

import { ExtensionContext, commands, window } from "vscode";
import { env } from "process";
import { TestSuitesTreeProvider } from "./testCasesTree";
import { ExtensionContext, commands, window } from "vscode";
import { getInstance } from "../ibmi";
import { buildMapSuite } from "./suites/buildMap";
import { decorationProviderSuite } from "./suites/decorationProvider";
import { iProjectSuite } from "./suites/iProject";
import { projectManagerSuite } from "./suites/projectManager";
import { jobLogSuite } from "./suites/jobLog";
import { projectExplorerTreeItemSuite } from "./suites/projectExplorerTreeItem";
import { decorationProviderSuite } from "./suites/decorationProvider";
import { jobLogCommandSuite } from "./suites/jobLogCommand";
import { jobLogTreeItemSuite } from "./suites/jobLogTreeItem";
import { projectExplorerTreeItemSuite } from "./suites/projectExplorerTreeItem";
import { projectManagerSuite } from "./suites/projectManager";
import { ringBufferSuite } from "./suites/ringBuffer";
import { buildMapSuite } from "./suites/buildMap";
import { utilSuite } from "./suites/utilTest";
import { TestSuitesTreeProvider } from "./testCasesTree";

const suites: TestSuite[] = [
buildMapSuite,
Expand Down Expand Up @@ -58,9 +58,9 @@ export async function initialise(context: ExtensionContext) {
await commands.executeCommand(`setContext`, `projectExplorer:testing`, true);
const ibmi = getInstance()!;
if (!individualTesting) {
ibmi.onEvent(`connected`, runTests);
ibmi.subscribe(context, `connected`, "Run IBM i Project Explorer tests", runTests);
sebjulliand marked this conversation as resolved.
Show resolved Hide resolved
}
ibmi.onEvent(`disconnected`, resetTests);
ibmi.subscribe(context, `disconnected`, "Reset IBM i Project Explorer tests", resetTests);
testSuitesTreeProvider = new TestSuitesTreeProvider(suites);
const testSuitesTreeView = window.createTreeView(`testing`, { treeDataProvider: testSuitesTreeProvider, showCollapseAll: true });

Expand Down
10 changes: 5 additions & 5 deletions src/views/projectExplorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ConnectionData, DeploymentMethod, ObjectItem } from "@halcyontech/vscod
import { DeploymentPath } from "@halcyontech/vscode-ibmi-types/api/Storage";
import * as path from "path";
import { CancellationToken, ConfigurationTarget, EventEmitter, ExtensionContext, ProgressLocation, QuickPickItem, TreeDataProvider, TreeItem, TreeView, Uri, WorkspaceFolder, commands, env, l10n, window, workspace } from "vscode";
import { DecorationProvider } from "../../decorationProvider";
import { EnvironmentManager } from "../../environmentManager";
import { IProjectT } from "../../iProjectT";
import { getDeployTools, getInstance, getTools } from "../../ibmi";
import { LINKS } from "../../ibmiProjectExplorer";
import { IProject } from "../../iproject";
import { ProjectManager } from "../../projectManager";
import { DecorationProvider } from "../../decorationProvider";
import ErrorItem from "./errorItem";
import IncludePaths from "./includePaths";
import Library, { LibraryType } from "./library";
Expand Down Expand Up @@ -41,7 +41,7 @@ export default class ProjectExplorer implements TreeDataProvider<ProjectExplorer
constructor(context: ExtensionContext) {
const ibmi = getInstance();
let currentDeploymentStorage: DeploymentPath;
ibmi?.onEvent(`connected`, async () => {
ibmi?.subscribe(context, `connected`, "Load IBM i Project Explorer", async () => {
this.refresh();

currentDeploymentStorage = JSON.parse(JSON.stringify(ibmi?.getStorage().getDeployment()));
Expand All @@ -50,10 +50,10 @@ export default class ProjectExplorer implements TreeDataProvider<ProjectExplorer
await iProject.syncLiblVars();
}
});
ibmi?.onEvent(`deploy`, () => {
ibmi?.subscribe(context, `deploy`, "Refresh IBM i Project Explorer after deploy", () => {
this.refresh();
});
ibmi?.onEvent(`deployLocation`, () => {
ibmi?.subscribe(context, `deployLocation`, "Refresh IBM i Project Explorer after deploy location changes", () => {
this.refresh();

const newDeploymentStorage = ibmi?.getStorage().getDeployment();
Expand All @@ -66,7 +66,7 @@ export default class ProjectExplorer implements TreeDataProvider<ProjectExplorer

currentDeploymentStorage = JSON.parse(JSON.stringify(newDeploymentStorage));
});
ibmi?.onEvent(`disconnected`, () => {
ibmi?.subscribe(context, `disconnected`, "Disconnect IBM i Projects", () => {
this.refresh();

for (const iProject of ProjectManager.getProjects()) {
Expand Down
Loading