Skip to content

Commit

Permalink
Merge branch 'main' into andrueastman/multipartRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrueastman authored Oct 2, 2024
2 parents 28e6074 + f837b76 commit 36875c4
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { treeViewId } from "../../constants";
import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class AddAllToSelectedEndpointsCommand extends Command {
private _openApiTreeProvider: OpenApiTreeProvider;

constructor(openApiTreeProvider: OpenApiTreeProvider) {
super();
this._openApiTreeProvider = openApiTreeProvider;
}

public getName(): string {
return `${treeViewId}.addAllToSelectedEndpoints`;
}

public async execute(openApiTreeNode: OpenApiTreeNode): Promise<void> {
this._openApiTreeProvider.select(openApiTreeNode, true, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { treeViewId } from "../../constants";
import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class AddToSelectedEndpointsCommand extends Command {
private _openApiTreeProvider: OpenApiTreeProvider;

constructor(openApiTreeProvider: OpenApiTreeProvider) {
super();
this._openApiTreeProvider = openApiTreeProvider;
}

public getName(): string {
return `${treeViewId}.addToSelectedEndpoints`;
}

public async execute(openApiTreeNode: OpenApiTreeNode): Promise<void> {
this._openApiTreeProvider.select(openApiTreeNode, true, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { treeViewId } from "../../constants";
import { OpenApiTreeProvider } from "../../openApiTreeProvider";
import { filterSteps } from "../../steps";
import { Command } from "../Command";

export class FilterDescriptionCommand extends Command {

private _openApiTreeProvider: OpenApiTreeProvider;

constructor(openApiTreeProvider: OpenApiTreeProvider) {
super();
this._openApiTreeProvider = openApiTreeProvider;
}

public getName(): string {
return `${treeViewId}.filterDescription`;
}

public async execute(): Promise<void> {
await filterSteps(this._openApiTreeProvider.filter,
x => this._openApiTreeProvider.filter = x);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as vscode from "vscode";

import { treeViewId } from "../../constants";
import { OpenApiTreeNode } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class OpenDocumentationPageCommand extends Command {

public getName(): string {
return `${treeViewId}.openDocumentationPage`;
}

public async execute(node: OpenApiTreeNode): Promise<void> {
node.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(node.documentationUrl));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { treeViewId } from "../../constants";
import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class RemoveAllFromSelectedEndpointsCommand extends Command {
private _openApiTreeProvider: OpenApiTreeProvider;

constructor(openApiTreeProvider: OpenApiTreeProvider) {
super();
this._openApiTreeProvider = openApiTreeProvider;
}

public getName(): string {
return `${treeViewId}.removeAllFromSelectedEndpoints`;
}

public async execute(openApiTreeNode: OpenApiTreeNode): Promise<void> {
this._openApiTreeProvider.select(openApiTreeNode, false, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { treeViewId } from "../../constants";
import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class RemoveFromSelectedEndpointsCommand extends Command {
private _openApiTreeProvider: OpenApiTreeProvider;

constructor(openApiTreeProvider: OpenApiTreeProvider) {
super();
this._openApiTreeProvider = openApiTreeProvider;
}

public getName(): string {
return `${treeViewId}.removeFromSelectedEndpoints`;
}

public async execute(openApiTreeNode: OpenApiTreeNode): Promise<void> {
this._openApiTreeProvider.select(openApiTreeNode, false, false);
}
}
49 changes: 23 additions & 26 deletions vscode/microsoft-kiota/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import * as vscode from "vscode";

import { CodeLensProvider } from "./codelensProvider";
import { MigrateFromLockFileCommand } from './commands/migrateFromLockFileCommand';
import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-view/addAllToSelectedEndpointsCommand';
import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-view/addToSelectedEndpointsCommand';
import { FilterDescriptionCommand } from './commands/open-api-tree-view/filterDescriptionCommand';
import { OpenDocumentationPageCommand } from './commands/open-api-tree-view/openDocumentationPageCommand';
import { RemoveAllFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand';
import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeFromSelectedEndpointsCommand';
import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants";
import { DependenciesViewProvider } from "./dependenciesViewProvider";
import { GenerationType, KiotaGenerationLanguage, KiotaPluginType } from "./enums";
Expand All @@ -26,7 +32,7 @@ import {
import { checkForLockFileAndPrompt } from "./migrateFromLockFile";
import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider";
import { searchDescription } from "./searchDescription";
import { GenerateState, filterSteps, generateSteps, searchSteps } from "./steps";
import { GenerateState, generateSteps, searchSteps } from "./steps";
import { updateClients } from "./updateClients";
import {
getSanitizedString, getWorkspaceJsonDirectory, getWorkspaceJsonPath,
Expand Down Expand Up @@ -61,7 +67,15 @@ export async function activate(
context.extensionUri
);
const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey);

const migrateFromLockFileCommand = new MigrateFromLockFileCommand(context);
const addAllToSelectedEndpointsCommand = new AddAllToSelectedEndpointsCommand(openApiTreeProvider);
const addToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider);
const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider);
const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider);
const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider);
const openDocumentationPageCommand = new OpenDocumentationPageCommand();

await loadTreeView(context);
await checkForLockFileAndPrompt(context);
let codeLensProvider = new CodeLensProvider();
Expand Down Expand Up @@ -114,26 +128,12 @@ export async function activate(
dependenciesInfoProvider
),
vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider),
registerCommandWithTelemetry(reporter,
`${treeViewId}.openDocumentationPage`,
(x: OpenApiTreeNode) => x.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(x.documentationUrl))
),
registerCommandWithTelemetry(reporter,
`${treeViewId}.addToSelectedEndpoints`,
(x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, false)
),
registerCommandWithTelemetry(reporter,
`${treeViewId}.addAllToSelectedEndpoints`,
(x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, true)
),
registerCommandWithTelemetry(reporter,
`${treeViewId}.removeFromSelectedEndpoints`,
(x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, false)
),
registerCommandWithTelemetry(reporter,
`${treeViewId}.removeAllFromSelectedEndpoints`,
(x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true)
),
registerCommandWithTelemetry(reporter, openDocumentationPageCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await openDocumentationPageCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, addToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addToSelectedEndpointsCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, addAllToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addAllToSelectedEndpointsCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, removeFromSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await removeFromSelectedEndpointsCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, removeAllFromSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)),

registerCommandWithTelemetry(reporter,
`${treeViewId}.generateClient`,
async () => {
Expand Down Expand Up @@ -302,11 +302,8 @@ export async function activate(
}
}
),
registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`,
async () => {
await filterSteps(openApiTreeProvider.filter, x => openApiTreeProvider.filter = x);
}
),
registerCommandWithTelemetry(reporter, filterDescriptionCommand.getName(), async () => await filterDescriptionCommand.execute()),

registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => {
clientOrPluginKey = clientKey;
clientOrPluginObject = clientObject;
Expand Down

0 comments on commit 36875c4

Please sign in to comment.