@NotNull
    private ICompletionProposal[] makeTemplateProposals(ITextViewer viewer, SQLCompletionRequest request) {
        String wordPart = request.getWordPart().toLowerCase();
        final List<SQLTemplateCompletionProposal> templateProposals = new ArrayList<>();
        // Templates
        for (Template template : editor.getTemplatesPage().getTemplateStore().getTemplates()) {
            if (template.getName().toLowerCase().startsWith(wordPart)
                && SQLEditorUtils.isTemplateContextFitsEditorContext(template.getContextTypeId(), editor)
            ) { 
                SQLContext templateContext = new SQLContext(
                    SQLTemplatesRegistry.getInstance().getTemplateContextRegistry().getContextType(template.getContextTypeId()),
                    viewer.getDocument(),
                    new Position(request.getWordDetector().getStartOffset(), request.getWordDetector().getLength()),
                    editor);
                ISelection selection = viewer.getSelectionProvider().getSelection();
                if (selection instanceof TextSelection) {
                    templateContext.setVariable(GlobalTemplateVariables.SELECTION, ((TextSelection) selection).getText());
                }
                templateProposals.add(new SQLTemplateCompletionProposal(
                    template,
                    templateContext,
                    new Region(request.getDocumentOffset(), 0),
                    null));
            }
        }
        templateProposals.sort(Comparator.comparing(TemplateProposal::getDisplayString));
        return templateProposals.toArray(new ICompletionProposal[0]);
    }
The SQL content assist processor. This content assist processor proposes text
completions and computes context information for a SQL content type.
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLCompletionProcessor.java