Class ProjectFilesContextProvider
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe absolute path to the project directory.private final ProjectsThe parent Projects toolkit.Fields inherited from class BasicContextProvider
children, parentFields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionProjectFilesContextProvider(Projects projectsToolkit, String projectPath) Constructs a new files provider for a specific project. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringformatProjectFile(ProjectFile file, String indent) Formats a project file into a Markdown list item.private StringformatSourceFolder(SourceFolder folder, String indent, String basePath, String relPath) Recursively formats a source folder and its contents into a Markdown tree.private StringgenerateMarkdown(ProjectFiles files) Generates a Markdown string representing the project file tree.voidpopulateMessage(RagMessage ragMessage) Injects the project's file tree into the RAG message.voidsetProviding(boolean enabled) Toggles providing status and triggers a UI refresh.Methods inherited from class BasicContextProvider
getAgi, getChildrenProviders, getParentProvider, setParentProviderMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getContextPosition, getDescription, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getId, getInstructionsTokenCount, getName, getRagTokenCount, getSystemInstructions, isEffectivelyProviding, isProvidingMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
projectsToolkit
The parent Projects toolkit. -
projectPath
The absolute path to the project directory.
-
-
Constructor Details
-
ProjectFilesContextProvider
-
-
Method Details
-
populateMessage
Injects the project's file tree into the RAG message.Implementation details: Fetches the current file structural data from the Projects toolkit and generates a Markdown tree. It distinguishes between root files and source-group folders for clarity.
- Parameters:
ragMessage- The target RAG message.- Throws:
Exception- if project files cannot be retrieved.
-
setProviding
public void setProviding(boolean enabled) Toggles providing status and triggers a UI refresh.Implementation details: Notifies the IDE that the project icon should be redrawn to reflect the new context state.
- Parameters:
enabled- New state.
-
generateMarkdown
Generates a Markdown string representing the project file tree.Implementation details: This method splits the output into the Root Directory (flat list) and Source Folders (hierarchical tree). It resolves the relative path for each top-level source folder to provide context for the AI.
- Parameters:
files- The project files data.- Returns:
- A Markdown-formatted string.
-
formatSourceFolder
private String formatSourceFolder(SourceFolder folder, String indent, String basePath, String relPath) Recursively formats a source folder and its contents into a Markdown tree.Implementation details: Displays the folder name (or display name) followed by an optional relative path in parentheses for top-level groups.
- Parameters:
folder- The source folder to format.indent- The current indentation level.basePath- The base path of the project.relPath- Optional relative path for display next to the folder.- Returns:
- A Markdown-formatted string for the folder.
-
formatProjectFile
Formats a project file into a Markdown list item.Implementation details: Includes the file name and any IDE-level annotations (e.g., Git status flags) extracted from the annotated name.
- Parameters:
file- The project file to format.indent- The current indentation string.- Returns:
- A Markdown-formatted string for the file.
-

