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

task: fix problem matcher failed when kind is file #11190

Conversation

DanboDuan
Copy link
Contributor

@DanboDuan DanboDuan commented May 23, 2022

Signed-off-by: bob [email protected]

What it does

It will always fails when task problem matcher kind is file as this:

{
    "tasks":
    [
        {
            "command": "cat test.log",
            "label": "test",
            "problemMatcher":
            {
                "fileLocation": "absolute",
                "owner": "Test",
                "pattern":
                [
                    {
                        "file": 1,
                        "kind": "file",
                        "regexp": "^([^\\s].*)$"
                    },
                    {
                        "code": 5,
                        "loop": true,
                        "message": 4,
                        "regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.+?)(?:\\s\\s+(.*))?$",
                        "severity": 3
                    }
                ]
            },
            "type": "shell"
        }
    ],
    "version": "2.0.0"
}

the test log should be

> [email protected] lint /home/test
> eslint .


/home/test/test-dir.js
  14:21  warning  Missing semicolon  semi
  15:23  warning  Missing semicolon  semi
  103:9  error  Parsing error: Unexpected token inte

/home/test/more-test.js
  13:9  error  Parsing error: Unexpected token 1000

✖ 3 problems (1 error 2 warnings)
  0 errors and 2 warnings potentially fixable with the `--fix` option.

this is the startStopMatcher2 case from packages/task/src/node/task-problem-collector.spec.ts, I just changes the kind from location to file.

the main cause is that the this.cachedProblemData.kind will always be undefined when cachedProblemData is created. just changes the not be undefined to be undefined

protected doOneLineMatch(line: string): boolean {
    if (this.activePattern) {
        const regexp = new RegExp(this.activePattern.regexp);
        const regexMatches = regexp.exec(line);
        if (regexMatches) {
            if (this.activePattern.kind !== undefined && this.cachedProblemData.kind !== undefined) {
                this.cachedProblemData.kind = this.activePattern.kind;
            }
            return this.fillProblemData(this.cachedProblemData, this.activePattern, regexMatches);
        }
    }
    return false;
}

How to test

Review checklist

Reminder for reviewers

@DanboDuan DanboDuan changed the title fix problem matcher failed when kind is file task: fix problem matcher failed when kind is file May 23, 2022
@DanboDuan
Copy link
Contributor Author

@msujew @vince-fugnitto could you please help review this pr or ask someone else

Signed-off-by: bob <[email protected]>
@colin-grant-work colin-grant-work self-requested a review May 23, 2022 15:29
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! The code is correct, and the tests pass. A couple of minor comments on the code itself, but with those minor changes, this will be good to go.

packages/task/src/node/task-problem-collector.spec.ts Outdated Show resolved Hide resolved
packages/task/src/node/task-abstract-line-matcher.ts Outdated Show resolved Hide resolved
DanboDuan and others added 2 commits May 24, 2022 10:14
@DanboDuan
Copy link
Contributor Author

Thanks for the contribution! The code is correct, and the tests pass. A couple of minor comments on the code itself, but with those minor changes, this will be good to go.

Thx!

Signed-off-by: bob <[email protected]>
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

Looks good to me. File type locations are now handled correctly. 👍

@vince-fugnitto vince-fugnitto added the tasks issues related to the task system label May 24, 2022
@DanboDuan
Copy link
Contributor Author

Looks good to me. File type locations are now handled correctly. 👍

Thx. @vince-fugnitto @colin-grant-work could you please help merge this pr

@colin-grant-work colin-grant-work merged commit e356217 into eclipse-theia:master May 25, 2022
@vince-fugnitto vince-fugnitto added this to the 1.26.0 milestone May 26, 2022
@DanboDuan DanboDuan deleted the fix/problem_matcher_file_kind_failed branch May 27, 2022 03:57
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants