Setup for IDE integration

Eclipse setup

To use CoverageBrowser as language server for Eclipse™, you need to:

  • Add LSP (Language Server Protocol) support to Eclipse IDE.
  • Add a launch configuration in Eclipse to start CoverageBrowser as language server.
  • Specify file types, such as C++ source files, to use the launch configuration for.

LSP support for Eclipse IDE

LSP support for Eclipse IDE is provided by the Eclipse Foundation project Eclipse LSP4E. As the first step, add the latest release of LSP4E to Eclipse. While this is described in Eclipse documentation in Updating and installing software, we will try to cover the steps here, too.

First, you need to tell Eclipse where to find this project:

  1. Go to Help > Install New Software.
  2. Click the Add button.
  3. Type a name into the Name text box, for example LSP4E.
  4. If the software site is located on the web, type the Web Site location (URL) of the site into the Location text box. You may also paste or drag and drop the following URL from a web browser into this text box: https://download.eclipse.org/lsp4e/releases/latest.

Then use this newly added site to install LSP4E to Eclipse:

  1. Go to Help > Install New Software.
  2. Select the site that was created previously; in our example case LSP4E.
  3. Check all checkboxes.
  4. Follow the instructions in the dialog to finish the installation.

If the installation was successful, the IDE now has LSP support.

Launch configuration to start CoverageBrowser as language server

A launch configuration describes how to start a program; in our case CoverageBrowser. To create a launch configuration:

  • Click Run > External Tools > External Tools Configuration.
  • Click New Launch Configuration button, and set a name in the Name field (Coco, for example).
  • In the Location field, enter the path to the folder containing CoverageBrowser.
  • In the Arguments field, enter the following arguments, each on a separate line:
    • Potentially, the path to the csmes files to open.
    • The flag --lsp-stdio or --lsp-stdio-proxy=/path/to/another/LS, depending on preferences.
  • Click Close.

The Launch Configuration is now ready for use.

Configure Eclipse to use the launch configuration that starts CoverageBrowser as a language server. To configure it for C++ source files:

  • Click Window > Preferences > Language Servers.
  • Click the Add button.
  • Select C++ Source File on the left side and Program > Coco on the right side (assuming the launch configuration is called Coco).
  • Click the Finish button.

When you open a C++ source file, CoverageBrowser is started as language server and provides information about the coverage of the currently opened file based on the csmes files.

Emacs setup

To use CoverageBrowser as language server for Emacs, one must:

  • Enable LSP support in Emacs.
  • Register CoverageBrowser as a LSP server in Emacs.

Enable LSP support in Emacs

To enable Emacs to understand LSP, we recommend that you install LSP Mode, as instructed in the Installation section in its documentation.

In the following section, we will assume that LSP Mode is already installed.

Register CoverageBrowser as LSP server

The registration is done by adding some lines to the init.el file for Emacs. For more information, see Adding support for languages.

For example, a simple registration of CoverageBrowser as LSP server for C++ can be done by adding the following code to init.el:

(add-hook 'c++-mode-hook 'lsp)

(with-eval-after-load 'lsp-mode
    (setq lsp-log-io t)
    (add-to-list 'lsp-language-id-configuration
        '(c++-mode . "coco"))
    (lsp-register-client
        (make-lsp-client :new-connection
            (lsp-stdio-connection '("Path/To/CoverageBrowser" "--lsp-stdio"))
                    :activation-fn (lsp-activate-on "coco")
                    :server-id 'coco)))

Qt Creator setup

Qt Creator v 8.0.0 and above has native support of CoverageBrowser's IDE integration. The integration is described in Checking Code Coverage in the Qt Creator Manual.

Microsoft Visual Studio setup

IDE integration for Microsoft® Visual Studio® is done by an extension named Squish Coco Integration in Visual Studio that is automatically installed as part of the Squish Coco installation process.

Usually, the extension finds and starts the CoverageBrowser binary automatically. If this does not happen, set the SQUISHCOCO_CBBIN environment variable to the full path of the CoverageBrowser binary. The SQUISHCOCO_CBARGS variable can be used to set the command line arguments for CoverageBrowser, but it is rarely needed.

Visual Studio Code setup

For Visual Studio Code (VS Code), use the Coco VsCode Integration extension that you can install from the Visual Studio Marketplace. For more information about installing VS Code extensions, see VS Code documentation.

Usually, the extension finds and starts the CoverageBrowser binary automatically. If this does not happen, set the lsp-vscode.coverageBrowser configuration setting to the full path of the CoverageBrowser binary. The lsp-vscode.coverageBrowserArguments can be used to set additional command line arguments for CoverageBrowser, but it is rarely needed.

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.