-
Notifications
You must be signed in to change notification settings - Fork 31.9k
fix named multiline problem pattern parsing #65840
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
Conversation
408: vscode problem matcher improvements r=matklad a=vemoo The problem matcher wasn't working properly and looking at the rustc errors i realized it could be simplified. I also added a new problem matcher that can be used with https://github.com/passcod/cargo-watch to get the errors in the editor on save. To use it one can create a tasks.json file with: ```json { "version": "2.0.0", "tasks": [ { "type": "shell", "label": "cargo watch", "command": "cargo", "isBackground": true, "args": [ "watch", "-c" ], "problemMatcher": [ "$rustc-watch" ] } ] } ``` I initially implemented it like this: cff9f62 but i think there's a bug in vscode so i worked around it by copying the pattern for both problem matchers. The first commit can be used if microsoft/vscode#65840 is merged. Co-authored-by: Bernardo <berublan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the original if
check around the error doesn't take into account named multiline problem matchers. Instead of moving the error into this else
, the original if
should be modified to also check for named and named multiline checked problem matchers.
I was going to do that initialy but I think that's part of the reason this bug happened, that the validation is being made twice. My reasoning is the following:
Another more explicit way to write it while avoiding duplicate checks and being less error prone would be this: const missingRegExpError = () => {
this.error(localize('ProblemPatternParser.problemPattern.missingRegExp', 'The problem pattern is missing a regular expression.'));
};
if (Config.NamedMultiLineCheckedProblemPattern.is(value)) {
return this.createNamedMultiLineProblemPattern(value);
} else if (Config.MultiLineProblemPattern.is(value)) {
if (Config.MultiLineCheckedProblemPattern.is(value)) {
return this.createMultiLineProblemPattern(value);
} else {
missingRegExpError();
return null;
}
} else if (Config.NamedProblemPattern.is(value)) {
if (Config.NamedCheckedProblemPattern.is(value)) {
let result = this.createSingleProblemPattern(value) as NamedProblemPattern;
result.name = value.name;
return result;
} else {
missingRegExpError();
return null;
}
} else if (Config.CheckedProblemPattern.is(value)) {
return this.createSingleProblemPattern(value);
} else {
missingRegExpError();
return null;
} Would that be better? |
I see your point about validation being done twice. To keep things concise, how about if (Config.NamedMultiLineCheckedProblemPattern.is(value)) {
return this.createNamedMultiLineProblemPattern(value);
} else if (Config.MultiLineProblemPattern.is(value) && Config.MultiLineCheckedProblemPattern.is(value)) {
return this.createMultiLineProblemPattern(value);
} else if (Config.NamedProblemPattern.is(value) && Config.NamedCheckedProblemPattern.is(value)) {
let result = this.createSingleProblemPattern(value) as NamedProblemPattern;
result.name = value.name;
return result;
} else if (Config.CheckedProblemPattern.is(value)) {
return this.createSingleProblemPattern(value);
} else {
// this.error line
return null;
} |
I like that, the only things is tha both
That's why i didn't include the non |
Thanks for the contribution and for being so thorough! |
Now that microsoft/vscode#65840 is in the latest release we can use the first commit from rust-lang#408
858: Use named multiline Problem Matcher r=matklad a=kjeremy Now that microsoft/vscode#65840 is in the latest release we can use the first commit from #408 Co-authored-by: kjeremy <kjeremy@gmail.com>
Before an error was being generated for valid named multiline problem patterns like this:
And when an error was generated the pattern was ignored.
This PR fixes that.