Skip to content

Commit

Permalink
Merge branch 'develop' into cristi/w-14720671
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCanizales authored Dec 29, 2023
2 parents 457ef52 + cc7aff2 commit 53b338c
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 61 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/require-await": "warn",
"@typescript-eslint/no-unsafe-return": "warn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ describe('Replay debugger adapter - integration', () => {
});
});

function createBreakpointsArgs(
const createBreakpointsArgs = (
classPath: string,
lineNumbers: number[]
): DebugProtocol.SetBreakpointsArguments {
): DebugProtocol.SetBreakpointsArguments => {
const result: DebugProtocol.SetBreakpointsArguments = {
source: {
path: classPath
Expand All @@ -271,19 +271,19 @@ function createBreakpointsArgs(
result.breakpoints!.push({ line: lineNumber })
);
return result;
}
};

function assertBreakpointsCreated(
const assertBreakpointsCreated = (
response: DebugProtocol.SetBreakpointsResponse,
expectedNumOfBreakpoints: number,
expectedSourcePath: string,
expectedLineNumbers: number[]
) {
) => {
expect(response.success).to.equal(true);
expect(response.body.breakpoints.length).to.equal(expectedNumOfBreakpoints);
response.body.breakpoints.forEach(bp => {
expect(bp.verified).to.be.true;
expect(bp.source!.path).to.equal(expectedSourcePath);
expect(expectedLineNumbers).to.include(bp.line!);
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ApexHeapDump } from '../../../src/core';
// Rather than duplicate a large heapdump in multiple places just have a common function return it. The
// heap dump for triggers is ends up bring pretty large but there are only 3 Account records in here.
// This method contains the elements necessary to test the Trigger variables in the heapdump.
export function createHeapDumpResultForTriggers(): ApexHeapDump {
export const createHeapDumpResultForTriggers = (): ApexHeapDump => {
// This particular heapdump was taken after an insert. The Trigger booleans for isafter and isinsert will
// be true. isbefore, isdelete, isundelete and isupdate will be false. The Trigger.new and Trigger.newmap
// will both be populated with 3 Account objects.
Expand Down Expand Up @@ -409,10 +409,10 @@ export function createHeapDumpResultForTriggers(): ApexHeapDump {
}
} as ApexExecutionOverlayResultCommandSuccess);
return heapdump;
}
};

// HeapDump with no String typename entries entries
export function createHeapDumpWithNoStringTypes(): ApexHeapDump {
export const createHeapDumpWithNoStringTypes = (): ApexHeapDump => {
const heapdump = new ApexHeapDump('some ID', 'Foo', '', 10);
heapdump.setOverlaySuccessResult({
HeapDump: {
Expand Down Expand Up @@ -602,10 +602,10 @@ export function createHeapDumpWithNoStringTypes(): ApexHeapDump {
} as ApexExecutionOverlayResultCommandSuccess);

return heapdump;
}
};

// Heapdump with typeName string entries
export function createHeapDumpWithStrings(): ApexHeapDump {
export const createHeapDumpWithStrings = (): ApexHeapDump => {
const heapdump = new ApexHeapDump('some ID', 'Foo', '', 10);
heapdump.setOverlaySuccessResult({
HeapDump: {
Expand Down Expand Up @@ -647,11 +647,11 @@ export function createHeapDumpWithStrings(): ApexHeapDump {
}
} as ApexExecutionOverlayResultCommandSuccess);
return heapdump;
}
};

// Partial heapdump with a nested reference, used to verify both leaf reference
// parsing and putting a variable together from the leaves.
export function createHeapDumpWithNestedRefs(): ApexHeapDump {
export const createHeapDumpWithNestedRefs = (): ApexHeapDump => {
const heapdump = new ApexHeapDump('some ID', 'Foo', '', 10);
heapdump.setOverlaySuccessResult({
HeapDump: {
Expand Down Expand Up @@ -835,10 +835,10 @@ export function createHeapDumpWithNestedRefs(): ApexHeapDump {
}
} as ApexExecutionOverlayResultCommandSuccess);
return heapdump;
}
};

// Partial heapdump with a circular reference
export function createHeapDumpWithCircularRefs(): ApexHeapDump {
export const createHeapDumpWithCircularRefs = (): ApexHeapDump => {
const heapdump = new ApexHeapDump('some ID', 'Foo', '', 10);
heapdump.setOverlaySuccessResult({
HeapDump: {
Expand Down Expand Up @@ -910,4 +910,4 @@ export function createHeapDumpWithCircularRefs(): ApexHeapDump {
}
} as ApexExecutionOverlayResultCommandSuccess);
return heapdump;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,15 @@ describe('ApexExecutionOverlayResult heapdump parsing with ActionScript SOQL res
});

// Verify that the number passed in is a hex address
function isHex(inputString: string): boolean {
if (inputString.startsWith('0x')) {
inputString = inputString.substr(2);
}
const a = parseInt(inputString, 16);
return a.toString(16) === inputString.toLowerCase();
}
const isHex = (inputString: string): boolean => {
return /^(0x)?[a-f0-9]+$/i.test(inputString);
};

export function createExpectedXHROptions(
export const createExpectedXHROptions = (
requestBody: string | undefined,
requestUrl: string,
restHttpMethodEnum: RestHttpMethodEnum
): XHROptions {
): XHROptions => {
return {
type: restHttpMethodEnum,
url: requestUrl,
Expand All @@ -690,7 +686,7 @@ export function createExpectedXHROptions(
},
data: requestBody
} as XHROptions;
}
};

/* The test code used to generate the heap dump. This is important because of the ordering for the verification
There are comments below where the checkpoints were set and where the various SOQL/Apex ActionScript were executed
Expand Down
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 53b338c

Please sign in to comment.