-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8137eec
commit 0fcbce1
Showing
61 changed files
with
498 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# Welcome to exercism/java-analyzer | ||
|
||
Welcome to the Exercism Java analyzer documentation! 👋 | ||
|
||
!!! note | ||
This documentation is still under construction. | ||
In the meantime, we suggest having a look at the [Javadoc][javadoc]. | ||
|
||
[javadoc]: /java-analyzer/api/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package analyzer; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The {@code Analyzer} interface is used to implement both global and exercise-specific analyzers. | ||
*/ | ||
public interface Analyzer { | ||
void analyze(List<CompilationUnit> compilationUnits, Analysis analysis); | ||
/** | ||
* Analyze the given solution and append analysis results to the given analysis. | ||
* The {@code analyze} method of each analyzer is invoked once for the whole submitted solution. | ||
* | ||
* @param solution The solution that should be analyzed. | ||
* @param analysis The analysis instance used to collect results. | ||
* This instance is shared across all analyzers, and should be used to add comments and tags, | ||
* or set a summary. | ||
*/ | ||
void analyze(Solution solution, Analysis analysis); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package analyzer; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* The main entrypoint to the Java analyzer from the command-line. | ||
* The CLI expects three arguments and is used like this: | ||
* | ||
* <pre> | ||
* java -jar java-analyzer.jar exercise-slug /path/to/input/ /path/to/output/ | ||
* </pre> | ||
*/ | ||
public class AnalyzerCli { | ||
|
||
private static boolean isNotValidDirectory(String p) { | ||
return !p.endsWith("/") || !new File(p).isDirectory(); | ||
} | ||
|
||
public static void main(String... args) throws IOException { | ||
if (args.length < 3) { | ||
System.err.println("Invalid arguments. Usage: java-analyzer <exercise slug> <exercise directory> <output directory>"); | ||
System.exit(-1); | ||
} | ||
|
||
String slug = args[0]; | ||
String inputDirectory = args[1]; | ||
String outputDirectory = args[2]; | ||
|
||
if (isNotValidDirectory(inputDirectory)) { | ||
System.err.println("Invalid input directory. Must be a valid directory and end with a slash."); | ||
System.exit(-1); | ||
} | ||
if (isNotValidDirectory(outputDirectory)) { | ||
System.err.println("Invalid output directory. Must be a valid directory and end with a slash."); | ||
System.exit(-1); | ||
} | ||
|
||
var solution = new SubmittedSolution(slug, Path.of(inputDirectory)); | ||
var analysis = AnalyzerRoot.analyze(solution); | ||
|
||
try (var analysisWriter = new FileWriter(Path.of(outputDirectory, "analysis.json").toFile()); | ||
var tagsWriter = new FileWriter(Path.of(outputDirectory, "tags.json").toFile())) { | ||
var output = new OutputWriter(analysisWriter, tagsWriter); | ||
output.write(analysis); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.