-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[new-parser] Add error listener to DrlExprParser #5778
[new-parser] Add error listener to DrlExprParser #5778
Conversation
if (parser.hasErrors()) { | ||
for (DroolsParserException error : parser.getErrors()) { | ||
registerDescrBuildError(context, patternDescr, | ||
"Unable to parse pattern expression:\n" + error.getMessage()); | ||
} | ||
return null; | ||
} | ||
result.setResource(patternDescr.getResource()); | ||
result.copyLocation(original); |
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.
parser.hasErrors()
check needs to be performed before accessing result
. If the parsers has errors, result
is null.
@@ -55,7 +55,7 @@ public String getOperator() { | |||
} | |||
|
|||
public void setOperator( String operator ) { | |||
this.operator = operator.trim(); | |||
this.operator = operator != null ? operator.trim() : null; |
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.
This is to avoid an NPE in org.drools.drl.parser.antlr4.DRLExprParserTest#testNoViableAlt
.
} | ||
@Test | ||
public void testNoViableAlt() { | ||
String source = "a~a"; |
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.
I confess that I discovered this by chance. I'm not sure why this causes the NoViableAltException
but I couldn't come up with anything better.
e.getOffendingToken().getStartIndex(), | ||
public DroolsParserException createDroolsException(Object offendingSymbol, int line, int charPositionInLine, String message, RecognitionException e ) { | ||
return new DroolsParserException( determineErrorCode( e ), | ||
String.format("Line %d:%d %s", line, charPositionInLine, message), |
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.
The message
produced by the parser is almost identical to the original message. It just needs prepending the line/column information. That allows me to drop the createErrorMessage
and the formatting strings.
if ( state.errorRecovery ) { | ||
return; | ||
} | ||
state.errorRecovery = true; |
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.
Error recovery is handled by the parser's DefaultErrorStrategy
.
@tkobayas @mariofusco, optionally @gitgabrio please review. |
Fixing progress: There were 99 failed tests (inaccurate because |
Add an error listener to the expression parser that collects errors and stores them in the helper.
This slightly increases the number of failing tests but fewer of them are actually visible because the build fails earlier and the module with the most failing tests
drools-model-codegen
is now skipped. The build will return to a "normal" state (before this PR) once we fix #5702, which I'm already working on.How to replicate CI configuration locally?
Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.
build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.
How to retest this PR or trigger a specific build:
for pull request and downstream checks
for a full downstream build
run_fdb
for Jenkins PR check only
Build Now
button.