Class AbstractTextDocumentService<T>

java.lang.Object
org.eclipse.lemminx.AbstractTextDocumentService<T>
Type Parameters:
T - the model type (e.g., DOMDocument, RNCDocument)
All Implemented Interfaces:
org.eclipse.lsp4j.services.TextDocumentService
Direct Known Subclasses:
RNCTextDocumentService, XMLTextDocumentService

public abstract class AbstractTextDocumentService<T> extends Object implements org.eclipse.lsp4j.services.TextDocumentService
Abstract base class for text document services that handle a specific file type (e.g., XML, RNC).

Provides common infrastructure:

  • Document management via ModelTextDocuments
  • Lifecycle methods (didOpen, didChange, didClose)
  • Default (empty) implementations of all LSP query methods
  • Helper methods for publishing diagnostics and async model computation
  • Field Details

  • Constructor Details

  • Method Details

    • canHandle

      public abstract boolean canHandle(String uri)
      Returns whether this service can handle the document with the given URI.
      Parameters:
      uri - the document URI.
      Returns:
      true if this service handles the file type.
    • didOpen

      public void didOpen(org.eclipse.lsp4j.DidOpenTextDocumentParams params)
      Specified by:
      didOpen in interface org.eclipse.lsp4j.services.TextDocumentService
    • didChange

      public void didChange(org.eclipse.lsp4j.DidChangeTextDocumentParams params)
      Specified by:
      didChange in interface org.eclipse.lsp4j.services.TextDocumentService
    • didClose

      public void didClose(org.eclipse.lsp4j.DidCloseTextDocumentParams params)
      Specified by:
      didClose in interface org.eclipse.lsp4j.services.TextDocumentService
    • didSave

      public void didSave(org.eclipse.lsp4j.DidSaveTextDocumentParams params)
      Specified by:
      didSave in interface org.eclipse.lsp4j.services.TextDocumentService
    • onDidOpen

      protected void onDidOpen(ModelTextDocument<T,SharedSettings> document)
      Called after a document has been opened and registered. Override to trigger validation, notify participants, etc.
    • onDidChange

      protected void onDidChange(ModelTextDocument<T,SharedSettings> document)
      Called after a document has been changed. Override to trigger validation, notify participants, etc.
    • onDidClose

      protected void onDidClose(String uri)
      Called when a document is about to be closed. Override to clean up resources, cancel pending validation, etc.
    • onIndexScanCompleted

      protected void onIndexScanCompleted()
      Called when the workspace index initial scan has completed. Override to re-validate open documents whose diagnostics depend on workspace-wide information (e.g. cross-file reference counts, unused-entry checks, or "missing start" suppression in RNC files).
    • getDocument

      public ModelTextDocument<T,SharedSettings> getDocument(String uri)
    • allDocuments

      public Collection<ModelTextDocument<T,SharedSettings>> allDocuments()
    • documentIsOpen

      public boolean documentIsOpen(String uri)
    • isIncrementalSupport

      public boolean isIncrementalSupport()
    • getSharedSettings

      protected SharedSettings getSharedSettings()
    • publishDiagnostics

      protected void publishDiagnostics(String uri, List<org.eclipse.lsp4j.Diagnostic> diagnostics)
    • computeModelAsync

      public <R> CompletableFuture<R> computeModelAsync(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier, BiFunction<T,org.eclipse.lsp4j.jsonrpc.CancelChecker,R> code)
    • computeModelAsyncCompose

      public <R> CompletableFuture<R> computeModelAsyncCompose(org.eclipse.lsp4j.TextDocumentIdentifier documentIdentifier, BiFunction<T,org.eclipse.lsp4j.jsonrpc.CancelChecker,CompletableFuture<R>> code)
    • updateSettings

      public void updateSettings(Object initSettings)
      Called when the client sends updated settings. Subclasses may override to extract settings specific to their file type.
      Parameters:
      initSettings - the settings object (content under xml).
    • getScopedFields

      protected List<ConfigurationField> getScopedFields()
      Returns the list of configuration fields that can be scoped per folder via workspace/configuration. Subclasses should override to return the appropriate scoped fields for their file type.
      Returns:
      the scoped fields, or null if scoped settings are not supported by this service.
    • setClientConfigurationSupport

      public void setClientConfigurationSupport(Boolean supported)
      Sets whether the client supports workspace/configuration. Called during capability negotiation.
      Parameters:
      supported - true if the client supports configuration pull.
    • clearAllScopedSettings

      public void clearAllScopedSettings()
      Clears all cached scoped settings, forcing a re-pull on next request.
    • getOrPullScopedSettings

      protected CompletableFuture<SharedSettings> getOrPullScopedSettings(String uri)
      Returns scoped settings for the given document URI. If the client supports workspace/configuration and scoped fields are defined, pulls per-folder settings from the client. Otherwise returns the global shared settings.
      Parameters:
      uri - the document URI to scope settings to.
      Returns:
      a future resolving to the (possibly scoped) shared settings.
    • completion

      public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<org.eclipse.lsp4j.CompletionItem>,org.eclipse.lsp4j.CompletionList>> completion(org.eclipse.lsp4j.CompletionParams params)
      Specified by:
      completion in interface org.eclipse.lsp4j.services.TextDocumentService
    • resolveCompletionItem

      public CompletableFuture<org.eclipse.lsp4j.CompletionItem> resolveCompletionItem(org.eclipse.lsp4j.CompletionItem unresolved)
      Specified by:
      resolveCompletionItem in interface org.eclipse.lsp4j.services.TextDocumentService
    • inlineCompletion

      public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<org.eclipse.lsp4j.InlineCompletionItem>,org.eclipse.lsp4j.InlineCompletionList>> inlineCompletion(org.eclipse.lsp4j.InlineCompletionParams params)
      Specified by:
      inlineCompletion in interface org.eclipse.lsp4j.services.TextDocumentService
    • hover

      public CompletableFuture<org.eclipse.lsp4j.Hover> hover(org.eclipse.lsp4j.HoverParams params)
      Specified by:
      hover in interface org.eclipse.lsp4j.services.TextDocumentService
    • documentHighlight

      public CompletableFuture<List<? extends org.eclipse.lsp4j.DocumentHighlight>> documentHighlight(org.eclipse.lsp4j.DocumentHighlightParams params)
      Specified by:
      documentHighlight in interface org.eclipse.lsp4j.services.TextDocumentService
    • documentSymbol

      public CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.SymbolInformation,org.eclipse.lsp4j.DocumentSymbol>>> documentSymbol(org.eclipse.lsp4j.DocumentSymbolParams params)
      Specified by:
      documentSymbol in interface org.eclipse.lsp4j.services.TextDocumentService
    • formatting

      public CompletableFuture<List<? extends org.eclipse.lsp4j.TextEdit>> formatting(org.eclipse.lsp4j.DocumentFormattingParams params)
      Specified by:
      formatting in interface org.eclipse.lsp4j.services.TextDocumentService
    • rangeFormatting

      public CompletableFuture<List<? extends org.eclipse.lsp4j.TextEdit>> rangeFormatting(org.eclipse.lsp4j.DocumentRangeFormattingParams params)
      Specified by:
      rangeFormatting in interface org.eclipse.lsp4j.services.TextDocumentService
    • prepareRename

      public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either3<org.eclipse.lsp4j.Range,org.eclipse.lsp4j.PrepareRenameResult,org.eclipse.lsp4j.PrepareRenameDefaultBehavior>> prepareRename(org.eclipse.lsp4j.PrepareRenameParams params)
      Specified by:
      prepareRename in interface org.eclipse.lsp4j.services.TextDocumentService
    • rename

      public CompletableFuture<org.eclipse.lsp4j.WorkspaceEdit> rename(org.eclipse.lsp4j.RenameParams params)
      Specified by:
      rename in interface org.eclipse.lsp4j.services.TextDocumentService
    • definition

      public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<? extends org.eclipse.lsp4j.Location>,List<? extends org.eclipse.lsp4j.LocationLink>>> definition(org.eclipse.lsp4j.DefinitionParams params)
      Specified by:
      definition in interface org.eclipse.lsp4j.services.TextDocumentService
    • typeDefinition

      public CompletableFuture<org.eclipse.lsp4j.jsonrpc.messages.Either<List<? extends org.eclipse.lsp4j.Location>,List<? extends org.eclipse.lsp4j.LocationLink>>> typeDefinition(org.eclipse.lsp4j.TypeDefinitionParams params)
      Specified by:
      typeDefinition in interface org.eclipse.lsp4j.services.TextDocumentService
    • references

      public CompletableFuture<List<? extends org.eclipse.lsp4j.Location>> references(org.eclipse.lsp4j.ReferenceParams params)
      Specified by:
      references in interface org.eclipse.lsp4j.services.TextDocumentService
    • codeAction

      public CompletableFuture<List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.Command,org.eclipse.lsp4j.CodeAction>>> codeAction(org.eclipse.lsp4j.CodeActionParams params)
      Specified by:
      codeAction in interface org.eclipse.lsp4j.services.TextDocumentService
    • resolveCodeAction

      public CompletableFuture<org.eclipse.lsp4j.CodeAction> resolveCodeAction(org.eclipse.lsp4j.CodeAction unresolved)
      Specified by:
      resolveCodeAction in interface org.eclipse.lsp4j.services.TextDocumentService
    • codeLens

      public CompletableFuture<List<? extends org.eclipse.lsp4j.CodeLens>> codeLens(org.eclipse.lsp4j.CodeLensParams params)
      Specified by:
      codeLens in interface org.eclipse.lsp4j.services.TextDocumentService
    • foldingRange

      public CompletableFuture<List<org.eclipse.lsp4j.FoldingRange>> foldingRange(org.eclipse.lsp4j.FoldingRangeRequestParams params)
      Specified by:
      foldingRange in interface org.eclipse.lsp4j.services.TextDocumentService
    • documentLink

      public CompletableFuture<List<org.eclipse.lsp4j.DocumentLink>> documentLink(org.eclipse.lsp4j.DocumentLinkParams params)
      Specified by:
      documentLink in interface org.eclipse.lsp4j.services.TextDocumentService
    • selectionRange

      public CompletableFuture<List<org.eclipse.lsp4j.SelectionRange>> selectionRange(org.eclipse.lsp4j.SelectionRangeParams params)
      Specified by:
      selectionRange in interface org.eclipse.lsp4j.services.TextDocumentService
    • linkedEditingRange

      public CompletableFuture<org.eclipse.lsp4j.LinkedEditingRanges> linkedEditingRange(org.eclipse.lsp4j.LinkedEditingRangeParams params)
      Specified by:
      linkedEditingRange in interface org.eclipse.lsp4j.services.TextDocumentService
    • documentColor

      public CompletableFuture<List<org.eclipse.lsp4j.ColorInformation>> documentColor(org.eclipse.lsp4j.DocumentColorParams params)
      Specified by:
      documentColor in interface org.eclipse.lsp4j.services.TextDocumentService
    • colorPresentation

      public CompletableFuture<List<org.eclipse.lsp4j.ColorPresentation>> colorPresentation(org.eclipse.lsp4j.ColorPresentationParams params)
      Specified by:
      colorPresentation in interface org.eclipse.lsp4j.services.TextDocumentService
    • semanticTokensFull

      public CompletableFuture<org.eclipse.lsp4j.SemanticTokens> semanticTokensFull(org.eclipse.lsp4j.SemanticTokensParams params)
      Specified by:
      semanticTokensFull in interface org.eclipse.lsp4j.services.TextDocumentService
    • inlayHint

      public CompletableFuture<List<org.eclipse.lsp4j.InlayHint>> inlayHint(org.eclipse.lsp4j.InlayHintParams params)
      Specified by:
      inlayHint in interface org.eclipse.lsp4j.services.TextDocumentService