Skip to content

Commit

Permalink
chore: move vscode apex debugger to arrow functions
Browse files Browse the repository at this point in the history
@W-14564471@
Refactor vscode apex debugger to arrow functions
  • Loading branch information
peternhale committed Dec 28, 2023
1 parent 369750b commit 5f99f40
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rules": {
"prefer-arrow/prefer-arrow-functions": ["error", {}],
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IsvContextUtil } from '@salesforce/salesforcedx-apex-debugger/out/src/c
import { projectPaths } from '@salesforce/salesforcedx-utils-vscode';
import * as vscode from 'vscode';

export async function setupGlobalDefaultUserIsvAuth() {
export const setupGlobalDefaultUserIsvAuth = async () => {
const isvUtil = new IsvContextUtil();
if (
vscode.workspace &&
Expand All @@ -19,7 +19,7 @@ export async function setupGlobalDefaultUserIsvAuth() {
vscode.workspace.workspaceFolders[0].uri.fsPath
);

vscode.commands.executeCommand(
await vscode.commands.executeCommand(
'setContext',
'sfdx:isv_debug_project',
isvDebugProject
Expand All @@ -33,9 +33,9 @@ export async function setupGlobalDefaultUserIsvAuth() {

// reset any auth
isvUtil.resetCliEnvironmentVars();
}
};

export function registerIsvAuthWatcher(extensionContext: vscode.ExtensionContext) {
export const registerIsvAuthWatcher = (extensionContext: vscode.ExtensionContext) => {
if (
vscode.workspace.workspaceFolders instanceof Array &&
vscode.workspace.workspaceFolders.length > 0
Expand All @@ -49,4 +49,4 @@ export function registerIsvAuthWatcher(extensionContext: vscode.ExtensionContext
/* eslint-enable @typescript-eslint/no-unused-vars */
extensionContext.subscriptions.push(isvAuthWatcher);
}
}
};
48 changes: 24 additions & 24 deletions packages/salesforcedx-vscode-apex-debugger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ const sfdxCoreExtension = vscode.extensions.getExtension(
'salesforce.salesforcedx-vscode-core'
);

export async function getDebuggerType(
export const getDebuggerType = async (
session: vscode.DebugSession
): Promise<string> {
): Promise<string> => {
let type = session.type;
if (type === LIVESHARE_DEBUGGER_TYPE) {
type = await session.customRequest(LIVESHARE_DEBUG_TYPE_REQUEST);
}
return type;
}
};

function registerCommands(): vscode.Disposable {
const registerCommands = (): vscode.Disposable => {
const customEventHandler = vscode.debug.onDidReceiveDebugSessionCustomEvent(
async event => {
if (event && event.session) {
Expand Down Expand Up @@ -89,7 +89,7 @@ function registerCommands(): vscode.Disposable {
exceptionBreakpointCmd,
startSessionHandler
);
}
};

export interface ExceptionBreakpointItem extends vscode.QuickPickItem {
typeref: string;
Expand All @@ -114,7 +114,7 @@ const EXCEPTION_BREAK_MODES: BreakModeItem[] = [
}
];

async function configureExceptionBreakpoint(): Promise<void> {
const configureExceptionBreakpoint = async (): Promise<void> => {
const sfdxApex = vscode.extensions.getExtension(
'salesforce.salesforcedx-vscode-apex'
);
Expand Down Expand Up @@ -170,12 +170,12 @@ async function configureExceptionBreakpoint(): Promise<void> {
}
}
}
}
};

export function mergeExceptionBreakpointInfos(
export const mergeExceptionBreakpointInfos = (
breakpointInfos: ExceptionBreakpointItem[],
enabledBreakpointTyperefs: string[]
): ExceptionBreakpointItem[] {
): ExceptionBreakpointItem[] => {
const processedBreakpointInfos: ExceptionBreakpointItem[] = [];
if (enabledBreakpointTyperefs.length > 0) {
for (let i = breakpointInfos.length - 1; i >= 0; i--) {
Expand All @@ -190,11 +190,11 @@ export function mergeExceptionBreakpointInfos(
}
}
return processedBreakpointInfos.concat(breakpointInfos);
}
};

export function updateExceptionBreakpointCache(
export const updateExceptionBreakpointCache = (
selectedException: ExceptionBreakpointItem
) {
) => {
if (
selectedException.breakMode === EXCEPTION_BREAKPOINT_BREAK_MODE_ALWAYS &&
!cachedExceptionBreakpoints.has(selectedException.typeref)
Expand All @@ -209,16 +209,16 @@ export function updateExceptionBreakpointCache(
) {
cachedExceptionBreakpoints.delete(selectedException.typeref);
}
}
};

export function getExceptionBreakpointCache(): Map<
export const getExceptionBreakpointCache = (): Map<
string,
ExceptionBreakpointItem
> {
> => {
return cachedExceptionBreakpoints;
}
};

function registerFileWatchers(): vscode.Disposable {
const registerFileWatchers = (): vscode.Disposable => {
const clsWatcher = vscode.workspace.createFileSystemWatcher('**/*.cls');
/* eslint-disable @typescript-eslint/no-unused-vars */
clsWatcher.onDidChange(uri => notifyDebuggerSessionFileChanged());
Expand All @@ -230,15 +230,15 @@ function registerFileWatchers(): vscode.Disposable {
trgWatcher.onDidDelete(uri => notifyDebuggerSessionFileChanged());
/* eslint-enable @typescript-eslint/no-unused-vars */
return vscode.Disposable.from(clsWatcher, trgWatcher);
}
};

function notifyDebuggerSessionFileChanged(): void {
const notifyDebuggerSessionFileChanged = (): void => {
if (vscode.debug.activeDebugSession) {
vscode.debug.activeDebugSession.customRequest(HOTSWAP_REQUEST);
}
}
};

export async function activate(extensionContext: vscode.ExtensionContext) {
export const activate = async (extensionContext: vscode.ExtensionContext): Promise<void> => {
console.log('Apex Debugger Extension Activated');
const extensionHRStart = process.hrtime();
const commands = registerCommands();
Expand Down Expand Up @@ -276,9 +276,9 @@ export async function activate(extensionContext: vscode.ExtensionContext) {
}

telemetryService.sendExtensionActivationEvent(extensionHRStart);
}
};

export function deactivate() {
export const deactivate = () => {
console.log('Apex Debugger Extension Deactivated');
telemetryService.sendExtensionDeactivationEvent();
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { messages as enMessages } from './i18n';
import { messages as jaMessages } from './i18n.ja';
const supportedLocales = [DEFAULT_LOCALE, LOCALE_JA];

function loadMessageBundle(config?: Config): Message {
const loadMessageBundle = (config?: Config): Message => {
const base = new Message(enMessages);

const localeConfig = config ? config.locale : DEFAULT_LOCALE;
Expand All @@ -30,7 +30,7 @@ function loadMessageBundle(config?: Config): Message {
}

return base;
}
};

export const nls = new Localization(
loadMessageBundle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class MockJorje {
}

public languageClientUtils = {
getStatus() {
getStatus: () => {
return {
isReady() {
isReady: () => {
return true;
},
failedToInitialize() {
failedToInitialize: () => {
return false;
},
getStatusMessage() {
getStatusMessage: () => {
return '';
}
};
Expand Down

0 comments on commit 5f99f40

Please sign in to comment.