Class AbstractElementCompletionItem<S,G>

java.lang.Object
org.eclipse.lsp4j.CompletionItem
org.eclipse.lemminx.services.extensions.completion.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 : <foo) if it exists an orphan end tag (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 // <fo| ==> foo attr=""> // <fo| ==> foo attr=""> // <fo|> ==> foo // <fo|/> ==> foo // <fo| attr="" ==> foo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractElementCompletionItem(String tagName, S sourceElement, G generator, ICompletionRequest request)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected com.google.gson.JsonObject
    addResolveData(ICompletionRequest request, String participantId)
    Update completion item data for resolve support.
    protected abstract org.eclipse.lsp4j.MarkupContent
    Returns the completion item documentation and null otherwise.
    protected abstract String
    generateFullElementContent(boolean generateEndTag)
    Returns the full element content (ex : ).
    protected G
    Returns the generator to generate the full XML element content and null otherwise.
    Returns the completion request.
    protected String
    Returns the resolver participant id.
    protected S
    Returns the source element (ex : a DOM element, a grammar element declaration, etc) used to generate the completion item.
    protected String
    Returns the tag name of the XML element completion item (ex : 'foo', 'x:foo').
    protected static boolean
     
    static boolean
     
    static void
    updateEndTagName(DOMNode node, int offset, ISharedSettingsRequest request, String tagName, org.eclipse.lsp4j.CompletionItem completionItem)
     

    Methods inherited from class org.eclipse.lsp4j.CompletionItem

    equals, getAdditionalTextEdits, getCommand, getCommitCharacters, getData, getDeprecated, getDetail, getDocumentation, getFilterText, getInsertText, getInsertTextFormat, getInsertTextMode, getKind, getLabel, getLabelDetails, getPreselect, getSortText, getTags, getTextEdit, getTextEditText, hashCode, setAdditionalTextEdits, setCommand, setCommitCharacters, setData, setDeprecated, setDetail, setDocumentation, setDocumentation, setDocumentation, setFilterText, setInsertText, setInsertTextFormat, setInsertTextMode, setKind, setLabel, setLabelDetails, setPreselect, setSortText, setTags, setTextEdit, setTextEditText, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractElementCompletionItem

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

    • 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.