Class DerivedSourceSearchParticipantRegistry

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.search.indexing.DerivedSourceSearchParticipantRegistry
All Implemented Interfaces:
EventListener, org.eclipse.core.runtime.IRegistryEventListener

public class DerivedSourceSearchParticipantRegistry extends Object implements org.eclipse.core.runtime.IRegistryEventListener
Registry for search participants contributed via the org.eclipse.jdt.core.derivedSourceSearchParticipant extension point.

Each contributed participant declares a set of file extensions it handles. The registry maps file extensions to eagerly-instantiated participant instances.

The registry listens for extension additions and removals via IRegistryEventListener, so dynamically loaded or unloaded bundles are reflected automatically without restart.

  • Method Details

    • dispose

      public void dispose()
      Disposes this registry by removing its extension registry listener.

      This should be called during JavaCore/JavaModelManager shutdown to avoid the extension registry retaining references to this classloader after the org.eclipse.jdt.core bundle is stopped or updated.

    • disposeInstance

      public static void disposeInstance()
      Disposes the singleton instance of this registry.

      Intended to be invoked from JavaCore/JavaModelManager shutdown.

    • getParticipant

      public static DerivedSourceSearchParticipant getParticipant(String fileExtension)
      Returns the search participant registered for the given file extension, or null if none.
      Parameters:
      fileExtension - file extension without dot, e.g. "kt"
      Returns:
      the search participant, or null
    • getContributedParticipants

      public static DerivedSourceSearchParticipant[] getContributedParticipants()
      Returns all contributed search participants. Does not include the default Java search participant.
      Returns:
      array of contributed participants (may be empty, never null)
    • getLanguageId

      public static String getLanguageId(String fileExtension)
      Returns the LSP language identifier for the given file extension, or null if no search participant is registered for it.

      If the participant's extension point registration includes a languageId attribute, that value is returned. Otherwise, the file extension itself is used as the language identifier.

      Parameters:
      fileExtension - file extension without dot, e.g. "kt"
      Returns:
      the language identifier (e.g. "kotlin"), or null
    • hasParticipant

      public static boolean hasParticipant(String fileExtension)
      Returns whether the given file extension has a registered search participant.
      Parameters:
      fileExtension - file extension without dot
      Returns:
      true if a participant is registered for this extension
    • reset

      public static void reset()
      Resets the registry, forcing a fresh reload from the extension registry. Intended for testing only.
    • getFileExtension

      public static String getFileExtension(String fileName)
      Returns the file extension from a file name, or null if none.
      Parameters:
      fileName - the file name (e.g. "Foo.kt")
      Returns:
      the extension without dot (e.g. "kt"), or null
    • added

      public void added(org.eclipse.core.runtime.IExtension[] extensions)
      Specified by:
      added in interface org.eclipse.core.runtime.IRegistryEventListener
    • removed

      public void removed(org.eclipse.core.runtime.IExtension[] extensions)
      Specified by:
      removed in interface org.eclipse.core.runtime.IRegistryEventListener
    • added

      public void added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)
      Specified by:
      added in interface org.eclipse.core.runtime.IRegistryEventListener
    • removed

      public void removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)
      Specified by:
      removed in interface org.eclipse.core.runtime.IRegistryEventListener