Skip to content

Commit 4862f65

Browse files
committed
Start adding python support
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)
1 parent b790545 commit 4862f65

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

vscode-wpilib/src/extension.ts

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { Gradle2020Import } from './webviews/gradle2020import';
3636
import { Help } from './webviews/help';
3737
import { ProjectCreator } from './webviews/projectcreator';
3838
import { WPILibUpdates } from './wpilibupdates';
39+
import { activatePython } from './python/python';
3940

4041
// External API class to implement the IExternalAPI interface
4142
class ExternalAPI implements IExternalAPI {
@@ -117,6 +118,8 @@ async function handleAfterTrusted(externalApi: ExternalAPI, context: vscode.Exte
117118
await activateCpp(context, externalApi);
118119
// Active the java parts of the extension
119120
await activateJava(context, externalApi);
121+
// Activate the python parts of the extension
122+
await activatePython(context, externalApi);
120123

121124
try {
122125
// Add built in tools
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
3+
import * as jsonc from 'jsonc-parser';
4+
import * as path from 'path';
5+
import * as vscode from 'vscode';
6+
import { ICodeDeployer, IExecuteAPI, IExternalAPI, IPreferencesAPI } from 'vscode-wpilibapi';
7+
import { gradleRun, readFileAsync } from '../utilities';
8+
9+
class DeployCodeDeployer implements ICodeDeployer {
10+
private preferences: IPreferencesAPI;
11+
private executeApi: IExecuteAPI;
12+
13+
constructor(externalApi: IExternalAPI) {
14+
this.preferences = externalApi.getPreferencesAPI();
15+
this.executeApi = externalApi.getExecuteAPI();
16+
}
17+
18+
public async getIsCurrentlyValid(workspace: vscode.WorkspaceFolder): Promise<boolean> {
19+
const prefs = this.preferences.getPreferences(workspace);
20+
const currentLanguage = prefs.getCurrentLanguage();
21+
return currentLanguage === 'none' || currentLanguage === 'java';
22+
}
23+
24+
public async runDeployer(teamNumber: number, workspace: vscode.WorkspaceFolder,
25+
_: vscode.Uri | undefined, ...args: string[]): Promise<boolean> {
26+
// TODO actaully deploy
27+
return false;
28+
}
29+
30+
public getDisplayName(): string {
31+
return 'python';
32+
}
33+
34+
public getDescription(): string {
35+
return 'Python Deploy';
36+
}
37+
}
38+
39+
export class DeployDebug {
40+
private deployDeployer: DeployCodeDeployer;
41+
42+
constructor(externalApi: IExternalAPI) {
43+
const deployDebugApi = externalApi.getDeployDebugAPI();
44+
deployDebugApi.addLanguageChoice('python');
45+
46+
//this.deployDebuger = new DebugCodeDeployer(externalApi);
47+
this.deployDeployer = new DeployCodeDeployer(externalApi);
48+
//this.simulator = new SimulateCodeDeployer(externalApi);
49+
50+
deployDebugApi.registerCodeDeploy(this.deployDeployer);
51+
52+
// if (allowDebug) {
53+
// deployDebugApi.registerCodeDebug(this.deployDebuger);
54+
// deployDebugApi.registerCodeSimulate(this.simulator);
55+
// }
56+
}
57+
58+
public dispose() {
59+
//
60+
}
61+
}

vscode-wpilib/src/python/python.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
import * as path from 'path';
4+
import * as vscode from 'vscode';
5+
import { IExternalAPI } from 'vscode-wpilibapi';
6+
import { DeployDebug } from './deploydebug';
7+
8+
export async function activatePython(context: vscode.ExtensionContext, coreExports: IExternalAPI) {
9+
10+
const extensionResourceLocation = path.join(context.extensionPath, 'resources', 'python');
11+
12+
const preferences = coreExports.getPreferencesAPI();
13+
const exampleTemplate = coreExports.getExampleTemplateAPI();
14+
const commandApi = coreExports.getCommandAPI();
15+
16+
const deployDebug = new DeployDebug(coreExports);
17+
context.subscriptions.push(deployDebug);
18+
19+
20+
}

0 commit comments

Comments
 (0)