VSCode problemmatcher: Unknown subfolder for file location

Viewed 435

I have a problem matcher defined like this:

"fileLocation": ["relative", "${workspaceFolder}"],

And I only know the name of the file and NOT the relative path from my compilation output. Than it only opens files when they are in the root of the workspace.

E.g. Problem matcher searches for: Package.sql But the file is under

  • root
    • Other Subfolders
    • PKGs
      • Package.sql

Is there a setting to let the problem matcher "find" that file, even if it's in a (unknown) subfolder? (Assumed all filenames are distinct)

2 Answers

You can use "command" string for print file with relative or absolute path like this: echo FILEBEGIN${relativeFile}FILEEND or echo FILEBEGIN${file}FILEEND

And it will be easy to get file by regex.

If you are using oracle and powershell you can try my task:

{
   "label": "compile",
   "type": "shell",
   "command": "echo 'set define off' 'set serveroutput on' '@${file}' 'exit' | sqlplus ${config:plsql-language.connection.activeInfos} | Select-String -Pattern '(\\d+/\\d+.*|.*created.*)' | % {'${relativeFile}:' + $($_.matches.value)}",
   "group": {
      "kind": "build",
      "isDefault": true
   },
   "problemMatcher": {
      "owner": "PLSQL",
      "severity": "error",
      "fileLocation":  ["relative", "${workspaceFolder}"],
      "pattern":
         {
            "regexp": "^(.*):(\\d+)\\/(\\d+)\\s+((PLS|ORA)-\\d+):(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "code": 4,
            "message": 6
         }
   }
}

The problem matcher should return either absolute path, or path relative to a fixed folder inside the workspace. If you have a filename only, without absolute/relative path, in my understanding Code won't be able to locate the file as the name only is not enough information. There is also the autodetect option. You can try something like this: "fileLocation": ["autodetect", "${workspaceFolder}/subfolder1/subfolder2"]

Related