Class AbstractElementCompletionItem<S,​G>

  • Type Parameters:
    S - the source element Java type.
    G - the generator Java type.
    Direct Known Subclasses:
    ContentModelElementCompletionItem, DOMElementCompletionItem

    public abstract class AbstractElementCompletionItem<S,​G>
    extends org.eclipse.lsp4j.CompletionItem
    Abstract class of CompletionItem to report an XML element completion item. This class returns a TextEdit which contains the full element content (ex : ) or only the start tag element (ex : ). When it exists an orphan end tag, an aditional text edit is reported to update this end tag with the start tag of the completion item. // Samples with completion from Text node // fo| ==> // fo| ==> // Samples with completion from element // foo attr=""> // ==> foo attr=""> // ==> foo // ==> foo // foo
    • Constructor Detail

      • AbstractElementCompletionItem

        public AbstractElementCompletionItem​(String tagName,
                                             S sourceElement,
                                             G generator,
                                             ICompletionRequest request)
    • Method Detail

      • getTagName

        protected String getTagName()
        Returns the tag name of the XML element completion item (ex : 'foo', 'x:foo').
        Returns:
        the tag name of the XML element completion item (ex : 'foo', 'x:foo').
      • getSourceElement

        protected S getSourceElement()
        Returns the source element (ex : a DOM element, a grammar element declaration, etc) used to generate the completion item.
        Returns:
        the source element (ex : a DOM element, a grammar element declaration, etc) used to generate the completion item.
      • getGenerator

        protected G getGenerator()
        Returns the generator to generate the full XML element content and null otherwise.
        Returns:
        the generator to generate the full XML element content and null otherwise.
      • getRequest

        protected ICompletionRequest getRequest()
        Returns the completion request.
        Returns:
        the completion request.
      • hasContentAfterTagName

        protected static boolean hasContentAfterTagName​(DOMElement element)
      • isElementClosed

        public static boolean isElementClosed​(DOMElement element)
      • addResolveData

        protected com.google.gson.JsonObject addResolveData​(ICompletionRequest request,
                                                            String participantId)
        Update completion item data for resolve support.
        Parameters:
        request - the completion request.
        participantId - the resolve participant id.
        Returns:
      • generateFullElementContent

        protected abstract String generateFullElementContent​(boolean generateEndTag)
        Returns the full element content (ex : ).
        Parameters:
        generateEndTag - true if the element end tag must be generated and false otherwise.
        Returns:
        the full element content (ex : ).
      • generateDocumentation

        protected abstract org.eclipse.lsp4j.MarkupContent generateDocumentation()
        Returns the completion item documentation and null otherwise.
        Returns:
        the completion item documentation and null otherwise.
      • updateEndTagName

        public static void updateEndTagName​(DOMNode node,
                                            int offset,
                                            ISharedSettingsRequest request,
                                            String tagName,
                                            org.eclipse.lsp4j.CompletionItem completionItem)
      • getResolverParticipantId

        protected String getResolverParticipantId()
        Returns the resolver participant id.
        Returns:
        the resolver participant id.