public final class ApplySuggestedFixes
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static com.google.common.collect.Ordering<CodeReplacement> |
ORDER_CODE_REPLACEMENTS |
Constructor and Description |
---|
ApplySuggestedFixes() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
applyCodeReplacements(java.lang.Iterable<CodeReplacement> replacements,
java.lang.String code)
Applies the provided set of code replacements to the code and returns the transformed code.
|
static java.util.Map<java.lang.String,java.lang.String> |
applySuggestedFixesToCode(java.lang.Iterable<SuggestedFix> fixes,
java.util.Map<java.lang.String,java.lang.String> filenameToCodeMap)
Applies the provided set of suggested fixes to the provided code and returns the new code.
|
static void |
applySuggestedFixesToFiles(java.lang.Iterable<SuggestedFix> fixes)
Applies the provided set of suggested fixes to the files listed in the suggested fixes.
|
private static void |
validateNoOverlaps(java.util.List<CodeReplacement> replacements)
Validates that none of the CodeReplacements have any overlap, since applying
changes that have overlap will produce malformed results.
|
private static final com.google.common.collect.Ordering<CodeReplacement> ORDER_CODE_REPLACEMENTS
public static void applySuggestedFixesToFiles(java.lang.Iterable<SuggestedFix> fixes) throws java.io.IOException
java.io.IOException
public static java.util.Map<java.lang.String,java.lang.String> applySuggestedFixesToCode(java.lang.Iterable<SuggestedFix> fixes, java.util.Map<java.lang.String,java.lang.String> filenameToCodeMap)
filenameToCodeMap
must contain all the files that the provided fixes apply to.
The fixes can be provided in any order, but they may not have any overlapping modifications
for the same file.
This function will return new code only for the files that have been modified.public static java.lang.String applyCodeReplacements(java.lang.Iterable<CodeReplacement> replacements, java.lang.String code)
private static void validateNoOverlaps(java.util.List<CodeReplacement> replacements)