Skip to content

Commit bb82718

Browse files
authored
Simplify the JctFileManagerImpl class into a separate repository (#287)
This splits up the file manager system into smaller components to reduce complexity of each class. There is now a separate repository mediator class, and module discovery is performed in a utility class in the utils package instead, enabling reuse and easier ability to swap out the existing implementation with new logic in the future, should it be needed. This also makes it easier to stub module detection in tests by using MockedStatic in Mockito
1 parent e92e588 commit bb82718

File tree

8 files changed

+674
-333
lines changed

8 files changed

+674
-333
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/impl/ContainerGroupRepositoryImpl.java

Lines changed: 425 additions & 0 deletions
Large diffs are not rendered by default.

java-compiler-testing/src/main/java/io/github/ascopes/jct/diagnostics/TeeWriter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public final class TeeWriter extends Writer {
5050
// and the delegated output writer at the same time.
5151
private final StringBuilder builder;
5252

53+
/**
54+
* Initialise the writer.
55+
*
56+
* @param writer the underlying writer to "tee" to.
57+
*/
5358
public TeeWriter(@WillCloseWhenClosed Writer writer) {
5459
lock = new Object();
5560
closed = false;

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/JctFileManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public interface JctFileManager extends JavaFileManager {
7575
*
7676
* @param location the location to apply an empty container for.
7777
*/
78-
void ensureEmptyLocationExists(Location location);
78+
void createEmptyLocation(Location location);
7979

8080
/**
8181
* Get the container group for the given package-oriented location.

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerAnnotationProcessorClassPathConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public JctFileManager configure(@WillNotClose JctFileManager fileManager) {
7575
case ENABLED:
7676
LOGGER.trace("Annotation processor discovery is enabled, ensuring empty location exists");
7777

78-
INHERITED_AP_PATHS.values().forEach(fileManager::ensureEmptyLocationExists);
78+
INHERITED_AP_PATHS.values().forEach(fileManager::createEmptyLocation);
7979

8080
return fileManager;
8181

@@ -84,7 +84,7 @@ public JctFileManager configure(@WillNotClose JctFileManager fileManager) {
8484
+ "into the annotation processor path");
8585

8686
INHERITED_AP_PATHS.forEach(fileManager::copyContainers);
87-
INHERITED_AP_PATHS.values().forEach(fileManager::ensureEmptyLocationExists);
87+
INHERITED_AP_PATHS.values().forEach(fileManager::createEmptyLocation);
8888

8989
return fileManager;
9090

0 commit comments

Comments
 (0)