components/org.wso2.carbon.siddhi.editor.core/src/main/resources/web/js/source-editor/completion-engine.js
/**
             * Handle the query insert into suggestions for the query
             *
             * @private
             * @param {string[]} regexResults Array of groups from the regex execution of the query
             * @param {string} fullEditorText Complete editor text before the cursor
             */
Handle the query insert into suggestions for the query
@private
@param {string[]} regexResults Array of groups from the regex execution of the query
@param {string} fullEditorText Complete editor text before the cursor
Handle the query insert into suggestions for the query @private @param { string [] } regexResults Array of groups from the regex execution of the query @param { string } fullEditorText Complete editor text before the cursor
function handleQueryInsertIntoSuggestions(regexResults, fullEditorText) {
                var streamOutputClause = regexResults[18];
                var afterHalfTypedKeywordSuggestionsRegex = new RegExp("^[a-zA-Z]*$", "i");
                var afterOutputEventTypesSuggestionRegex = new RegExp(
                    "^(?:" + regex.query.output.eventTypes + ")?" + "events\\s+[a-zA-Z]*$", "i");
                var afterIntoKeywordSuggestionsRegex = new RegExp(
                    "^(?:(?:" + regex.query.output.eventTypes + ")?" + "events\\s+)?into\\s+[a-zA-Z]*$", "i");
                var afterQuerySuggestionsRegex = new RegExp(
                    "^(?:(?:" + regex.query.output.eventTypes + ")?events\\s+)?" +
                    "into\\s+" + regex.identifier + "\\s*(?:;)?\\s+[a-zA-Z]*$", "i");
                var streamFinderRegex = new RegExp(regex.query.input.standardStreamRegex, "ig");
                if (streamOutputClause == "" || afterHalfTypedKeywordSuggestionsRegex.test(streamOutputClause)) {
                    addCompletions(suggestions.outputEventTypes.map(function (completion) {
                        return Object.assign({}, completion, {
                            value: completion.value + " events into "
                        });
                    }));
                    addCompletions(["into"].map(function (completion) {
                        return {value: completion + " "};
                    }));
                } else if (afterOutputEventTypesSuggestionRegex.test(streamOutputClause)) {
                    addCompletions({value: "into "});
                } else if (afterIntoKeywordSuggestionsRegex.test(streamOutputClause)) {
                    var isInner = streamFinderRegex.exec(regexResults.input)[1] == "#";
                    if (!isInner) {
                        addCompletions(Object.keys(self.streamsList).map(function (stream) {
                            return {
                                caption: stream,
                                value: stream + ";",
                                type: constants.typeToDisplayNameMap[constants.STREAMS],
                                description: self.streamsList[stream].description,
                                priority: 6
                            }
                        }));
                    }
                    if (isInsidePartition(regexResults)) {
                        var partitionNumber = getTheCurrentPartitionIndex(fullEditorText);
                        if (self.partitionsList[partitionNumber]) {
                            addCompletions(Object.keys(self.partitionsList[partitionNumber])
                                .map(function (innerStream) {
                                        innerStream = (isInner ? innerStream.substring(1) : innerStream);
                                        return {
                                            caption: innerStream,
                                            value: innerStream + ";",
                                            type: constants.typeToDisplayNameMap[constants.INNER_STREAMS],
                                            description: self.partitionsList[partitionNumber][innerStream].description,
                                            priority: 6
                                        };
                                    }
                                ));
                        }
                    }
                    addCompletions(Object.keys(self.eventTablesList).map(function (table) {
                        return {
                            caption: table,
                            value: table + ";",
                            type: constants.typeToDisplayNameMap[constants.EVENT_TABLES],
                            description: self.eventTablesList[table].description
                        }
                    }));
                    addCompletions(Object.keys(self.eventWindowsList).map(function (window) {
                        return {
                            caption: window,
                            value: window + ";",
                            type: constants.typeToDisplayNameMap[constants.WINDOWS],
                            description: self.eventWindowsList[window].description
                        }
                    }));
                } else if (afterQuerySuggestionsRegex.test(streamOutputClause)) {
                    handleEndOfPartitionCheck(regexResults);
                }
            }
function handleQueryInsertIntoSuggestions ( regexResults , fullEditorText ) { var streamOutputClause = regexResults [ 18 ] ; var afterHalfTypedKeywordSuggestionsRegex = new RegExp ( "^[a-zA-Z]*$" , "i" ) ; var afterOutputEventTypesSuggestionRegex = new RegExp ( "^(?:" + regex . query . output . eventTypes + ")?" + "events\\s+[a-zA-Z]*$" , "i" ) ; var afterIntoKeywordSuggestionsRegex = new RegExp ( "^(?:(?:" + regex . query . output . eventTypes + ")?" + "events\\s+)?into\\s+[a-zA-Z]*$" , "i" ) ; var afterQuerySuggestionsRegex = new RegExp ( "^(?:(?:" + regex . query . output . eventTypes + ")?events\\s+)?" + "into\\s+" + regex . identifier + "\\s*(?:;)?\\s+[a-zA-Z]*$" , "i" ) ; var streamFinderRegex = new RegExp ( regex . query . input . standardStreamRegex , "ig" ) ; if ( streamOutputClause == "" || afterHalfTypedKeywordSuggestionsRegex . test ( streamOutputClause ) ) { addCompletions ( suggestions . outputEventTypes . map ( function ( completion ) { return Object . assign ( { } , completion , { value : completion . value + " events into " } ) ; } ) ) ; addCompletions ( [ "into" ] . map ( function ( completion ) { return { value : completion + " " } ; } ) ) ; } else if ( afterOutputEventTypesSuggestionRegex . test ( streamOutputClause ) ) { addCompletions ( { value : "into " } ) ; } else if ( afterIntoKeywordSuggestionsRegex . test ( streamOutputClause ) ) { var isInner = streamFinderRegex . exec ( regexResults . input ) [ 1 ] == "#" ; if ( ! isInner ) { addCompletions ( Object . keys ( self . streamsList ) . map ( function ( stream ) { return { caption : stream , value : stream + ";" , type : constants . typeToDisplayNameMap [ constants . STREAMS ] , description : self . streamsList [ stream ] . description , priority : 6 } } ) ) ; } if ( isInsidePartition ( regexResults ) ) { var partitionNumber = getTheCurrentPartitionIndex ( fullEditorText ) ; if ( self . partitionsList [ partitionNumber ] ) { addCompletions ( Object . keys ( self . partitionsList [ partitionNumber ] ) . map ( function ( innerStream ) { innerStream = ( isInner ? innerStream . substring ( 1 ) : innerStream ) ; return { caption : innerStream , value : innerStream + ";" , type : constants . typeToDisplayNameMap [ constants . INNER_STREAMS ] , description : self . partitionsList [ partitionNumber ] [ innerStream ] . description , priority : 6 } ; } ) ) ; } } addCompletions ( Object . keys ( self . eventTablesList ) . map ( function ( table ) { return { caption : table , value : table + ";" , type : constants . typeToDisplayNameMap [ constants . EVENT_TABLES ] , description : self . eventTablesList [ table ] . description } } ) ) ; addCompletions ( Object . keys ( self . eventWindowsList ) . map ( function ( window ) { return { caption : window , value : window + ";" , type : constants . typeToDisplayNameMap [ constants . WINDOWS ] , description : self . eventWindowsList [ window ] . description } } ) ) ; } else if ( afterQuerySuggestionsRegex . test ( streamOutputClause ) ) { handleEndOfPartitionCheck ( regexResults ) ; } }
Handle the query insert into suggestions for the query
 @private
 @param {string[]} regexResults Array of groups from the regex execution of the query
 @param {string} fullEditorText Complete editor text before the cursor
Handle the query insert into suggestions for the query @private @param { string [] } regexResults Array of groups from the regex execution of the query @param { string } fullEditorText Complete editor text before the cursor
// Regexps used for identifying the suggestions // Testing to find the relevant suggestion // Add output event types and into keywords // Add into keyword after output event types // Add source suggestions to insert into // Add normal streams and inner streams as suggestions // Adding inner streams if hash is present // Adding inner stream completions relevant to the correct partition // Check if this can be the end of the partition and add "end" keyword suggestion