components/org.wso2.carbon.siddhi.editor.core/src/main/resources/web/js/source-editor/completion-engine.js
/**
             * Handle the standard stream suggestions for aggregation definitions
             * @private
             * @param {string[]} regexResults Array of groups from the regex execution of the aggregation definition
             * @param {string} fullEditorText Complete editor text before the cursor
             */
Handle the standard stream suggestions for aggregation definitions
@private
@param {string[]} regexResults Array of groups from the regex execution of the aggregation definition
@param {string} fullEditorText Complete editor text before the cursor
Handle the standard stream suggestions for aggregation definitions @private @param { string [] } regexResults Array of groups from the regex execution of the aggregation definition @param { string } fullEditorText Complete editor text before the cursor
function handleAggregationDefinitionStandardStreamSuggestions(regexResults, fullEditorText) {
                var aggregationInput = regexResults[4];
                var sourceSuggestionsRegex = new RegExp("(?:^(#\\s*)?[a-zA-Z_0-9]*)$", "i");
                var afterHashSuggestionsRegex = new RegExp(regex.aggregation.input.standardStreamRegex + regex.hash +
                    "[a-zA-Z_0-9]*$", "i");
                var streamProcessorExtensionSuggestionsRegex =
                    new RegExp(regex.aggregation.input.standardStreamRegex + regex.hash +
                        regex.namespace + "[a-zA-Z_0-9]*$", "i");
                var windowSuggestionsRegex = new RegExp(regex.aggregation.input.standardStreamRegex + regex.hash +
                    regex.aggregation.input.windowKeywordAndDot + "[a-zA-Z_0-9]*$", "i");
                var windowExtensionSuggestionsRegex = new RegExp(regex.aggregation.input.standardStreamRegex +
                    regex.hash + regex.aggregation.input.windowKeywordAndDot + regex.namespace +
                    "[a-zA-Z_0-9]*$", "i");
                var windowAndStreamProcessorParameterSuggestionsRegex = new RegExp(
                    regex.aggregation.input.standardStreamRegex + regex.hash +
                    "(?:" + regex.aggregation.input.windowKeywordAndDot + ")?" +
                    "(?:" + regex.namespace + ")?" +
                    regex.identifier + "\\s*\\([^\\)]*$", "i");
                var afterStreamSuggestionsRegex =
                    new RegExp(regex.aggregation.input.standardStreamRegex + "\\s+[^\\[#]*$", "i");
                if (sourceSuggestionsRegex.test(aggregationInput)) {
                    var isInner = sourceSuggestionsRegex.exec(aggregationInput)[1] == "#";
                    if (!isInner) {
                        addCompletions(Object.keys(self.streamsList).map(function (stream) {
                            return {
                                value: stream,
                                type: constants.typeToDisplayNameMap[constants.STREAMS],
                                description: self.streamsList[stream].description,
                                priority: 6
                            }
                        }));
                    }
                } else if (streamProcessorExtensionSuggestionsRegex.test(aggregationInput)) {
                    var namespace = streamProcessorExtensionSuggestionsRegex.exec(aggregationInput)[5].trim();
                    addSnippets(getExtensionStreamProcessors(namespace));
                } else if (windowSuggestionsRegex.test(aggregationInput)) {
                    addSnippets(getInBuiltWindowProcessors());
                    addSnippets(getExtensionNamesSpaces([constants.WINDOW_PROCESSORS])
                        .map(function (windowProcessor) {
                                return Object.assign({}, windowProcessor, {
                                    caption: windowProcessor.value,
                                    value: windowProcessor.value + ":"
                                });
                            }
                        ));
                } else if (windowExtensionSuggestionsRegex.test(aggregationInput)) {
                    addSnippets(getExtensionWindowProcessors(
                        windowExtensionSuggestionsRegex.exec(aggregationInput)[1].trim()
                    ));
                } else if (windowAndStreamProcessorParameterSuggestionsRegex.test(aggregationInput)) {
                    addCompletions(getAttributesFromSourcesWithPrefixedDuplicates(regexResults, fullEditorText, {
                        name: windowAndStreamProcessorParameterSuggestionsRegex.exec(aggregationInput)[1].trim()
                    }, [constants.STREAMS, constants.WINDOWS]));
                } else if (afterStreamSuggestionsRegex.test(aggregationInput)) {
                    var completions = [{value: "#"}];
                    if (/\s+[^\[#]*$/i.test(aggregationInput)) {
                        completions = completions.concat(
                            ["select"]
                                .map(function (completion) {
                                return {value: completion + " "};
                            })
                        );
                    }
                    addCompletions(completions);
                } else if (afterHashSuggestionsRegex.test(aggregationInput)) {
                    addSnippets(getInBuiltStreamProcessors().map(function (suggestion) {
                        return Object.assign({}, suggestion, {
                            priority: 3
                        });
                    }));
                    addCompletions(getExtensionNamesSpaces([constants.STREAM_PROCESSORS]).map(function (completion) {
                        return Object.assign({}, completion, {
                            caption: completion,
                            value: completion + ":",
                            priority: 2
                        });
                    }));
                    if (new RegExp(regex.aggregation.input.sourceRegex +
                            "(?:" + regex.aggregation.input.sourceHandlersRegex + ")*" +
                            regex.hash + "[^\\(\\.:]*$", "i").test(aggregationInput)) {
                        addCompletions({caption: "window", value: "window.", priority: 2});
                    }
                }
            }
function handleAggregationDefinitionStandardStreamSuggestions ( regexResults , fullEditorText ) { var aggregationInput = regexResults [ 4 ] ; var sourceSuggestionsRegex = new RegExp ( "(?:^(#\\s*)?[a-zA-Z_0-9]*)$" , "i" ) ; var afterHashSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + regex . hash + "[a-zA-Z_0-9]*$" , "i" ) ; var streamProcessorExtensionSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + regex . hash + regex . namespace + "[a-zA-Z_0-9]*$" , "i" ) ; var windowSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + regex . hash + regex . aggregation . input . windowKeywordAndDot + "[a-zA-Z_0-9]*$" , "i" ) ; var windowExtensionSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + regex . hash + regex . aggregation . input . windowKeywordAndDot + regex . namespace + "[a-zA-Z_0-9]*$" , "i" ) ; var windowAndStreamProcessorParameterSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + regex . hash + "(?:" + regex . aggregation . input . windowKeywordAndDot + ")?" + "(?:" + regex . namespace + ")?" + regex . identifier + "\\s*\\([^\\)]*$" , "i" ) ; var afterStreamSuggestionsRegex = new RegExp ( regex . aggregation . input . standardStreamRegex + "\\s+[^\\[#]*$" , "i" ) ; if ( sourceSuggestionsRegex . test ( aggregationInput ) ) { var isInner = sourceSuggestionsRegex . exec ( aggregationInput ) [ 1 ] == "#" ; if ( ! isInner ) { addCompletions ( Object . keys ( self . streamsList ) . map ( function ( stream ) { return { value : stream , type : constants . typeToDisplayNameMap [ constants . STREAMS ] , description : self . streamsList [ stream ] . description , priority : 6 } } ) ) ; } } else if ( streamProcessorExtensionSuggestionsRegex . test ( aggregationInput ) ) { var namespace = streamProcessorExtensionSuggestionsRegex . exec ( aggregationInput ) [ 5 ] . trim ( ) ; addSnippets ( getExtensionStreamProcessors ( namespace ) ) ; } else if ( windowSuggestionsRegex . test ( aggregationInput ) ) { addSnippets ( getInBuiltWindowProcessors ( ) ) ; addSnippets ( getExtensionNamesSpaces ( [ constants . WINDOW_PROCESSORS ] ) . map ( function ( windowProcessor ) { return Object . assign ( { } , windowProcessor , { caption : windowProcessor . value , value : windowProcessor . value + ":" } ) ; } ) ) ; } else if ( windowExtensionSuggestionsRegex . test ( aggregationInput ) ) { addSnippets ( getExtensionWindowProcessors ( windowExtensionSuggestionsRegex . exec ( aggregationInput ) [ 1 ] . trim ( ) ) ) ; } else if ( windowAndStreamProcessorParameterSuggestionsRegex . test ( aggregationInput ) ) { addCompletions ( getAttributesFromSourcesWithPrefixedDuplicates ( regexResults , fullEditorText , { name : windowAndStreamProcessorParameterSuggestionsRegex . exec ( aggregationInput ) [ 1 ] . trim ( ) } , [ constants . STREAMS , constants . WINDOWS ] ) ) ; } else if ( afterStreamSuggestionsRegex . test ( aggregationInput ) ) { var completions = [ { value : "#" } ] ; if ( / \s+[^\[#]*$ / i . test ( aggregationInput ) ) { completions = completions . concat ( [ "select" ] . map ( function ( completion ) { return { value : completion + " " } ; } ) ) ; } addCompletions ( completions ) ; } else if ( afterHashSuggestionsRegex . test ( aggregationInput ) ) { addSnippets ( getInBuiltStreamProcessors ( ) . map ( function ( suggestion ) { return Object . assign ( { } , suggestion , { priority : 3 } ) ; } ) ) ; addCompletions ( getExtensionNamesSpaces ( [ constants . STREAM_PROCESSORS ] ) . map ( function ( completion ) { return Object . assign ( { } , completion , { caption : completion , value : completion + ":" , priority : 2 } ) ; } ) ) ; if ( new RegExp ( regex . aggregation . input . sourceRegex + "(?:" + regex . aggregation . input . sourceHandlersRegex + ")*" + regex . hash + "[^\\(\\.:]*$" , "i" ) . test ( aggregationInput ) ) { addCompletions ( { caption : "window" , value : "window." , priority : 2 } ) ; } } }
Handle the standard stream suggestions for aggregation definitions
 @private
 @param {string[]} regexResults Array of groups from the regex execution of the aggregation definition
 @param {string} fullEditorText Complete editor text before the cursor
Handle the standard stream suggestions for aggregation definitions @private @param { string [] } regexResults Array of groups from the regex execution of the aggregation definition @param { string } fullEditorText Complete editor text before the cursor
// Regexps used for identifying the suggestions // Testing to find the relevant suggestion // Adding streams, inner streams ,event tables, event triggers, event windows // Adding stream names if hash is not present: Inner stream and normal streams // stream processor extension suggestions after a namespace and colon // Add inbuilt windows, extension namespaces after hash + window + dot // Add extension namespace names after hash + window + dot + namespace + colon // Add source attributes for parameters for stream processors and windows // Add suggestions after typing a source name // Add stream processors, stream processor extension namespaces as suggestions after source + hash /*
                    addSnippets(getExtensionNamesSpaces([constants.STREAM_PROCESSORS]).map(function (suggestion) {
                        return Object.assign({}, suggestion, {
                            value: suggestion.value + ":",
                            priority: 3
                        });
                    }));
                    */ // Add window keyword suggestion // Only one window can be applied for a stream