microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

ProblemMatcher can't locate file located inside WorkspaceRoot subfolders. #10021

Closed Joebeazelman closed 1 year ago

Joebeazelman commented 1 year ago

Environment

OS and Version: MacOS 12.6 (21G115) VS Code Version: 1.72.2 (Universal)

I am using an extension designed for working with Ada projects. The project is normally built using a custom crate management tool, Alire, which sets several environment variables and call the same toolchain as the Ada Extension. Unfortunately, the Ada extension can't build the project because it's unaware of Alire's environment variables. To get around this issue, I'm overriding the extension's default task to call Alire instead.

So far, the project builds, but unlike extensions default build task, whenever there's a build error, clicking on any of the errors results in VSCode claiming it cannot find the file with an option to create it. I overrode the extension's ProblemMatcher inside my build task to use a relative location as displayed in the error message, but it cannot find them. Oddly enough, option clicking from in the terminal window works flawlessly. What could be the problem?

Code sample and Logs

Here's my build task:


{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "alire: Build project",
      "command": "alr",
      "args": ["build"],
      "problemMatcher": {
        "base": "$ada",
        "fileLocation": ["autoDetect", "${workspaceRoot}"],
        "pattern": {
          "regexp": "^([^:]:?[^:]*):(\\d+):(\\d+):\\s+(?:([a-z]+):\\s+)?(.*)$",
          "file": 1,
          "line": 2,
          "column": 3,
          "severity": 4,
          "message": 5
        }
      },
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Here's my workspace file (located inside .vscode folder in root of project):

{
  "folders": [
    {
      "path": "../"
    }
  ],
  "settings": {
    "ada.projectFile": "main.gpr",

    // Set a workspace-specific environment for Linux/OSX platforms
    "terminal.integrated.env.linux": {
      //  Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
      "MAIN_NUMBER": "MAIN_2",

      //  Optionally, you can append the Ada toolchain of your choice to the PATH environment variable
      //  if you want to use a different toolchain.
      //  "PATH": "<PATH_TO_TOOLCHAIN>:${env:PATH}",

      //  Append the path to the directory containing print_utils.gpr project file dependency to
      //  the GPR_PROJECT_PATH environment variable
      "GPR_PROJECT_PATH": "./imported:${env:GPR_PROJECT_PATH}"
    }
  }
}

Screenshots

No response

Additional context

No response

Colengms commented 1 year ago

Hi @Joebeazelman . This is the repo for the C/C++ extension for VS Code. It looks like you found the repo for the Ada extension and have posted there as well. So, I'll close this one. :)

Joebeazelman commented 1 year ago

Hi,

Is there a way to migrate this question to the appropriate VSCode project?

Colengms commented 1 year ago

Hi @Joebeazelman . Are you using the "Language Support for Ada" extension? If so, the "Repository" link on their Marketplace page links to the repo you posted your other issue in. I think that's the correct project.