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

support modifying existing problem matchers #7455

Merged
merged 1 commit into from
Apr 1, 2020

Conversation

elaihau
Copy link
Contributor

@elaihau elaihau commented Mar 30, 2020

  • VS Code supports the possibility of modifying existing problem matchers. With this change, Theia users can define a base problem matcher in which they can further customize the properties fileLocation, applyTo, owner, severity, pattern, and source.

  • resolves [tasks] support modifying existing problem matchers #6427

Signed-off-by: Liang Huang lhuang4@ualberta.ca

How to test

With this change, a user can define a base problem matcher in which they can further customize:

{
  "type": "npm",
  "script": "lint",
  "problemMatcher": {
    "base": "$eslint-stylish",
    "applyTo": "closedDocuments"
  },
  "isBackground": true
}

Instead of linting all files, the task above only lints the closed documents due to the existence of "applyTo": "closedDocuments"

Steps to test

  1. Open a workspace, define a task that produces warnings ONLY.
    Mine is
    {
        "type": "npm",
        "script": "lintAAB",
        "problemMatcher": [
            "$eslint-stylish"
            ]
          }
        ]
    }

and the npm lintAAB is defined in package.json as follows

  "scripts": {
    "lintAAB": "eslint ."
  }
  1. Run the task. After the task finishes, all warnings should have been displayed as warning markers in the problems view.

  2. Use "$eslint-stylish" as the base, and override the patterns property. The task config looks like this:

        {
            "type": "npm",
            "script": "lintAAB",
            "problemMatcher": [{
                "base": "$eslint-stylish",
                "pattern": [
                        {
                            "regexp": "^([^\\s].*)$",
                            "kind": "location",
                            "file": 1
                        },
                        {
                            "regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.+?)(?:\\s\\s+(.*))?$",
                            "line": 1,
                            "column": 2,
                            "severity": 1, // error
                            "message": 4,
                            "code": 5,
                            "loop": true
                        }
                    ]
            }   
            ]
        }
  1. Run this task one more time, check the problems view after it finishes
    Expected: all warning markers are created as error markers this time

Peek 2020-03-30 16-04

  1. Repeat Step 1 - 4 for other properties, such as fileLocation, applyTo, owner, severity, pattern, and source.

Review checklist

- VS Code supports the possibility of modifying existing problem matchers. With this change, Theia users can define a base problem matcher in which they can further customize the properties `background`, `fileLocation`, `applyTo`, `owner`, `severity`, `pattern`, and `source`.

- resolves #6427

Signed-off-by: Liang Huang <lhuang4@ualberta.ca>
@akosyakov akosyakov added tasks issues related to the task system vscode issues related to VSCode compatibility labels Mar 31, 2020
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the changes using a modified version of my workspace eslint-ws, and was able to successfully extend eslint-stylish by updating properties. 👍

For example, I was able to modify:

  • severity
  • applyTo
  • owner
  • source
  • pattern
  • fileLocation

@elaihau elaihau merged commit cf86e86 into master Apr 1, 2020
@elaihau elaihau deleted the Liang/modifyExistingProblemMatcher branch April 1, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tasks] support modifying existing problem matchers
3 participants