/** * This will load up a DSL from the reader specified. * This will make the expander available to any parser * regardless of name. * * The DSL expander will be the default expander. * * This is the constructor most people should use. */ public DefaultExpanderResolver(final Reader reader) throws IOException { final DSLTokenizedMappingFile file = new DSLTokenizedMappingFile(); if ( file.parseAndLoad( reader ) ) { final Expander expander = new DefaultExpander(); expander.addDSLMapping( file.getMapping() ); this.expanders.put( "*", expander ); } else { throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() ); } }
@Test public void testTestAnyEnum() throws Exception { SuggestionCompletionLoader suggestionCompletionLoader = new SuggestionCompletionLoader(); ArrayList<DSLTokenizedMappingFile> dsls = new ArrayList<DSLTokenizedMappingFile>(); DSLTokenizedMappingFile dslTokenizedMappingFile = new DSLTokenizedMappingFile(); DSLMappingEntry dslMappingEntry = mock( DSLMappingEntry.class ); when( dslMappingEntry.getSection() ).thenReturn( DSLMappingEntry.ANY ); dslTokenizedMappingFile.getMapping().addEntry( dslMappingEntry ); dsls.add( dslTokenizedMappingFile ); SuggestionCompletionEngine suggestionEngine = suggestionCompletionLoader.getSuggestionEngine( "", Collections.<JarInputStream> emptyList(), dsls ); assertEquals( 1, suggestionEngine.actionDSLSentences.length ); assertEquals( 1, suggestionEngine.conditionDSLSentences.length ); assertEquals( 0, suggestionEngine.keywordDSLItems.length ); }
private void populateDSLSentences(final List<DSLTokenizedMappingFile> dsls) { for ( DSLTokenizedMappingFile file : dsls ) { for ( DSLMappingEntry entry : file.getMapping().getEntries() ) { if ( entry.getSection() == DSLMappingEntry.CONDITION ) { builder.addDSLConditionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) { builder.addDSLActionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.KEYWORD ) { builder.addDSLMapping( entry ); } else if ( entry.getSection() == DSLMappingEntry.ANY ) { builder.addDSLConditionSentence( entry.getMappingKey() ); builder.addDSLActionSentence( entry.getMappingKey() ); } } } }
private void populateDSLSentences(final List<DSLTokenizedMappingFile> dsls) { for ( DSLTokenizedMappingFile file : dsls ) { for ( DSLMappingEntry entry : file.getMapping().getEntries() ) { if ( entry.getSection() == DSLMappingEntry.CONDITION ) { builder.addDSLConditionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) { builder.addDSLActionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.KEYWORD ) { builder.addDSLMapping( entry ); } else if ( entry.getSection() == DSLMappingEntry.ANY ) { builder.addDSLConditionSentence( entry.getMappingKey() ); builder.addDSLActionSentence( entry.getMappingKey() ); } } } }