Skip to content

Commit

Permalink
NEW (Extension) @W-15640497@ Make Delta runs a user visible setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jag-j committed Sep 20, 2024
1 parent 6ed70e6 commit 10f23e0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@
"type": "boolean",
"default": false,
"description": "Discover critical problems and performance issues in your Apex code with ApexGuru, which analyzes your Apex files for you. This feature is in a closed pilot; contact your account representative to learn more."
},
"codeAnalyzer.deltaRuns.enabled": {
"type": "boolean",
"default": false,
"description": "***Enable delta run of Salesforce Graph Engine***"
}
}
},
Expand All @@ -187,7 +192,7 @@
},
{
"command": "sfca.runDfa",
"when": "false"
"when": "true"
},
{
"command": "sfca.removeDiagnosticsOnActiveFile",
Expand Down
14 changes: 9 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
});

sfgeCachePath = path.join(createTempDirectory(), 'sfca-graph-engine-cache.json');
const runDfaOnWorkspaceCmd = vscode.commands.registerCommand(Constants.COMMAND_RUN_DFA, async () => {
await _runDfa(context);
savedFilesCache.clear();
});
context.subscriptions.push(runOnActiveFile, runOnSelected, runDfaOnSelectedMethodCmd, runDfaOnWorkspaceCmd, removeDiagnosticsOnActiveFile, removeDiagnosticsOnSelectedFile, removeDiagnosticsInRange);
context.subscriptions.push(runOnActiveFile, runOnSelected, runDfaOnSelectedMethodCmd, removeDiagnosticsOnActiveFile, removeDiagnosticsOnSelectedFile, removeDiagnosticsInRange);

if (apexGuruEnabled) {
const runApexGuruOnSelectedFile = vscode.commands.registerCommand(Constants.COMMAND_RUN_APEX_GURU_ON_FILE, async (selection: vscode.Uri, multiSelect?: vscode.Uri[]) => {
Expand All @@ -150,6 +146,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
context.subscriptions.push(runApexGuruOnSelectedFile, runApexGuruOnCurrentFile);
}

if (SettingsManager.getSfgeDeltaRunsEnabled()) {
const runDfaOnWorkspaceCmd = vscode.commands.registerCommand(Constants.COMMAND_RUN_DFA, async () => {
await _runDfa(context);
savedFilesCache.clear();
});
context.subscriptions.push(runDfaOnWorkspaceCmd);
}

const documentSaveListener = vscode.workspace.onDidSaveTextDocument(document => {
const filePath = document.uri.fsPath;
savedFilesCache.add(filePath);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ export class SettingsManager {
public static getApexGuruEnabled(): boolean {
return vscode.workspace.getConfiguration('codeAnalyzer.apexGuru').get('enabled');
}

public static getSfgeDeltaRunsEnabled(): boolean {
return vscode.workspace.getConfiguration('codeAnalyzer.deltaRuns').get('enabled');
}
}
15 changes: 15 additions & 0 deletions src/test/suite/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,19 @@ suite('SettingsManager Test Suite', () => {
expect(result).to.equal(mockAnalyzeOnSaveEnabled);
expect(getConfigurationStub.calledOnceWith('codeAnalyzer.apexGuru')).to.be.true;
});

test('getSfgeDeltaRunsEnabled should return the delta runs enabled setting', () => {
// ===== SETUP =====
const mockAnalyzeOnSaveEnabled = true;
getConfigurationStub.withArgs('codeAnalyzer.deltaRuns').returns({
get: Sinon.stub().returns(mockAnalyzeOnSaveEnabled)
});

// ===== TEST =====
const result = SettingsManager.getSfgeDeltaRunsEnabled();

// ===== ASSERTIONS =====
expect(result).to.equal(mockAnalyzeOnSaveEnabled);
expect(getConfigurationStub.calledOnceWith('codeAnalyzer.deltaRuns')).to.be.true;
});
});

0 comments on commit 10f23e0

Please sign in to comment.