Class Hints
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
This is the IntelliJ counterpart of the NetBeans Hints toolkit. Where NetBeans
drives its hints SPI, IntelliJ runs the code-analysis daemon's main passes on demand via
DaemonCodeAnalyzerImpl.runMainPasses(PsiFile, Document, ProgressIndicator) and reports the resulting
HighlightInfos (errors, warnings, weak warnings) with line numbers and messages.
Applying quick-fixes programmatically is deferred — it requires resolving each highlight's
IntentionAction and running it in a write command.
- Author:
- anahata
-
Field Summary
Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
ConstructorsConstructorDescriptionHints()Constructs the Hints toolkit (instantiated reflectively via its public no-arg constructor). -
Method Summary
Modifier and TypeMethodDescriptionApplies a quick-fix to a highlight on a given line of a file.getFileHints(String filePath, String minSeverity) Lists the inspection/annotator highlights for a file at or above a severity threshold.private com.intellij.lang.annotation.HighlightSeverityparseSeverity(String name) Parses a severity name into aHighlightSeverity, defaulting toWARNING.private List<com.intellij.codeInsight.daemon.impl.HighlightInfo> runMainPasses(com.intellij.openapi.project.Project project, com.intellij.psi.PsiFile psiFile, com.intellij.openapi.editor.Document document) Runs the analysis daemon's main passes for a file synchronously and returns its highlights.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, initialize, isEffectivelyProviding, postActivate, rebindMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, error, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, getSystemInstructions, isProviding, populateMessage, setParentProvider, setProviding
-
Constructor Details
-
Hints
public Hints()Constructs the Hints toolkit (instantiated reflectively via its public no-arg constructor).
-
-
Method Details
-
getFileHints
Lists the inspection/annotator highlights for a file at or above a severity threshold.Runs the analysis daemon's main passes synchronously (on this background tool thread, under a progress indicator) so the result reflects the current file state without requiring the file to be open in an editor.
- Parameters:
filePath- the absolute path of the file to analyze.minSeverity- the minimum severity to include:ERROR,WARNING(default),WEAK_WARNING, orINFO.- Returns:
- a Markdown listing of highlights (severity, line, message).
- Throws:
AgiToolException- if the file cannot be resolved.
-
applyHint
Applies a quick-fix to a highlight on a given line of a file.Re-runs the analysis daemon, locates a highlight on the target line whose registered quick-fix matches (by name substring, or the first fix), opens the file at that offset, and invokes the fix's
IntentionActioninside a write command.- Parameters:
filePath- the absolute path of the file.line- the 1-based line number of the highlight to fix.fixName- a case-insensitive substring of the fix name, ornullfor the first fix.- Returns:
- a confirmation naming the applied fix.
- Throws:
AgiToolException- if the file, highlight, or a matching fix cannot be resolved.
-
runMainPasses
private List<com.intellij.codeInsight.daemon.impl.HighlightInfo> runMainPasses(com.intellij.openapi.project.Project project, com.intellij.psi.PsiFile psiFile, com.intellij.openapi.editor.Document document) Runs the analysis daemon's main passes for a file synchronously and returns its highlights. Must be called off the EDT (AI tool threads qualify).- Parameters:
project- the host project.psiFile- the file to analyze.document- the file's document.- Returns:
- the highlights produced by the main passes.
-
parseSeverity
Parses a severity name into aHighlightSeverity, defaulting toWARNING.- Parameters:
name- the severity name (case-insensitive), ornull.- Returns:
- the resolved severity threshold.
-

