Package org.machanism.machai.gw.reviewer
Class JavaReviewer
java.lang.Object
org.machanism.machai.gw.reviewer.JavaReviewer
- All Implemented Interfaces:
Reviewer
Reviewer implementation for Java source files (.java).
This reviewer reads Java source as UTF-8 and detects the presence of the
@guidance tag in either block (/* ... */)
or line (// ...) comments.
When processing package-info.java, the reviewer emits a package-level prompt fragment that only
includes path context; for other Java files it emits a prompt fragment containing the full file content.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractPackageName(String content) Extracts the declared package name from a Java source snippet.String[]Returns the file extensions supported by this reviewer.Reviews the provided Java file and, if guidance is present, returns a formatted prompt fragment.
-
Constructor Details
-
JavaReviewer
public JavaReviewer()
-
-
Method Details
-
getSupportedFileExtensions
Returns the file extensions supported by this reviewer.- Specified by:
getSupportedFileExtensionsin interfaceReviewer- Returns:
- an array containing
"java"
-
perform
Reviews the provided Java file and, if guidance is present, returns a formatted prompt fragment.- Specified by:
performin interfaceReviewer- Parameters:
projectDir- the project root directory used to compute a project-relative path for contextguidancesFile- the Java file to analyze- Returns:
- a formatted prompt fragment, or
nullwhen the file does not contain guidance - Throws:
IOException- if an error occurs while reading the file
-
extractPackageName
Extracts the declared package name from a Java source snippet.- Parameters:
content- the full text content of a Java source file- Returns:
- the declared package name, or
"<default package>"when no package declaration is present
-