Skip to content

Commit d3d9e50

Browse files
authored
Merge pull request #83 from rgdoliveira/sync_main
Sync main branch with Apache main branch
2 parents 8d9ea27 + 20d17bd commit d3d9e50

File tree

441 files changed

+27731
-9245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+27731
-9245
lines changed
File renamed without changes.

NOTICE

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ This product also includes the following third-party components:
2121
* search-ui
2222
Downloaded from: https://gitlab.com/antora/antora-lunr-extension
2323
License: Mozilla Public License 2.0
24+
25+
* JavaParser, JavaLexer
26+
Downloaded from: https://github.com/antlr/grammars-v4/tree/master/java/java
27+
License: BSD License

drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderRulesConfigurationImpl.java

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public KnowledgeBuilderRulesConfigurationImpl(CompositeConfiguration<KnowledgeBu
127127
}
128128

129129
private void init() {
130-
131130
setProperty( TrimCellsInDTableOption.PROPERTY_NAME,
132131
getPropertyValue(TrimCellsInDTableOption.PROPERTY_NAME,
133132
"true"));

drools-compiler/src/main/java/org/drools/compiler/lang/DescrDumper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.drools.drl.ast.descr.OperatorDescr;
3535
import org.drools.drl.ast.descr.RelationalExprDescr;
3636
import org.drools.drl.parser.DrlExprParser;
37+
import org.drools.drl.parser.DrlExprParserFactory;
3738
import org.drools.drl.parser.impl.Operator;
3839
import org.kie.internal.builder.conf.LanguageLevelOption;
3940

@@ -137,7 +138,7 @@ public StringBuilder dump( StringBuilder sbuilder,
137138
}
138139

139140
private void processConstraint(StringBuilder sbuilder, ExprConstraintDescr base, boolean isInsideRelCons, DumperContext context) {
140-
DrlExprParser expr = new DrlExprParser( context.getRuleContext().getConfiguration().getOption(LanguageLevelOption.KEY));
141+
DrlExprParser expr = DrlExprParserFactory.getDrlExprParser(context.getRuleContext().getConfiguration().getOption(LanguageLevelOption.KEY));
141142
ConstraintConnectiveDescr result = expr.parse( base.getExpression() );
142143
if ( result.getDescrs().size() == 1 ) {
143144
dump( sbuilder,

drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import org.drools.drl.ast.descr.ReturnValueRestrictionDescr;
100100
import org.drools.drl.ast.descr.RuleDescr;
101101
import org.drools.drl.parser.DrlExprParser;
102+
import org.drools.drl.parser.DrlExprParserFactory;
102103
import org.drools.drl.parser.DroolsParserException;
103104
import org.drools.util.ClassUtils;
104105
import org.drools.util.StringUtils;
@@ -1803,17 +1804,17 @@ protected ConstraintConnectiveDescr parseExpression(final RuleBuildContext conte
18031804
final PatternDescr patternDescr,
18041805
final BaseDescr original,
18051806
final String expression) {
1806-
DrlExprParser parser = new DrlExprParser(context.getConfiguration().getOption(LanguageLevelOption.KEY));
1807+
DrlExprParser parser = DrlExprParserFactory.getDrlExprParser(context.getConfiguration().getOption(LanguageLevelOption.KEY));
18071808
ConstraintConnectiveDescr result = parser.parse(normalizeEval(expression));
1808-
result.setResource(patternDescr.getResource());
1809-
result.copyLocation(original);
18101809
if (parser.hasErrors()) {
18111810
for (DroolsParserException error : parser.getErrors()) {
18121811
registerDescrBuildError(context, patternDescr,
18131812
"Unable to parse pattern expression:\n" + error.getMessage());
18141813
}
18151814
return null;
18161815
}
1816+
result.setResource(patternDescr.getResource());
1817+
result.copyLocation(original);
18171818
return result;
18181819
}
18191820

drools-compiler/src/main/java/org/drools/compiler/rule/builder/QueryElementBuilder.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.drools.drl.ast.descr.ExprConstraintDescr;
4747
import org.drools.drl.ast.descr.PatternDescr;
4848
import org.drools.drl.parser.DrlExprParser;
49+
import org.drools.drl.parser.DrlExprParserFactory;
4950
import org.drools.drl.parser.DroolsParserException;
5051
import org.drools.util.ClassUtils;
5152
import org.drools.util.StringUtils;
@@ -68,7 +69,7 @@ public RuleConditionElement build( RuleBuildContext context,
6869
BaseDescr descr ) {
6970
throw new UnsupportedOperationException();
7071
}
71-
72+
7273
public RuleConditionElement build( RuleBuildContext context,
7374
BaseDescr descr,
7475
Pattern prefixPattern ) {
@@ -264,7 +265,7 @@ private void processBinding( RuleBuildContext context,
264265
} else {
265266
// it must be a literal/expression
266267
// it's an expression and thus an input
267-
DrlExprParser parser = new DrlExprParser( context.getConfiguration().getOption(LanguageLevelOption.KEY));
268+
DrlExprParser parser = DrlExprParserFactory.getDrlExprParser(context.getConfiguration().getOption(LanguageLevelOption.KEY));
268269
ConstraintConnectiveDescr bresult = parser.parse( bind.getExpression() );
269270
if ( parser.hasErrors() ) {
270271
for ( DroolsParserException error : parser.getErrors() ) {
@@ -395,7 +396,7 @@ private static int getPos( String identifier,
395396
private ConstraintConnectiveDescr parseExpression( final RuleBuildContext context,
396397
final PatternDescr patternDescr,
397398
final String expression ) {
398-
DrlExprParser parser = new DrlExprParser( context.getConfiguration().getOption(LanguageLevelOption.KEY));
399+
DrlExprParser parser = DrlExprParserFactory.getDrlExprParser( context.getConfiguration().getOption(LanguageLevelOption.KEY));
399400
ConstraintConnectiveDescr result = parser.parse( expression );
400401
if ( result == null || parser.hasErrors() ) {
401402
for ( DroolsParserException error : parser.getErrors() ) {

drools-drl/drools-drl-ast/src/main/java/org/drools/drl/ast/descr/OperatorDescr.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public String getOperator() {
5555
}
5656

5757
public void setOperator( String operator ) {
58-
this.operator = operator.trim();
58+
this.operator = operator != null ? operator.trim() : null;
5959
}
6060

6161
public boolean isNegated() {
+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
25+
<modelVersion>4.0.0</modelVersion>
26+
<parent>
27+
<groupId>org.drools</groupId>
28+
<artifactId>drools-drl</artifactId>
29+
<version>999-SNAPSHOT</version>
30+
</parent>
31+
32+
<groupId>org.drools</groupId>
33+
<artifactId>drools-drl-parser-tests</artifactId>
34+
35+
<name>Drools :: DRL :: Parser :: Tests</name>
36+
37+
<properties>
38+
<java.module.name>org.drools.drl.parser.tests</java.module.name>
39+
</properties>
40+
41+
<dependencies>
42+
<!-- Tests -->
43+
<dependency>
44+
<groupId>org.assertj</groupId>
45+
<artifactId>assertj-core</artifactId>
46+
<scope>test</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter-api</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-engine</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.junit.jupiter</groupId>
60+
<artifactId>junit-jupiter-params</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>ch.qos.logback</groupId>
65+
<artifactId>logback-classic</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.drools</groupId>
71+
<artifactId>drools-drl-parser</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.drools</groupId>
76+
<artifactId>drools-compiler</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.drools</groupId>
81+
<artifactId>drools-mvel</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
</dependencies>
85+
86+
<profiles>
87+
<profile>
88+
<id>default</id>
89+
<activation>
90+
<activeByDefault>true</activeByDefault>
91+
</activation>
92+
<build>
93+
<plugins>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-surefire-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<!-- override default-test for new parser -->
100+
<id>default-test</id>
101+
<configuration>
102+
<systemPropertyVariables>
103+
<drools.drl.antlr4.parser.enabled>true</drools.drl.antlr4.parser.enabled>
104+
</systemPropertyVariables>
105+
</configuration>
106+
</execution>
107+
<execution>
108+
<id>old-parser-test</id>
109+
<configuration>
110+
<systemPropertyVariables>
111+
<drools.drl.antlr4.parser.enabled>false</drools.drl.antlr4.parser.enabled>
112+
</systemPropertyVariables>
113+
</configuration>
114+
<goals>
115+
<goal>test</goal>
116+
</goals>
117+
</execution>
118+
</executions>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
</profile>
123+
</profiles>
124+
</project>

0 commit comments

Comments
 (0)