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

[new-parser] Parsing fails if a Java keyword appears in a qualified name #5818

Closed
yurloc opened this issue Apr 2, 2024 · 4 comments
Closed
Assignees

Comments

@yurloc
Copy link
Contributor

yurloc commented Apr 2, 2024

Parent issue

Failing tests

  • org.kie.declarativetypes.JavaBeansEventRoleTest#testImportBean
  • org.drools.mvel.integrationtests.ExtendsTest#testDeclareExtendsWithFullyQualifiedName

Description

Rule code snippet

package some.other.package;
import org.drools.compiler.Bean;
declare Bean
  @role(event)
end

Error output

Updated:

### parse : ANTLR4_PARSER_ENABLED = true
line 1:18 mismatched input '.' expecting {<EOF>, 'unit', 'function', 'global', 'declare', 'rule', 'query', 'salience', 'enabled', 'no-loop', 'auto-focus', 'lock-on-active', 'refract', 'direct', 'agenda-group', 'activation-group', 'ruleflow-group', 'date-effective', 'date-expires', 'dialect', 'calendars', 'timer', 'duration', 'import'}
14:07:57.000 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:defaultKieBase
[1,18]: mismatched input '.' expecting {<EOF>, 'unit', 'function', 'global', 'declare', 'rule', 'query', 'salience', 'enabled', 'no-loop', 'auto-focus', 'lock-on-active', 'refract', 'direct', 'agenda-group', 'activation-group', 'ruleflow-group', 'date-effective', 'date-expires', 'dialect', 'calendars', 'timer', 'duration', 'import'}
[0,0]: Parser returned a null Package


org.kie.api.builder.CompilationErrorsException: Unable to create KieModule, Errors Existed: [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=bean1.drl, line=1, column=0
   text=mismatched input '.' expecting {<EOF>, 'unit', 'function', 'global', 'declare', 'rule', 'query', 'salience', 'enabled', 'no-loop', 'auto-focus', 'lock-on-active', 'refract', 'direct', 'agenda-group', 'activation-group', 'ruleflow-group', 'date-effective', 'date-expires', 'dialect', 'calendars', 'timer', 'duration', 'import'}], Message [id=2, kieBase=defaultKieBase, level=ERROR, path=bean1.drl, line=0, column=0
   text=Parser returned a null Package]]

	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:526)
	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:532)
	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:507)
	at org.kie.declarativetypes.JavaBeansEventRoleTest.testImportBean(JavaBeansEventRoleTest.java:108)

Originally when this issue was reported:

00:14:32.657 [main] WARN  o.d.c.k.builder.impl.KieBuilderImpl.packageNameForFile:396 - File 'bean1.drl' is in folder '' but declares package 'some.other.package'. It is advised to have a correspondance between package and folder names.
### parse : ANTLR4_PARSER_ENABLED = true

org.junit.ComparisonFailure: 
Expecting value to be true but was false 
Expected :true
Actual   :false
<Click to see difference>


	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at org.kie.declarativetypes.JavaBeansEventRoleTest.testImportBean(JavaBeansEventRoleTest.java:115)
@yurloc yurloc changed the title [new-paser] Parsing fails if package appears in a qualified name [new-parser] Parsing fails if package appears in a qualified name Apr 3, 2024
@yurloc yurloc changed the title [new-parser] Parsing fails if package appears in a qualified name [new-parser] Parsing fails if a Java keyword appears in a qualified name May 13, 2024
@tkobayas
Copy link
Contributor

@yurloc As we discussed in #5819 , we would go for the direction "Add Java keywords to drlIdentifier " for backward compatibility (= focus on passing existing tests).

After the phase, we would re-consider such issues like dropping useless syntax / ambiguity. Feel free to share if you have any concern. Thanks!

@tkobayas
Copy link
Contributor

/take

@yurloc
Copy link
Contributor Author

yurloc commented May 17, 2024

Feel free to share if you have any concern. Thanks!

No concerns. I think this is the best solution for the time being.

  • It's 100% backward compatible.
  • It fixes the problem. Once we have a green test suite, we can look for an alternative solution.

@yurloc
Copy link
Contributor Author

yurloc commented May 21, 2024

Fixed by #5958.

@yurloc yurloc closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎯 Done
Development

No branches or pull requests

2 participants