zabel-xyz / plsql-language

plsql-language for vscode
MIT License
78 stars 29 forks source link

ProblemMatcher #20

Open Danieleeee opened 7 years ago

Danieleeee commented 7 years ago

Can you implement ProblemMatcher for this extension? vscode issues #28722

This is the result: screen shot 2017-03-21 at 08 50 30

Exemple of task.json:

{
    "version": "0.1.0",
    // The command is a shell script
    "isShellCommand": true,
    // Run sqlplus via a batch file
    "windows": {
        "command": "_run_sqlplus.bat"
    },
    "osx": {
        "command": "./_run_sqlplus.sh"
    },
    "linux": {
        "command": "./_run_sqlplus.sh"
    },

    // first argument is the database connection string
    // second argument is the file to execute (ie the current file)
    "args": ["username/password@//hostname:1521/xe", "@\"${file}\""],

    // do not switch to the output pane automatically
    "showOutput": "silent",

    // use this to get any database errors (from user_errors view) listed in the "Problems" pane in VS Code
    "problemMatcher": {
        "owner": "plsql",
        "fileLocation": ["relative", "${fileDirname}"],
        "pattern": [
          {
            "regexp": "(.*) (\\d*)\/(\\d*) (.*?) (.*)",
            "severity": 1,
            "line": 2,
            "column": 3,
            "file": 4,
            "message": 5,
            "loop": true
        }
      ]
    }
}
MadeManMax commented 6 years ago

Hi, I do it like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Wrap & Install",
            "type": "shell",
            "args": [
                "\"${fileDirname}\"",
                "${fileBasenameNoExtension}",
                "${fileExtname}",
                "user/pass@tnsname"
            ],
            "command": "c:\\oracle\\wrapAndInstall.bat",
            "problemMatcher": {
                "owner": "plsql",
                "fileLocation": [
                    "relative",
                    "${fileDirname}"
                ],
                "pattern": [
                    {
                        "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error|WARNING|ERROR):\\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                ]
            }
        }
    ]
}

In file wrapAndInstall.bat I mainly wrap and remove last line before \ and I use UnxTools for that, but if you don't want to wrap Your code just use line with sqlplur.exe

@echo off
cls
set fileDirname=%1
set fileName=%2
set fileExtension=%3
set connectionString=%4
echo %fileDirname% %fileName% %fileExtension%
rm %fileDirname%\%fileName%.plb
rm %fileDirname%\%fileName%.wrap
wrap.exe iname=%fileDirname%\%fileName%%fileExtension% oname=%fileDirname%\%fileName%.plb edebug=wrap_new_sql
gawk.exe "/./" < %fileDirname%\%fileName%.plb > %fileDirname%\%fileName%.wrap
rm %fileDirname%\%fileName%.plb
echo FILE:%fileName%.sql:
sqlplus.exe %connectionString% @"c:\oracle\product\12.1.0\client_2\BIN\plsql_compile.sql" %fileDirname%\%fileName%.wrap %fileName% %fileExtension%
rm %fileDirname%\%fileName%.wrap

The plsql_compile.sql file installs package and write formatted errors into consol which is then parsed by problem matcher. This solution is not perfect but it works. A, one more thing. I use following naming which is then taken into consideration in below script:

Hope this will help you configure your tasks with problem matcher.