Package com.illumon.compilertools
Class ReplicateUtilities
java.lang.Object
com.illumon.compilertools.ReplicateUtilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyFixup(List<String> lines, String region, String searchPattern, Function<Matcher, List<String>> replacer) Take a list of lines; and apply a given fixup expressed as a code region, regular expression, then function from the matcher to the replacement line.findNoLocateRegions(String replicateDest) static voidfixupChunkAttributes(String objectPath) fixupChunkAttributes(List<String> lines) fixupChunkAttributes(List<String> lines, String genericType) globalReplacements(int skip, List<String> lines, String... replacements) globalReplacements(List<String> lines, String... replacements) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and adds extra lines at the top.static PathremoveAnyImports(List<String> lines, String... importRegex) Remove imports if they match any of the patterns.removeImport(List<String> lines, Class... importClasses) removeImport(List<String> lines, String... importRegex) Remove all of the specified imports -- Error if any are not found.removeRegion(List<String> lines, String region) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and removes it.replaceInRegion(String region, List<String> lines, String... replacements) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and replaces the text with the contents of replacement.Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and replaces the text with the contents of replacement.simpleFixup(List<String> lines, String region, String... replacements) Take a list of lines; and apply a given fixup expressed as a code region and replacementsstandardCleanups(List<String> lines) Do whatever miscellaneous cleanups might be appropriate for all replicated classes.
-
Constructor Details
-
ReplicateUtilities
public ReplicateUtilities()
-
-
Method Details
-
locateBasePath
-
applyFixup
@NotNull public static @NotNull List<String> applyFixup(List<String> lines, String region, String searchPattern, Function<Matcher, List<String>> replacer) Take a list of lines; and apply a given fixup expressed as a code region, regular expression, then function from the matcher to the replacement line.- Parameters:
lines- the input linesregion- the name of the region started by "// region <name>" and ended by "// endregion <name>"searchPattern- the pattern to search forreplacer- a function from the search pattern's successful matcher to the new lines to apply as a List.- Returns:
- a new list of lines with the fixup applied
-
simpleFixup
@NotNull public static @NotNull List<String> simpleFixup(List<String> lines, String region, String... replacements) Take a list of lines; and apply a given fixup expressed as a code region and replacements- Parameters:
lines- the input linesregion- the name of the region started by "// region <name>" and ended by "// endregion <name>"replacements- an array with an even number of elements, even elements are a thing to replace, the next element is the thing to replace it with- Returns:
- a new list of lines with the fixup applied
-
standardCleanups
Do whatever miscellaneous cleanups might be appropriate for all replicated classes. For now, this removes identical import lines. -
insertRegion
@NotNull public static @NotNull List<String> insertRegion(List<String> lines, String region, List<String> extraLines) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and adds extra lines at the top.- Parameters:
lines- the lines to processregion- the name of the regionextraLines- the lines to insert- Returns:
- a new list of lines
-
removeRegion
Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and removes it.- Parameters:
lines- the lines to processregion- the name of the region- Returns:
- a new list of lines
-
replaceRegion
@NotNull public static @NotNull List<String> replaceRegion(List<String> lines, String region, List<String> replacement) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and replaces the text with the contents of replacement.- Parameters:
lines- the lines to processregion- the name of the regionreplacement- the lines to insert- Returns:
- a new list of lines
-
replaceRegion
@NotNull public static @NotNull List<String> replaceRegion(List<String> lines, String region, Function<List<String>, List<String>> replacement) Locates the region demarked by "// region <name>" and ended by "// endregion <name>" and replaces the text with the contents of replacement.- Parameters:
lines- the lines to processregion- the name of the regionreplacement- the lines to insert- Returns:
- a new list of lines
-
globalReplacements
-
globalReplacements
-
replaceInRegion
-
addImport
-
removeImport
-
addImport
-
removeImport
Remove all of the specified imports -- Error if any are not found. -
removeAnyImports
Remove imports if they match any of the patterns. -
fixupChunkAttributes
-
fixupChunkAttributes
-
fixupChunkAttributes
- Throws:
IOException
-
indent
-
findNoLocateRegions
- Throws:
IOException
-