Skip to content

Commit

Permalink
Merge pull request #152 from Discookie/ericsson/intuitive-settings
Browse files Browse the repository at this point in the history
Extension settings rework part 1
  • Loading branch information
MiklosMagyari authored Jul 16, 2024
2 parents 5374a75 + 6ea8d8e commit 0fe2993
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
32 changes: 30 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@
"order": 3
},
"codechecker.executor.arguments": {
"type": "string",
"description": "Additional arguments to CodeChecker's analyze command. For example, if you want to use a config file for CodeChecker pass '--config <config.json>'. For supported arguments, run `CodeChecker analyze --help`. The command `CodeChecker: Show full command line` command shows the resulting command line.",
"deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.arguments` instead."
},
"codechecker.analyze.arguments": {
"type": "string",
"description": "Additional arguments to CodeChecker analyze command. For example, if you want to use a config file for CodeChecker pass '--config <config.json>'. For supported arguments, run `CodeChecker analyze --help`. The command `CodeChecker: Show full command line` command shows the resulting command line.",
"default": "",
"default": "--analyzer-config clangsa:mode=shallow",
"order": 4
},
"codechecker.executor.threadCount": {
Expand All @@ -132,17 +137,35 @@
"null"
],
"description": "CodeChecker's thread count - leave empty to use all threads",
"default": null,
"deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.threadCount` instead."
},
"codechecker.analyze.threadCount": {
"type": [
"number",
"null"
],
"description": "CodeChecker's thread count - leave empty to use all threads",
"default": 4,
"minimum": 1,
"order": 5
},
"codechecker.executor.logBuildCommand": {
"type": "string",
"description": "The build command passed to CodeChecker log.",
"deprecationMessage": "This setting is deprecated. Use `codechecker.log.buildCommand` instead."
},
"codechecker.log.buildCommand": {
"type": "string",
"description": "The build command passed to CodeChecker log.",
"default": "make",
"order": 6
},
"codechecker.executor.logArguments": {
"type": "string",
"description": "Additional arguments to CodeChecker log command. For supported arguments, run `CodeChecker log --help`. The command `CodeChecker: Preview CodeChecker log in terminal` command shows the resulting command line.",
"deprecationMessage": "This setting is deprecated. Use `codechecker.log.arguments` instead."
},
"codechecker.log.arguments": {
"type": "string",
"description": "Additional arguments to CodeChecker log command. For supported arguments, run `CodeChecker log --help`. The command `CodeChecker: Preview CodeChecker log in terminal` command shows the resulting command line.",
"default": "",
Expand Down Expand Up @@ -184,6 +207,11 @@
"default": true
},
"codechecker.executor.runOnSave": {
"type": "boolean",
"description": "Controls auto-run of CodeChecker on save",
"deprecationMessage": "This setting is deprecated. Use `codechecker.analyze.runOnSave` instead."
},
"codechecker.analyze.runOnSave": {
"type": "boolean",
"description": "Controls auto-run of CodeChecker on save",
"default": true
Expand Down
39 changes: 32 additions & 7 deletions src/backend/executor/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,16 @@ export class ExecutorBridge implements Disposable {

const reportsFolder = this.getReportsFolder();

const ccArgumentsSetting = workspace.getConfiguration('codechecker.executor').get<string>('arguments');
const executorConfig = workspace.getConfiguration('codechecker.executor');
const analyzeConfig = workspace.getConfiguration('codechecker.analyze');

const ccArgumentsSetting = analyzeConfig.has('arguments') ? analyzeConfig.get<string>('arguments')
: executorConfig.has('arguments') ? executorConfig.get<string>('arguments') : undefined;

const ccArguments = parseShellArgsAndReplaceVariables(ccArgumentsSetting ?? '');

const ccThreads = workspace.getConfiguration('codechecker.executor').get<string>('threadCount');
const ccThreads = analyzeConfig.has('threadCount') ? analyzeConfig.get<string>('threadCount')
: executorConfig.has('threadCount') ? executorConfig.get<string>('threadCount') : undefined;
// FIXME: Add support for selecting a specific workspace folder

const args = [
Expand Down Expand Up @@ -274,17 +279,27 @@ export class ExecutorBridge implements Disposable {
return undefined;
}

const executorConfig = workspace.getConfiguration('codechecker.executor');
const logConfig = workspace.getConfiguration('codechecker.log');

if (buildCommand === undefined) {
buildCommand = getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand') ?? 'make';
buildCommand = logConfig.has('buildCommand')
? getConfigAndReplaceVariables('codechecker.log', 'buildCommand')
: executorConfig.has('logBuildCommand')
? getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand')
: undefined;
} else {
buildCommand = replaceVariables(buildCommand) ?? 'make';
buildCommand = replaceVariables(buildCommand);
}

buildCommand = buildCommand ?? 'make';

const workspaceFolder = workspace.workspaceFolders[0].uri.fsPath;
const ccFolder = getConfigAndReplaceVariables('codechecker.backend', 'outputFolder')
?? path.join(workspaceFolder, '.codechecker');

const logArgumentsSetting = workspace.getConfiguration('codechecker.executor').get<string>('logArguments');
const logArgumentsSetting = logConfig.has('arguments') ? logConfig.get<string>('arguments')
: executorConfig.has('logArguments') ? executorConfig.get<string>('logArguments') : undefined;
const logArguments = parseShellArgsAndReplaceVariables(logArgumentsSetting ?? '');

// Use a predefined path as fallback here
Expand Down Expand Up @@ -326,7 +341,11 @@ export class ExecutorBridge implements Disposable {
}

private analyzeOnSave() {
const canAnalyzeOnSave = workspace.getConfiguration('codechecker.executor').get<boolean>('runOnSave');
const executorConfig = workspace.getConfiguration('codechecker.executor');
const analyzeConfig = workspace.getConfiguration('codechecker.analyze');

const canAnalyzeOnSave = analyzeConfig.has('runOnSave') ? analyzeConfig.get<boolean>('runOnSave')
: executorConfig.has('runOnSave') ? executorConfig.get<boolean>('runOnSave') : undefined;

// Analyze even if the comp.db doesn't exists, for multi-root workspaces
if (!canAnalyzeOnSave) {
Expand Down Expand Up @@ -402,9 +421,15 @@ export class ExecutorBridge implements Disposable {

public async runLogCustomCommand(buildCommand?: string) {
if (buildCommand === undefined) {
const executorConfig = workspace.getConfiguration('codechecker.executor');
const logConfig = workspace.getConfiguration('codechecker.log');

const logArguments = logConfig.has('arguments') ? logConfig.get<string>('arguments')
: executorConfig.has('logArguments') ? executorConfig.get<string>('logArguments') : undefined;

buildCommand = await window.showInputBox({
prompt: 'Enter the build command to run with CodeChecker log',
value: getConfigAndReplaceVariables('codechecker.executor', 'logBuildCommand') ?? 'make'
value: logArguments ?? 'make'
});
}

Expand Down

0 comments on commit 0fe2993

Please sign in to comment.