Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions vscode-wpilib/src/toolapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ export class ToolAPI implements IToolAPI {
if (grResult !== undefined && grResult === i18n('ui', 'Yes')) {
const preferencesApi = this.externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot install gradle tools with an empty workspace')
i18n('message', 'Cannot install gradle tools since this is not a WPILib project')
);
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion vscode-wpilib/src/vendorlibraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export class VendorLibraries extends VendorLibrariesBase {
if (workspace === undefined) {
const prefsApi = this.externalApi.getPreferencesAPI();
workspace = await prefsApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (workspace === undefined || !prefsApi.getPreferences(workspace).getIsWPILibProject()) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot install vendor libraries since this is not a WPILib project')
);
return;
}
}
Expand Down
167 changes: 121 additions & 46 deletions vscode-wpilib/src/vscommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setTeamNumber', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set team number in an empty workspace')
i18n('message', 'Cannot set team number since this is not a WPILib project')
);
return;
}
Expand All @@ -102,9 +105,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot deploy code in an empty workspace')
i18n('message', 'Cannot deploy code since this is not a WPILib project')
);
return;
}
Expand All @@ -119,9 +125,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot debug code in an empty workspace')
i18n('message', 'Cannot debug code since this is not a WPILib project')
);
return;
}
Expand All @@ -136,9 +145,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot simulate code in an empty workspace')
i18n('message', 'Cannot simulate code since this is not a WPILib project')
);
return;
}
Expand All @@ -153,9 +165,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot simulate code in an empty workspace')
i18n('message', 'Cannot simulate code since this is not a WPILib project')
);
return;
}
Expand All @@ -170,9 +185,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot start tests in an empty workspace')
i18n('message', 'Cannot start tests since this is not a WPILib project')
);
return;
}
Expand All @@ -187,9 +205,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
async (source: vscode.Uri | undefined) => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set team number in an empty workspace')
i18n('message', 'Cannot set team number since this is not a WPILib project')
);
return;
}
Expand All @@ -210,9 +231,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
}
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot create command in an empty workspace')
i18n('message', 'Cannot create command since this is not a WPILib project')
);
return;
}
Expand All @@ -225,9 +249,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setLanguage', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set language in an empty workspace')
i18n('message', 'Cannot set language since this is not a WPILib project')
);
return;
}
Expand Down Expand Up @@ -260,9 +287,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setSkipTests', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set skip tests in an empty workspace')
i18n('message', 'Cannot set skip tests since this is not a WPILib project')
);
return;
}
Expand All @@ -285,9 +315,15 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setSkipSelectSimulateExtension', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set skip select simulate extension in an empty workspace')
i18n(
'message',
'Cannot set skip select simulate extension since this is not a WPILib project'
)
);
return;
}
Expand All @@ -314,9 +350,15 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setSelectDefaultSimulateExtension', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set select default simulate extension in an empty workspace')
i18n(
'message',
'Cannot set select default simulate extension since this is not a WPILib project'
)
);
return;
}
Expand All @@ -343,9 +385,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setOffline', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set offline in an empty workspace')
i18n('message', 'Cannot set offline since this is not a WPILib project')
);
return;
}
Expand All @@ -372,9 +417,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setDeployOffline', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set deploy offline in an empty workspace')
i18n('message', 'Cannot set deploy offline since this is not a WPILib project')
);
return;
}
Expand All @@ -401,9 +449,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setStopSimulationOnEntry', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set stop simulation in an empty workspace')
i18n('message', 'Cannot set stop simulation since this is not a WPILib project')
);
return;
}
Expand All @@ -430,9 +481,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setUseWinDbgX', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set windbgx in an empty workspace')
i18n('message', 'Cannot set windbgx since this is not a WPILib project')
);
return;
}
Expand Down Expand Up @@ -463,9 +517,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setAutoSave', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set auto save in an empty workspace')
i18n('message', 'Cannot set auto save since this is not a WPILib project')
);
return;
}
Expand All @@ -492,9 +549,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.setStartRioLog', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot set start RioLog in an empty workspace')
i18n('message', 'Cannot set start RioLog since this is not a WPILib project')
);
return;
}
Expand Down Expand Up @@ -540,9 +600,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.installGradleTools', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot install gradle tools with an empty workspace')
i18n('message', 'Cannot install gradle tools since this is not a WPILib project')
);
return;
}
Expand All @@ -560,9 +623,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
return;
}
const wp = await externalApi.getPreferencesAPI().getFirstOrSelectedWorkspace();
if (wp === undefined) {
if (
wp === undefined ||
!externalApi.getPreferencesAPI().getPreferences(wp).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot run command on empty workspace')
i18n('message', 'Cannot run gradle command since this is not a WPILib project')
);
return;
}
Expand All @@ -587,9 +653,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.resetAutoUpdate', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot reset auto update with an empty workspace')
i18n('message', 'Cannot reset auto update since this is not a WPILib project')
);
return;
}
Expand All @@ -602,9 +671,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
vscode.commands.registerCommand('wpilibcore.changeDesktop', async () => {
const preferencesApi = externalApi.getPreferencesAPI();
const workspace = await preferencesApi.getFirstOrSelectedWorkspace();
if (workspace === undefined) {
if (
workspace === undefined ||
!preferencesApi.getPreferences(workspace).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot change desktop with an empty workspace')
i18n('message', 'Cannot change desktop since this is not a WPILib project')
);
return;
}
Expand Down Expand Up @@ -697,9 +769,12 @@ export function createVsCommands(context: vscode.ExtensionContext, externalApi:
context.subscriptions.push(
vscode.commands.registerCommand('wpilibcore.runGradleClean', async () => {
const wp = await externalApi.getPreferencesAPI().getFirstOrSelectedWorkspace();
if (wp === undefined) {
if (
wp === undefined ||
!externalApi.getPreferencesAPI().getPreferences(wp).getIsWPILibProject()
) {
vscode.window.showInformationMessage(
i18n('message', 'Cannot run command on empty workspace')
i18n('message', 'Cannot run gradle clean since this is not a WPILib project')
);
return;
}
Expand Down