components/org.wso2.carbon.siddhi.editor.core/src/main/resources/web/js/source-editor/completion-engine.js
/**
             * Handle the query output to table suggestions for the query
             * Handles update or insert into, delete and update
             *
             * @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 output to table suggestions for the query
Handles update or insert into, delete and update

@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 output to table suggestions for the query Handles update or insert into delete and update @private @param { string [] } regexResults Array of groups from the regex execution of the query @param { string } fullEditorText Complete editor text before the cursor
function handleQueryUpdateOrInsertIntoDeleteUpdateSuggestions(regexResults, fullEditorText) {
                var tableOutputClause = regexResults[18];
                var afterHalfTypedKeywordSuggestionsRegex = new RegExp("^[a-zA-Z]*$", "i");
                var eventTypeSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+[a-zA-Z]*$", "i");
                var afterForKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "for\\s+[a-zA-Z]*$", "i");
                var eventsKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "for\\s+" + regex.query.output.eventTypes + "[a-zA-Z]*$", "i");
                var setKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "(?:for\\s+(?:" + regex.query.output.eventTypes + ")?events\\s+)?[a-zA-Z]*$", "i");
                var afterSetKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "(?:for\\s+(?:" + regex.query.output.eventTypes + ")?events\\s+)?" +
                    "set((?:.(?!on))*)?[a-zA-Z]*$", "i");
                var onKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "(?:for\\s+(?:" + regex.query.output.eventTypes + ")?events\\s+)?" +
                    "(?:set\\s+(?:.(?!on))*?\\s+)?[a-zA-Z]*$", "i");
                var afterOnKeywordSuggestionsRegex = new RegExp("^" + regex.identifier + "\\s+" +
                    "(?:for\\s+(?:" + regex.query.output.eventTypes + ")?events\\s+)?" +
                    "(?:set\\s+(?:.(?!on))*?\\s+)?" +
                    "on\\s+(?!;)(?:.(?!;))*$", "i");
                if (tableOutputClause == "" || afterHalfTypedKeywordSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions(Object.keys(self.eventTablesList).map(function (table) {
                        return {
                            value: table + " ",
                            type: constants.typeToDisplayNameMap[constants.EVENT_TABLES],
                            description: self.eventTablesList[table].description
                        }
                    }));
                } else if (eventTypeSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions(suggestions.outputEventTypes.map(function (completion) {
                        return Object.assign({}, completion, {
                            value: "for " + completion.value + " events "
                        });
                    }));
                } else if (afterForKeywordSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions(suggestions.outputEventTypes.map(function (completion) {
                        return Object.assign({}, completion, {
                            value: completion.value + " events "
                        });
                    }));
                } else if (eventsKeywordSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions({value: "events "});
                } else if (afterOnKeywordSuggestionsRegex.test(tableOutputClause)
                            || afterSetKeywordSuggestionsRegex.test(tableOutputClause)) {
                    var sourceReferenceSearchRegex = new RegExp("^" + regex.identifier, "ig");
                    var referenceToSourceMap = [];
                    var sourceReferenceMatch;
                    while (sourceReferenceMatch = sourceReferenceSearchRegex.exec(tableOutputClause)) {
                        if (getSource(regexResults, fullEditorText, sourceReferenceMatch[0],
                                [constants.EVENT_TABLES])) {
                            referenceToSourceMap[sourceReferenceMatch[0]] = sourceReferenceMatch[0];
                        }
                    }
                    addAttributesOfSourceReferencesAsCompletions(
                        regexResults, fullEditorText, referenceToSourceMap, 3, 2, [constants.EVENT_TABLES]
                    );
                    addCompletions(suggestions.logicalOperatorList.map(function (suggestion) {
                        return Object.assign({}, suggestion, {
                            priority: 2
                        });
                    }));
                    if (afterOnKeywordSuggestionsRegex.test(tableOutputClause)) {
                        handleEndOfPartitionCheck(regexResults);
                    }
                }
                if (setKeywordSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions({value: "set "});
                }
                if (onKeywordSuggestionsRegex.test(tableOutputClause)) {
                    addCompletions({value: "on "});
                }
            }
function handleQueryUpdateOrInsertIntoDeleteUpdateSuggestions ( regexResults , fullEditorText ) { var tableOutputClause = regexResults [ 18 ] ; var afterHalfTypedKeywordSuggestionsRegex = new RegExp ( "^[a-zA-Z]*$" , "i" ) ; var eventTypeSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+[a-zA-Z]*$" , "i" ) ; var afterForKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "for\\s+[a-zA-Z]*$" , "i" ) ; var eventsKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "for\\s+" + regex . query . output . eventTypes + "[a-zA-Z]*$" , "i" ) ; var setKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "(?:for\\s+(?:" + regex . query . output . eventTypes + ")?events\\s+)?[a-zA-Z]*$" , "i" ) ; var afterSetKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "(?:for\\s+(?:" + regex . query . output . eventTypes + ")?events\\s+)?" + "set((?:.(?!on))*)?[a-zA-Z]*$" , "i" ) ; var onKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "(?:for\\s+(?:" + regex . query . output . eventTypes + ")?events\\s+)?" + "(?:set\\s+(?:.(?!on))*?\\s+)?[a-zA-Z]*$" , "i" ) ; var afterOnKeywordSuggestionsRegex = new RegExp ( "^" + regex . identifier + "\\s+" + "(?:for\\s+(?:" + regex . query . output . eventTypes + ")?events\\s+)?" + "(?:set\\s+(?:.(?!on))*?\\s+)?" + "on\\s+(?!;)(?:.(?!;))*$" , "i" ) ; if ( tableOutputClause == "" || afterHalfTypedKeywordSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( Object . keys ( self . eventTablesList ) . map ( function ( table ) { return { value : table + " " , type : constants . typeToDisplayNameMap [ constants . EVENT_TABLES ] , description : self . eventTablesList [ table ] . description } } ) ) ; } else if ( eventTypeSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( suggestions . outputEventTypes . map ( function ( completion ) { return Object . assign ( { } , completion , { value : "for " + completion . value + " events " } ) ; } ) ) ; } else if ( afterForKeywordSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( suggestions . outputEventTypes . map ( function ( completion ) { return Object . assign ( { } , completion , { value : completion . value + " events " } ) ; } ) ) ; } else if ( eventsKeywordSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( { value : "events " } ) ; } else if ( afterOnKeywordSuggestionsRegex . test ( tableOutputClause ) || afterSetKeywordSuggestionsRegex . test ( tableOutputClause ) ) { var sourceReferenceSearchRegex = new RegExp ( "^" + regex . identifier , "ig" ) ; var referenceToSourceMap = [ ] ; var sourceReferenceMatch ; while ( sourceReferenceMatch = sourceReferenceSearchRegex . exec ( tableOutputClause ) ) { if ( getSource ( regexResults , fullEditorText , sourceReferenceMatch [ 0 ] , [ constants . EVENT_TABLES ] ) ) { referenceToSourceMap [ sourceReferenceMatch [ 0 ] ] = sourceReferenceMatch [ 0 ] ; } } addAttributesOfSourceReferencesAsCompletions ( regexResults , fullEditorText , referenceToSourceMap , 3 , 2 , [ constants . EVENT_TABLES ] ) ; addCompletions ( suggestions . logicalOperatorList . map ( function ( suggestion ) { return Object . assign ( { } , suggestion , { priority : 2 } ) ; } ) ) ; if ( afterOnKeywordSuggestionsRegex . test ( tableOutputClause ) ) { handleEndOfPartitionCheck ( regexResults ) ; } } if ( setKeywordSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( { value : "set " } ) ; } if ( onKeywordSuggestionsRegex . test ( tableOutputClause ) ) { addCompletions ( { value : "on " } ) ; } }
Handle the query output to table suggestions for the query
 Handles update or insert into, delete and update
Handle the query output to table suggestions for the query Handles update or insert into delete and update
// Regexps used for identifying the suggestions // Testing to find the relevant suggestion // Add table names as suggestions // Add output event type suggestions after the table name // Add output event type suggestions after the for keyword // Add the events keyword suggestion after the event type // Add suggestions after the on keyword for specifying the rows to update in tables // Getting the reference to source map // Check if this can be the end of the partition and add "end" keyword suggestion // Add on and set keyword suggestions // Add on keyword suggestion