Interface IWatchedFilesContext

All Superinterfaces:
ICodeLensRefresher

public interface IWatchedFilesContext extends ICodeLensRefresher
Context passed to IWorkspaceServiceParticipant.didChangeWatchedFiles(List, IWatchedFilesContext) so extensions can request deferred client notifications after all participants have processed the current file-change batch.

Design — N-to-1 refresh: Multiple extensions may call ICodeLensRefresher.requestCodeLensRefresh() for the same batch. The workspace service inspects ICodeLensRefresher.isCodeLensRefreshRequested() once after all participants finish and sends exactly one workspace/codeLens/refresh to the client. This mirrors the ISaveContext pattern used for document saves.

Use case — file copied / created: The user copies order.xml (which declares xsi:noNamespaceSchemaLocation="schema.xsd") into the workspace. The file watcher fires a Created event. IWorkspaceServiceParticipant.didChangeWatchedFiles(List, IWatchedFilesContext) is called; WorkspaceIndexPlugin re-indexes the file and calls ICodeLensRefresher.requestCodeLensRefresh() because grammar references were found. After all participants finish, the workspace service sends one workspace/codeLens/refresh, causing the "N references" lens on schema.xsd to update immediately.

Conditional refresh: The refresh is only requested when the indexed file actually contains grammar references (

invalid reference
WorkspaceIndex#indexFile
returns true). Creating a plain XML file with no grammar declarations does not trigger an unnecessary client round-trip.

Use case — diagnostics refresh: After a file is indexed, the "unused" diagnostics on open catalog documents may change (a newly pasted XML file may reference a catalog entry that was previously unused).

invalid reference
WorkspaceIndexPlugin
calls requestDiagnosticsRefresh() so that catalog diagnostics are republished without requiring the user to save or reopen the file.
See Also:
  • Method Details

    • requestDiagnosticsRefresh

      void requestDiagnosticsRefresh()
      Signals that diagnostics should be refreshed for documents affected by the current file-change batch (e.g. open catalog documents whose "unused" warnings may now be stale). The workspace service sends the refresh once after all participants finish, regardless of how many times this method is called.
    • isDiagnosticsRefreshRequested

      boolean isDiagnosticsRefreshRequested()
      Returns true if at least one participant requested a diagnostics refresh.