Skip to content

IntelliSenseinclude paths not updated after generated code using compileCommands #10854

Open
@tcm0116

Description

@tcm0116

Environment

  • OS and Version: Ubuntu 18.04
  • VS Code Version: 1.77.3
  • C/C++ Extension Version: v1.14.5
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

Our project utilizes Bazel and uses a tool to generate a compile_commands.json file that is intended to be used by the C/C++ IntelliSense engine. In many cases, the paths to the header files in the compile_commands.json reference folders within the Bazel build tree known as "virtual includes", which are symlinks to the actual headers. However, the "virtual includes" folders aren't created until a build is performed.

The issue at hand is that if the compile_commands.json is generated before the folders it references are created, then it's not possible to coerce IntelliSense to re-evaluate the includes for a given translation unit without re-generating the compile_commands.json file. Even using the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands do not cause it to re-evaluate the include paths.

As it stands, the only way we've been able to get IntelliSense to recognize the generated folders is to generate the compile_commands.json file after the folders have been generated.

Steps to reproduce:

  1. Generate a compile_commands.json file for a project that has includes in folders which are not yet created
  2. Open a .cpp file that includes a file from a path that has yet to be generated
  3. IntelliSense will show red squiggles for the include file that is not yet available
  4. Generate the missing file
  5. Close/re-open the file or run the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands
  6. IntelliSense will continue to show red squiggles for the include file that is now available
  7. Re-generate the compile_commands.json file (or use the Linux touch command to update the file times)
  8. IntelliSense will now re-process the includes and remove the red squiggles

Expected behavior:

The compile_commands.json should not have to be re-generated (or updated) in order to cause IntelliSense to discover include paths which were not present when the source code file was initially parsed by IntelliSense. CLosing/re-opening or using the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands should trigger this re-evaluation.

Configuration and Logs

{
    "configurations": [
        {
            "name": "gcc9-x86_64",
            "compilerPath": "${workspaceFolder}/external/cc_toolchain_linux-linux-gcc9-x86_64-linux_ubuntu_focal-x86_64/toolchain/usr/bin/x86_64-linux-gnu-gcc-9",
            "cStandard": "${default}",
            "cppStandard": "${default}",
            "compileCommands": "${default}"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions