Class DataEntryField

java.lang.Object
org.eclipse.lemminx.services.data.DataEntryField

public class DataEntryField extends Object
Data entry field support used to resolve :
  • resolve completion : https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem
  • resolve codeAction : https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeAction
Here a data sample for codeAction used by the resolve code action: { "title": "Generate 'content.dtd' and bind with xml-model", "kind": "quickfix", ... ], "data": { "uri": "file:///.../content.xml", "participantId": "org.eclipse.lemminx.extensions.contentmodel.participants.codeactions.NoGrammarConstraintsCodeAction#xml-model@dtd", "file": "file:///.../content.dtd" } }

The two required data field for any resolve (codeAction, completion, etc) are:

  • "uri" : the URI of the document XML where completion, codeAction, etc must be resolved (when user clicks on this quickfix).
  • "participantId" : the participant ID which must be used to process the resolve of the completion, codeAction, etc.
  • extra fields (in the below sample "file" is the file URI of the grammar file which must be generated).

Author:
Angelo ZERR
  • Field Details

  • Constructor Details

    • DataEntryField

      public DataEntryField()
  • Method Details

    • createData

      public static com.google.gson.JsonObject createData(String uri, String participantId)
      Create a JSON data entry field with the two required information:
      Parameters:
      uri - the URI of the document XML where completion, codeAction, etc must be resolved (when user clicks on this quickfix).
      participantId - the participant ID which must be used to process the resolve of the completion, codeAction, etc.
      Returns:
      the JSON data entry field.
    • getUri

      public static String getUri(Object data)
      Returns the URI of the document XML where completion, codeAction, etc must be resolved (when user clicks on this quickfix) and null otherwise.
      Parameters:
      data - the data entry field comings from the CompletionItem, CodeAction, etc.
      Returns:
      the URI of the document XML where completion, codeAction, etc must be resolved (when user clicks on this quickfix) and null otherwise.
    • getParticipantId

      public static String getParticipantId(Object data)
      Returns the participant ID which must be used to process the resolve of the completion, codeAction, etc and null otherwise.
      Parameters:
      data - the data entry field comings from the CompletionItem, CodeAction, etc.
      Returns:
      the participant ID which must be used to process the resolve of the completion, codeAction, etc and null otherwise.
    • getProperty

      public static String getProperty(Object data, String fieldName)
      Returns the property value of the given fieldName if the given data and null otherwise.
      Parameters:
      data - the data entry field comings from the CompletionItem, CodeAction, etc.
      fieldName - the entry field name (ex : "uri", "participantId").
      Returns:
      the property value of the given fieldName if the given data and null otherwise.
    • getPropertyAsInt

      public static Integer getPropertyAsInt(Object data, String fieldName)
      Returns the value of the field as an integer or null if the field is empty.
      Parameters:
      data - the object to read the field of
      fieldName - the field to read
      Returns:
      the value of the field as an integer or null if the field is empty
      Throws:
      ClassCastException - if the field is not an integer
    • getPropertyAsBoolean

      public static Boolean getPropertyAsBoolean(Object data, String fieldName)
      Returns the value of the field as an boolean or null if the field is empty.
      Parameters:
      data - the object to read the field of
      fieldName - the field to read
      Returns:
      the value of the field as an boolean or null if the field is empty
      Throws:
      ClassCastException - if the field is not an boolean
    • createCompletionData

      public static com.google.gson.JsonObject createCompletionData(ICompletionRequest request, String participantId)
      Returns the minimal data to resolve a completion item.
      Parameters:
      request - the completion request.
      participantId - the participant id to retrieve the resolver.
      Returns:
      the minimal data to resolve a completion item.