coc-sonarlint 0.0.9 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,6 +62,14 @@ This extension also provides a custom root directory where the sonar lint binari
62
62
  }
63
63
  ```
64
64
 
65
+ Sonarlint will try to prompt you when a compile commands in c or cpp projects is not found, to disable that feature globally, and ignore the missing compile commands you can set the following property in your coc-settings.json
66
+
67
+ ```json
68
+ {
69
+ "sonarlint.notifyMissingCompileCommands": false
70
+ }
71
+ ```
72
+
65
73
  The directory must contain two folders, a server/ and analyzers/, where the server binary is located in the server/ folder and all analyzer binaries are located in the analyzers/ folder
66
74
 
67
75
  ### JS/TS analysis specific requirements
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/index.js CHANGED
@@ -12315,28 +12315,27 @@ var coc12 = __toESM(require("coc.nvim"));
12315
12315
 
12316
12316
  // src/settings/settings.ts
12317
12317
  var import_coc = require("coc.nvim");
12318
- var currentConfig;
12319
12318
  var SONARLINT_CATEGORY = "sonarlint";
12320
12319
  var VERBOSE_LOGS = "output.showVerboseLogs";
12320
+ var PATH_TO_COMPILE_COMMANDS = "pathToCompileCommands";
12321
+ var NOTIFY_COMPILE_COMMANDS = "notifyMissingCompileCommands";
12321
12322
  function getSonarLintConfiguration() {
12322
12323
  return import_coc.workspace.getConfiguration(SONARLINT_CATEGORY);
12323
12324
  }
12324
12325
  function isVerboseEnabled() {
12325
- return getCurrentConfiguration()?.get(VERBOSE_LOGS, false);
12326
+ return getSonarLintConfiguration().get(VERBOSE_LOGS, false);
12326
12327
  }
12327
- function enableVerboseLogs() {
12328
- getCurrentConfiguration()?.update(
12329
- VERBOSE_LOGS,
12330
- true,
12331
- import_coc.ConfigurationTarget.Global
12332
- );
12333
- import_coc.window.showInformationMessage("Verbose logging enabled.");
12328
+ function isNotificationEnabled() {
12329
+ return getSonarLintConfiguration().get(NOTIFY_COMPILE_COMMANDS, true);
12334
12330
  }
12335
- function loadInitialSettings() {
12336
- currentConfig = getSonarLintConfiguration();
12331
+ function updateNotificationDisabled(value, target) {
12332
+ getSonarLintConfiguration().update(NOTIFY_COMPILE_COMMANDS, value, target);
12337
12333
  }
12338
- function getCurrentConfiguration() {
12339
- return currentConfig;
12334
+ function updateCompileCommandsPath(value, target) {
12335
+ getSonarLintConfiguration().update(PATH_TO_COMPILE_COMMANDS, value, target);
12336
+ }
12337
+ function updateVerboseLogging(value, target) {
12338
+ getSonarLintConfiguration().update(VERBOSE_LOGS, value, target);
12340
12339
  }
12341
12340
 
12342
12341
  // src/util/logging.ts
@@ -13344,7 +13343,7 @@ var javaServerInLightWeightModeAlreadyLogged = false;
13344
13343
  function installClasspathListener(languageClient2) {
13345
13344
  const extension2 = getJavaExtension();
13346
13345
  if (!extension2) {
13347
- coc9.window.showWarningMessage(`Unable to find any compliant java extension installed in the coc runtime`);
13346
+ logToSonarLintOutput(`Unable to find any compliant java extension installed in the coc runtime`);
13348
13347
  return;
13349
13348
  }
13350
13349
  if (extension2?.isActive) {
@@ -13407,7 +13406,7 @@ async function getJavaConfig(languageClient2, fileUri) {
13407
13406
  const extension2 = getJavaExtension();
13408
13407
  try {
13409
13408
  if (!extension2) {
13410
- coc9.window.showWarningMessage(`Unable to find any compliant java extension installed in the coc runtime`);
13409
+ logToSonarLintOutput(`Unable to find any compliant java extension installed in the coc runtime`);
13411
13410
  return;
13412
13411
  }
13413
13412
  const extensionApi = await extension2?.activate();
@@ -13691,31 +13690,14 @@ var SonarLintDocumentation;
13691
13690
  })(SonarLintDocumentation || (SonarLintDocumentation = {}));
13692
13691
 
13693
13692
  // src/cfamily/cfamily.ts
13694
- var PATH_TO_COMPILE_COMMANDS = "pathToCompileCommands";
13695
- var FULL_PATH_TO_COMPILE_COMMANDS = `${SONARLINT_CATEGORY}.${PATH_TO_COMPILE_COMMANDS}`;
13696
- var DO_NOT_ASK_ABOUT_COMPILE_COMMANDS_FLAG = "doNotAskAboutCompileCommands";
13697
13693
  var remindMeLaterAboutCompileCommandsFlag = false;
13694
+ var userSelectingCompileCommandsChoice = false;
13698
13695
  function showMessageAndUpdateConfig(compilationDbPath) {
13699
13696
  coc11.window.showInformationMessage(
13700
13697
  `Analysis configured. Compilation database path is set to: ${compilationDbPath}`
13701
13698
  );
13702
- const [pathForSettings, workspaceFolder] = tryRelativizeToWorkspaceFolder(compilationDbPath);
13703
- if (workspaceFolder !== void 0) {
13704
- const config = coc11.workspace.getConfiguration(
13705
- SONARLINT_CATEGORY,
13706
- workspaceFolder.uri
13707
- );
13708
- return config.update(
13709
- PATH_TO_COMPILE_COMMANDS,
13710
- pathForSettings,
13711
- coc11.ConfigurationTarget.WorkspaceFolder
13712
- );
13713
- }
13714
- return coc11.workspace.getConfiguration().update(
13715
- FULL_PATH_TO_COMPILE_COMMANDS,
13716
- pathForSettings,
13717
- coc11.ConfigurationTarget.Workspace
13718
- );
13699
+ const [pathForSettings, _] = tryRelativizeToWorkspaceFolder(compilationDbPath);
13700
+ updateCompileCommandsPath(pathForSettings);
13719
13701
  }
13720
13702
  function tryRelativizeToWorkspaceFolder(filePath) {
13721
13703
  if (!path3.isAbsolute(filePath)) {
@@ -13733,51 +13715,48 @@ function tryRelativizeToWorkspaceFolder(filePath) {
13733
13715
  async function configureCompilationDatabase() {
13734
13716
  const paths = (await coc11.workspace.findFiles(`**/compile_commands.json`)).filter((path4) => fs3.existsSync(path4.fsPath));
13735
13717
  if (paths.length === 0) {
13736
- coc11.window.showWarningMessage(
13737
- `No compilation databases were found in the workspace
13738
-
13739
- [How to generate compile commands](${SonarLintDocumentation.C_CPP_ANALYSIS})`
13740
- );
13741
- coc11.workspace.getConfiguration().update(
13742
- FULL_PATH_TO_COMPILE_COMMANDS,
13743
- void 0,
13744
- coc11.ConfigurationTarget.Workspace
13745
- );
13718
+ coc11.window.showWarningMessage(`No compilation databases were found in the workspace
13719
+ [How to generate compile commands](${SonarLintDocumentation.C_CPP_ANALYSIS})`);
13720
+ updateCompileCommandsPath(void 0);
13746
13721
  } else {
13747
13722
  await showCompilationDatabaseOptions(paths);
13748
13723
  }
13749
13724
  }
13750
- function notifyMissingCompileCommands(context) {
13725
+ function notifyMissingCompileCommands() {
13751
13726
  return async () => {
13752
- if (await doNotAskAboutCompileCommandsFlag(context) || remindMeLaterAboutCompileCommandsFlag) {
13727
+ if (userSelectingCompileCommandsChoice || isNotificationEnabled() !== true || remindMeLaterAboutCompileCommandsFlag) {
13753
13728
  return;
13754
13729
  }
13755
- const remindMeLaterAction = "Ask me later";
13756
- const configureCompileCommandsAction = "Configure compile commands";
13757
- const message = `SonarLint is unable to analyze C and C++ file(s) because there is no configured compilation
13758
- database.`;
13759
- coc11.window.showWarningMessage(
13730
+ userSelectingCompileCommandsChoice = true;
13731
+ const remindMeLaterAction = "Ask me later again";
13732
+ const doNotAskGlobally = "Never ask or prompt me again";
13733
+ const doNotAskForThisWorkspace = "Do not ask for this workspace";
13734
+ const configureCompileCommandsAction = "Configure compile commands now";
13735
+ const message = `SonarLint might be unable to analyze C and C++ file(s) because there is no configured compilation database.`;
13736
+ const selection = await coc11.window.showWarningMessage(
13760
13737
  message,
13761
13738
  configureCompileCommandsAction,
13762
- remindMeLaterAction
13763
- ).then((selection) => {
13764
- switch (selection) {
13765
- case configureCompileCommandsAction:
13766
- configureCompilationDatabase();
13767
- break;
13768
- case remindMeLaterAction:
13769
- remindMeLaterAboutCompileCommandsFlag = true;
13770
- break;
13771
- }
13772
- });
13739
+ remindMeLaterAction,
13740
+ doNotAskForThisWorkspace,
13741
+ doNotAskGlobally
13742
+ );
13743
+ switch (selection) {
13744
+ case configureCompileCommandsAction:
13745
+ configureCompilationDatabase();
13746
+ break;
13747
+ case remindMeLaterAction:
13748
+ remindMeLaterAboutCompileCommandsFlag = true;
13749
+ break;
13750
+ case doNotAskForThisWorkspace:
13751
+ updateNotificationDisabled(false, void 0);
13752
+ break;
13753
+ case doNotAskGlobally:
13754
+ updateNotificationDisabled(false, coc11.ConfigurationTarget.Global);
13755
+ break;
13756
+ }
13757
+ userSelectingCompileCommandsChoice = false;
13773
13758
  };
13774
13759
  }
13775
- async function doNotAskAboutCompileCommandsFlag(context) {
13776
- return context.workspaceState.get(
13777
- DO_NOT_ASK_ABOUT_COMPILE_COMMANDS_FLAG,
13778
- false
13779
- );
13780
- }
13781
13760
  async function showCompilationDatabaseOptions(paths) {
13782
13761
  if (paths.length === 1) {
13783
13762
  return showMessageAndUpdateConfig(paths[0].fsPath);
@@ -13789,7 +13768,7 @@ async function showCompilationDatabaseOptions(paths) {
13789
13768
  }));
13790
13769
  items.sort((i1, i2) => i1.label.localeCompare(i2.label));
13791
13770
  const selection = await coc11.window.showQuickPick(items, {
13792
- placeholder: "Pick a compilation database"
13771
+ placeholder: "Pick a compilation database source"
13793
13772
  });
13794
13773
  if (selection) {
13795
13774
  return showMessageAndUpdateConfig(paths[selection.index].fsPath);
@@ -13840,7 +13819,6 @@ async function runJavaServer(context) {
13840
13819
  });
13841
13820
  }
13842
13821
  async function activate(context) {
13843
- loadInitialSettings();
13844
13822
  setExtensionContext(context);
13845
13823
  initLogOutput(context);
13846
13824
  const serverOptions = () => runJavaServer(context);
@@ -14002,14 +13980,11 @@ function registerCommands(context) {
14002
13980
  context.subscriptions.push(
14003
13981
  coc12.commands.registerCommand(
14004
13982
  Commands.CONFIGURE_COMPILATION_DATABASE,
14005
- configureCompilationDatabase
13983
+ () => void configureCompilationDatabase()
14006
13984
  )
14007
13985
  );
14008
13986
  context.subscriptions.push(
14009
- coc12.commands.registerCommand(
14010
- Commands.ENABLE_VERBOSE_LOGS,
14011
- () => enableVerboseLogs()
14012
- )
13987
+ coc12.commands.registerCommand(Commands.ENABLE_VERBOSE_LOGS, () => updateVerboseLogging(true))
14013
13988
  );
14014
13989
  context.subscriptions.push(
14015
13990
  coc12.commands.registerCommand(Commands.INSTALL_MANAGED_JRE, () => {
@@ -14070,10 +14045,12 @@ function installCustomRequestHandlers(context) {
14070
14045
  coc12.Uri.parse(browseTo)
14071
14046
  )
14072
14047
  );
14073
- languageClient.onNotification(
14074
- NeedCompilationDatabaseRequest.type,
14075
- notifyMissingCompileCommands(context)
14076
- );
14048
+ if (isNotificationEnabled() !== false) {
14049
+ languageClient.onNotification(
14050
+ NeedCompilationDatabaseRequest.type,
14051
+ notifyMissingCompileCommands()
14052
+ );
14053
+ }
14077
14054
  }
14078
14055
  async function showAllLocations(issue) {
14079
14056
  const locations = [];
@@ -14114,8 +14091,20 @@ function deactivate() {
14114
14091
  }
14115
14092
  async function showRulesView(title) {
14116
14093
  allRulesView.title = title;
14117
- if (!allRulesView.visible) {
14118
- await allRulesView?.show();
14094
+ if (allRulesView?.visible) {
14095
+ const winId = allRulesView.windowId;
14096
+ const tabnr = await import_coc3.nvim.call("tabpagenr");
14097
+ const buflist = await import_coc3.nvim.call("tabpagebuflist", [tabnr]);
14098
+ const bufId = await import_coc3.nvim.call("winbufnr", [winId]);
14099
+ const found = buflist.find((bufnr) => {
14100
+ return bufId == bufnr;
14101
+ });
14102
+ if (!found) {
14103
+ await import_coc3.nvim.call("coc#window#close", [winId]);
14104
+ await allRulesView?.show("botright 10split");
14105
+ }
14106
+ } else if (!allRulesView?.visible) {
14107
+ await allRulesView?.show("botright 10split");
14119
14108
  }
14120
14109
  }
14121
14110
  function logWithPrefix(data, prefix) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "coc-sonarlint",
3
- "version": "0.0.9",
3
+ "version": "0.0.12",
4
4
  "description": "sonarlint for coc.nvim",
5
- "author": "asmodeus812 <svetlozar321@gmail.com>",
5
+ "author": "asmodeus812",
6
6
  "license": "MIT",
7
7
  "main": "lib/index.js",
8
8
  "keywords": [
@@ -310,6 +310,13 @@
310
310
  "markdownDescription": "Files whose name match this [glob pattern](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob) will not be processed by analyzers. In [Connected Mode](command:SonarLint.HelpAndFeedbackLinkClicked?%22connectedModeDocs%22) with SonarQube or SonarCloud, this property will be ignored and server exclusion settings will be applied. No rules are evaluated on excluded files. Example: `**/lib/**,**/*generated*`",
311
311
  "scope": "resource"
312
312
  },
313
+ "sonarlint.notifyMissingCompileCommands": {
314
+ "order": 21,
315
+ "default": true,
316
+ "type": "boolean",
317
+ "markdownDescription": "Specifies if missing or invalid compile commands in c or cpp projects will prompt the user to generate or create one, by default the user will be asked for each new workspace he visits, and the user can opt out of it per workspace by selecting the option - Do not ask for compile commands again for this workspace",
318
+ "scope": "resource"
319
+ },
313
320
  "sonarlint.ls.javaHome": {
314
321
  "order": 20,
315
322
  "type": "string",
Binary file