Class AgiContext

java.lang.Object
uno.anahata.asi.intellij.internal.AgiContext

public final class AgiContext extends Object
Bridge between IntelliJ VirtualFile selections and the per-session Anahata ResourceManager, backing the Project-view "AGI Context" node decorator and popup action.

This is the IntelliJ counterpart of the NetBeans FilesContextActionLogic. It adds and removes files (recursing into directories) from a session's context, and reports membership so the decorator can badge in-context files. All session lookups go through the live IntellijAsiContainer.getInstances() registry.

Author:
anahata
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    The actor recorded when files are added to context from the Project view.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Non-instantiable utility holder.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Agi>
    Returns all active sessions across every live tool-window container.
    static int
    add(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
    Adds the selection (directories expanded to their files) to the session's context.
    static boolean
    allInContext(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
    Tests whether every file in the selection (directories expanded to their files) is in the given session's context.
    private static List<Path>
    collect(com.intellij.openapi.vfs.VirtualFile[] files)
    Expands a selection into concrete local file paths, recursing into directories.
    private static void
    collectInto(com.intellij.openapi.vfs.VirtualFile file, List<Path> out)
    Recursively accumulates local files under a node into the target list.
    private static String
    pathKey(com.intellij.openapi.vfs.VirtualFile file)
    Canonical resource key for a local file, matching how registerPaths stores it.
    static int
    remove(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
    Removes the selection (directories expanded to their files) from the session's context.
    static int
    sessionsContaining(com.intellij.openapi.vfs.VirtualFile file)
    Counts how many active sessions currently hold the given file in context.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ACTOR

      private static final String ACTOR
      The actor recorded when files are added to context from the Project view.
      See Also:
  • Constructor Details

    • AgiContext

      private AgiContext()
      Non-instantiable utility holder.
  • Method Details

    • activeSessions

      public static List<Agi> activeSessions()
      Returns all active sessions across every live tool-window container.
      Returns:
      the active sessions.
    • sessionsContaining

      public static int sessionsContaining(com.intellij.openapi.vfs.VirtualFile file)
      Counts how many active sessions currently hold the given file in context.
      Parameters:
      file - the file to test.
      Returns:
      the number of sessions containing the file (0 if none, or if it is a directory).
    • allInContext

      public static boolean allInContext(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
      Tests whether every file in the selection (directories expanded to their files) is in the given session's context.
      Parameters:
      agi - the session.
      files - the selected files/folders.
      Returns:
      true if the selection is non-empty and fully in context.
    • add

      public static int add(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
      Adds the selection (directories expanded to their files) to the session's context.
      Parameters:
      agi - the session.
      files - the selected files/folders.
      Returns:
      the number of files registered.
    • remove

      public static int remove(Agi agi, com.intellij.openapi.vfs.VirtualFile[] files)
      Removes the selection (directories expanded to their files) from the session's context.
      Parameters:
      agi - the session.
      files - the selected files/folders.
      Returns:
      the number of resources unregistered.
    • collect

      private static List<Path> collect(com.intellij.openapi.vfs.VirtualFile[] files)
      Expands a selection into concrete local file paths, recursing into directories.
      Parameters:
      files - the selected files/folders.
      Returns:
      the flattened list of local file paths.
    • collectInto

      private static void collectInto(com.intellij.openapi.vfs.VirtualFile file, List<Path> out)
      Recursively accumulates local files under a node into the target list.
      Parameters:
      file - the file or directory node.
      out - the accumulator.
    • pathKey

      private static String pathKey(com.intellij.openapi.vfs.VirtualFile file)
      Canonical resource key for a local file, matching how registerPaths stores it.
      Parameters:
      file - the file.
      Returns:
      the absolute path string key.