stinb / UnderstandForVSCode

VS Code extension for Understand
https://www.scitools.com
MIT License
1 stars 0 forks source link
code-comprehension static-analysis

Understand for Visual Studio Code

Understand by SciTools is a popular platform for code comprehension and maintaining legacy code. This plugin shows the static analysis results from Understand in Visual Studio Code.


Video

See the extension in action in our video.

Video: Get the best of both worlds with the Visual Studio Code extension for Understand


Licensing

To use this extension, you must have a valid Understand license. Try it for free with a trial license. Students and teachers can get a free educational license. Please see available options at scitools.com/pricing.


Compare to Other Extensions

Understand by SciTools C/C++ by Microsoft clangd by LLVM C/C++ Advanced Lint by Joseph Benden
Supports more than C/C++ Yes No No No
Can analyze whole project Yes Yes No No
See all errors/warnings at launch Yes No No No
Definitions and other references Yes Yes Yes No
Hover for arguments, type, etc. Yes Yes Yes No
AUTOSAR, MISRA, CERT, etc. Yes No No Yes
Companion GUI application Yes No No No

Compatibility


Features

See or Go To References

Screenshot of hover information with types in the editor


See Hover Information

Screenshot of hover information with types in the editor


See Errors and Warnings

Screenshot of an analysis error violation in the editor


Quickly Analyze Your Code

Screenshot of analysis progress on the status bar


Explore in Understand

Screenshot of our main product Understand


Understand Different Languages


Setup

Screenshot of the status item showing "Connected to the Understand language server"

Setup: Installation

  1. Install Understand, which comes with UServer, the Understand language server

  2. Open Visual Studio Code and install this extension, if you haven't already

Setup: Project Creation

  1. Using at least 1 source code file, create a project in Understand, resulting in a .und folder. With this extension, you can simply create a source code file and run the command "Understand: Explore in Understand: New Project" to quickly get started.

  2. If you want to see violations from CodeCheck, make your CodeCheck configuration(s) run in the background

  3. In Visual Studio Code, open a folder/workspace that contains the .und folder. Also, include all of the source code files that you want.


FAQ

Why is the language server executable not found?

Make the command userver accessible to Visual Studio Code

Why isn't the language server starting?

Make sure that you have a .und folder in your file explorer, which is created automatically when creating an Understand project.


Why aren't my results accurate after creating or deleting a file?

If your project uses compile_commands.json, then you must build after creating or deleting files.


Now that I am connected to the Understand language server, how do I use it?

Command Palette:

  1. Open the command palette with the keybinding for workbench.action.showCommands and type in Understand to see all of the commands available to you.
  2. Click the gear to view the command ID and start adding keyboard startcuts.

Status Bar:

Code Actions:

Editor Context Menu:


Why don't I see some commands in certain files?

If a file isn't a resolved project file, then the file-specific commands won't show up in the command palette. The other commands - general and project-specific - should still be available.


Why don't I see certain kinds of references, like declarations, type definitions, or implementations?

  • It might be because the token doesn't have an entity, like a number literal or a keyword.
  • An entity may not have the reference kind that you are looking for. For example, in C, an int object doesn't have a type definition because it's a primitive type, but a struct object does if the type is resolved.
  • Some languages don't have certain reference kinds. For example, C doesn't have implementations, but Java does.

Why don't violations go away after manually fixing them?

  • You should analyze after manually fixing an error or warning.

How do I see the name of a violation?

Do any of the following


How do I skip certain violations with the "Go to Next/Previous Violation" commands?


How do I have more control over showing/focusing on the violations (Problems panel)?

In keybindings.json, try different keybindings like the following. Read more about the "when" property and running multiple commands.

// Example keybinding: Show violations and focus on violations, but close when it's focused
{
    "key": "alt+v",
    "command": "understand.violations.toggleVisibilityAndFocus",
},
// Example keybinding: When in the editor, show violations but keep focus on the editor
{
    "key": "alt+v",
    "command": "runCommands",
    "when": "editorFocus && activePanel != 'workbench.panel.markers'",
    "args": {
        "commands": [
            "understand.violations.toggleVisibilityAndFocus",
            "workbench.action.focusLastEditorGroup",
        ],
    }
},
// Example keybinding: When in the editor, close violations from the editor
{
    "key": "alt+v",
    "command": "runCommands",
    "when": "editorFocus && activePanel == 'workbench.panel.markers'",
    "args": {
        "commands": [
            "understand.violations.toggleVisibilityAndFocus",
            "understand.violations.toggleVisibilityAndFocus",
            "workbench.action.focusLastEditorGroup",
        ],
    }
},
// Example keybinding: When in the violations panel, focus on the editor
{
    "key": "alt+v",
    "when": "panelFocus && activePanel == 'workbench.panel.markers'",
    "command": "workbench.action.focusLastEditorGroup",
},
// Example keybinding: When in the violations panel, close it
{
    "key": "escape",
    "when": "panelFocus && activePanel == 'workbench.panel.markers'",
    "command": "understand.violations.toggleVisibilityAndFocus",
},

How do I change the colors of violations?

In settings.json, the colors can be changed. This is especially useful for color blind users

{
    // See all color customizations:
    // https://code.visualstudio.com/api/references/theme-color
    "workbench.colorCustomizations": {
        // Editor squiggles and problems panel
        "editorWarning.foreground": "#ffff77",
        "editorError.foreground": "#ff7777",
        // File name color
        "list.warningForeground": "#ffff77",
        "list.errorForeground": "#ff7777"
    }
}