Skip to content

Commit

Permalink
Start adding python support
Browse files Browse the repository at this point in the history
This is just the basic start, and only a code deployer to start with (and one that doesn't deploy at that, as I don't know the command)
  • Loading branch information
ThadHouse committed Sep 29, 2023
1 parent b790545 commit e00bc06
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vscode-wpilib/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { Gradle2020Import } from './webviews/gradle2020import';
import { Help } from './webviews/help';
import { ProjectCreator } from './webviews/projectcreator';
import { WPILibUpdates } from './wpilibupdates';
import { activatePython } from './python/python';

// External API class to implement the IExternalAPI interface
class ExternalAPI implements IExternalAPI {
Expand Down Expand Up @@ -117,6 +118,8 @@ async function handleAfterTrusted(externalApi: ExternalAPI, context: vscode.Exte
await activateCpp(context, externalApi);
// Active the java parts of the extension
await activateJava(context, externalApi);
// Activate the python parts of the extension
await activatePython(context, externalApi);

try {
// Add built in tools
Expand Down
61 changes: 61 additions & 0 deletions vscode-wpilib/src/python/deploydebug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

import * as jsonc from 'jsonc-parser';
import * as path from 'path';
import * as vscode from 'vscode';
import { ICodeDeployer, IExecuteAPI, IExternalAPI, IPreferencesAPI } from 'vscode-wpilibapi';
import { gradleRun, readFileAsync } from '../utilities';

class DeployCodeDeployer implements ICodeDeployer {
private preferences: IPreferencesAPI;
private executeApi: IExecuteAPI;

constructor(externalApi: IExternalAPI) {
this.preferences = externalApi.getPreferencesAPI();
this.executeApi = externalApi.getExecuteAPI();
}

public async getIsCurrentlyValid(workspace: vscode.WorkspaceFolder): Promise<boolean> {
const prefs = this.preferences.getPreferences(workspace);
const currentLanguage = prefs.getCurrentLanguage();
return currentLanguage === 'none' || currentLanguage === 'java';
}

public async runDeployer(teamNumber: number, workspace: vscode.WorkspaceFolder,
_: vscode.Uri | undefined, ...args: string[]): Promise<boolean> {
// TODO actaully deploy
return false;
}

public getDisplayName(): string {
return 'python';
}

public getDescription(): string {
return 'Python Deploy';
}
}

export class DeployDebug {
private deployDeployer: DeployCodeDeployer;

constructor(externalApi: IExternalAPI) {
const deployDebugApi = externalApi.getDeployDebugAPI();
deployDebugApi.addLanguageChoice('python');

//this.deployDebuger = new DebugCodeDeployer(externalApi);
this.deployDeployer = new DeployCodeDeployer(externalApi);
//this.simulator = new SimulateCodeDeployer(externalApi);

deployDebugApi.registerCodeDeploy(this.deployDeployer);

// if (allowDebug) {
// deployDebugApi.registerCodeDebug(this.deployDebuger);
// deployDebugApi.registerCodeSimulate(this.simulator);
// }
}

public dispose() {
//
}
}
20 changes: 20 additions & 0 deletions vscode-wpilib/src/python/python.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

import * as path from 'path';
import * as vscode from 'vscode';
import { IExternalAPI } from "vscode-wpilibapi";
import { DeployDebug } from './deploydebug';

export async function activatePython(context: vscode.ExtensionContext, coreExports: IExternalAPI) {

const extensionResourceLocation = path.join(context.extensionPath, 'resources', 'python');

const preferences = coreExports.getPreferencesAPI();
const exampleTemplate = coreExports.getExampleTemplateAPI();
const commandApi = coreExports.getCommandAPI();

const deployDebug = new DeployDebug(coreExports);
context.subscriptions.push(deployDebug);


}

0 comments on commit e00bc06

Please sign in to comment.