use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode5.
@Test
public void testIncompleteCode5() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode13.
@Test
public void testIncompleteCode13() throws DroolsParserException, RecognitionException {
String input = "package com.sample " + "import com.sample.DroolsTest.Message; " + "rule \"Hello World\"" + " when " + " then" + " \\\" " + "end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode2.
@Test
public void testIncompleteCode2() throws DroolsParserException, RecognitionException {
String input = "rule MyRule when Class ( property memberOf collection ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorSentences().get(0).getContent()));
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode8.
@Test
public void testIncompleteCode8() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.1111.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
System.out.println(parser.getErrors());
assertEquals("a.b.c", descr.getNamespace());
// FIXME: assertEquals(2, descr.getRules().size());
assertEquals(true, parser.hasErrors());
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method generatedResourcesToPackageDescr.
private List<PackageDescr> generatedResourcesToPackageDescr(Resource resource, List<PMMLResource> resources) throws DroolsParserException {
List<PackageDescr> pkgDescrs = new ArrayList<>();
DrlParser parser = new DrlParser(configuration.getLanguageLevel());
for (PMMLResource res : resources) {
for (String key : res.getRules().keySet()) {
String src = res.getRules().get(key);
PackageDescr descr = null;
descr = parser.parse(false, src);
if (descr != null) {
descr.setResource(resource);
pkgDescrs.add(descr);
dumpGeneratedRule(descr, key, src);
} else {
addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
}
}
}
return pkgDescrs;
}
Aggregations