Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem matcher doesn't work with contextual errors #227

Open
Khady opened this issue May 23, 2020 · 4 comments
Open

problem matcher doesn't work with contextual errors #227

Khady opened this issue May 23, 2020 · 4 comments
Labels
type: bug Something isn't working

Comments

@Khady
Copy link
Contributor

Khady commented May 23, 2020

There is a problem matcher for ocamlc defined in package.json:

{
"name": "ocamlc",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": [
{
"regexp": "^\\s*\\bFile\\b\\s*\"(.*)\",\\s*\\bline\\b\\s*(\\d+),\\s*\\bcharacters\\b\\s*(\\d+)-(\\d+)\\s*:\\s*$",
"file": 1,
"line": 2,
"column": 3,
"endColumn": 4
},
{
"regexp": "^(?:\\s*\\bParse\\b\\s*)?\\s*\\b([Ee]rror|Warning)\\b\\s*(?:\\(\\s*\\bwarning\\b\\s*(\\d+)\\))?\\s*:\\s*(.*)$",
"severity": 1,
"code": 2,
"message": 3
}
]
}

I tried to use it in a project with such a task:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compile",
            "type": "shell",
            "command": "opam exec -- dune build",
            "group": "build",
            "problemMatcher": "$ocamlc"
        }
    ]
}

When running the task (Tasks: run task -> compile), my build is launched but the errors are not picked up by vscode.

If I change package.json of this extension to this, then it is able to detect the compilation errors. But only the location. It can't detect the severity or the message.

    "problemMatchers": [
      {
        "name": "ocamlc",
        "fileLocation": [
          "relative",
          "${workspaceFolder}"
        ],
        "pattern": {
          "regexp": "^\\s*\\bFile\\b\\s*\"(.*)\",\\s*\\bline\\b\\s*(\\d+),\\s*\\bcharacters\\b\\s*(\\d+)-(\\d+)\\s*:\\s*$",
          "file": 1,
          "line": 2,
          "column": 3,
          "endColumn": 4
        }
      }
    ],

If I make the `pattern' field a list, even with only one element, then it doesn't seem to work. The documentation says that pattern can be a list. So I don't understand where the problem comes from.

Another issue but not as critical, the regexp is not able to handle locations for multi-line errors in ocaml 4.09+.

@Khady Khady changed the title problem matcher doesn't work problem matcher doesn't work with contextual errors May 23, 2020
@Khady
Copy link
Contributor Author

Khady commented May 23, 2020

(flags
  (:standard -error-style short))

I found out that if I set the error style to short then the problem matcher works. Maybe two matchers are needed. The current one for short errors. And one that ignores the lines starting with \d+ | or \s+\^ for contextual errors.

I'll try to give it a go if you think it's ok to do that.

@mnxn
Copy link
Collaborator

mnxn commented May 23, 2020

I'll try to give it a go if you think it's ok to do that.

Thank you for the detailed issue.
This functionality would indeed be useful. Feel free to submit a PR if you get it working.

@mnxn
Copy link
Collaborator

mnxn commented May 25, 2020

@Khady were all the problems fixed by #229?

@Khady
Copy link
Contributor Author

Khady commented May 26, 2020

No. It still works only with short errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants