Class TemplateProposalProvider

  • All Implemented Interfaces:
    org.eclipse.xtext.ui.editor.contentassist.ITemplateProposalProvider
    Direct Known Subclasses:
    BslTemplateProposalProvider

    public abstract class TemplateProposalProvider
    extends Object
    implements org.eclipse.xtext.ui.editor.contentassist.ITemplateProposalProvider
    Abstract implementation of proposal provider
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected int comparePrefixes​(String prefix1, String prefix2, String name)
      Compares prefixes to get the most common one for given string
      void createTemplates​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext[] contexts, org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor acceptor)
      Creates templates with given contexts to analyze the best one and to not create many proposal for one template many proposals with different contexts
      void createTemplates​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context, org.eclipse.xtext.ui.editor.contentassist.ITemplateAcceptor acceptor)  
      protected org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext getBestContextForTemplate​(ITemplate template, org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext[] contexts)
      Returns the best context for given template from given contexts, or null if neither of contexts is acceptable
      protected abstract TemplateStorageManager getStorageManager​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context)
      Returns storage manager of templates
      protected abstract ITemplateProcessor getTemplateProcessor()
      Returns template processor to process given templates
      protected boolean hasAcceptablePrefix​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context, ITemplate template)
      Checks if prefix is acceptable in given context for given template
    • Constructor Detail

      • TemplateProposalProvider

        public TemplateProposalProvider()
    • Method Detail

      • createTemplates

        public void createTemplates​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context,
                                    org.eclipse.xtext.ui.editor.contentassist.ITemplateAcceptor acceptor)
        Specified by:
        createTemplates in interface org.eclipse.xtext.ui.editor.contentassist.ITemplateProposalProvider
      • createTemplates

        public void createTemplates​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext[] contexts,
                                    org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor acceptor)
        Creates templates with given contexts to analyze the best one and to not create many proposal for one template many proposals with different contexts
        Parameters:
        contexts - The possible contexts, cannot be null
        acceptor - The acceptor to accept proposals, cannot be null
      • getBestContextForTemplate

        protected org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext getBestContextForTemplate​(ITemplate template,
                                                                                                           org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext[] contexts)
        Returns the best context for given template from given contexts, or null if neither of contexts is acceptable
        Parameters:
        template - The template to find context for, cannot be null
        contexts - The contexts to choose from , cannot be null
        Returns:
        The best context for the given template, can be null if neither of contexts is acceptable
      • hasAcceptablePrefix

        protected boolean hasAcceptablePrefix​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context,
                                              ITemplate template)
        Checks if prefix is acceptable in given context for given template
        Parameters:
        context - The context of invocation, cannot be null
        template - The template to check, cannot be null
        Returns:
      • comparePrefixes

        protected int comparePrefixes​(String prefix1,
                                      String prefix2,
                                      String name)
        Compares prefixes to get the most common one for given string
        Parameters:
        prefix1 - The first prefix, cannot be null
        prefix2 - The second prefix, cannot be null
        name - The string to find the most common prefix for, cannot be null
        Returns:
      • getStorageManager

        protected abstract TemplateStorageManager getStorageManager​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context)
        Returns storage manager of templates
        Parameters:
        context - The provided context, cannot be null
        Returns:
        The instance of template storage manager, cannot be null
      • getTemplateProcessor

        protected abstract ITemplateProcessor getTemplateProcessor()
        Returns template processor to process given templates
        Returns:
        The instance of template processor, cannot be null