Class ApplySuggestedFixes


  • public final class ApplySuggestedFixes
    extends java.lang.Object
    Class that applies suggested fixes to code or files.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.String>> applyAllSuggestedFixChoicesToCode​(java.lang.Iterable<SuggestedFix> fixChoices, java.util.Map<java.lang.String,​java.lang.String> fileNameToCodeMap)
      Applies all possible options from each SuggestedFixAlternative to the provided code and returns the new code.
      static java.lang.String applyCodeReplacements​(java.util.Collection<CodeReplacement> replacements, java.lang.String code)
      Applies the provided set of code replacements to the code and returns the transformed code.
      static com.google.common.collect.ImmutableMap<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, ignoring alternative fixes.
      static void applySuggestedFixesToFiles​(java.lang.Iterable<SuggestedFix> fixes)
      Applies the provided set of suggested fixes to the files listed in the suggested fixes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • applySuggestedFixesToFiles

        public static void applySuggestedFixesToFiles​(java.lang.Iterable<SuggestedFix> fixes)
                                               throws java.io.IOException
        Applies the provided set of suggested fixes to the files listed in the suggested fixes. The fixes can be provided in any order, but they may not have any overlapping modifications for the same file.
        Throws:
        java.io.IOException
      • applyAllSuggestedFixChoicesToCode

        public static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.String>> applyAllSuggestedFixChoicesToCode​(java.lang.Iterable<SuggestedFix> fixChoices,
                                                                                                                                                                                 java.util.Map<java.lang.String,​java.lang.String> fileNameToCodeMap)
        Applies all possible options from each SuggestedFixAlternative to the provided code and returns the new code. This only makes sense if all the SuggestedFixAlternatives come from the same checker, i.e. they offer the same number of choices and the same index corresponds to similar fixes. The 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.
      • applySuggestedFixesToCode

        public static com.google.common.collect.ImmutableMap<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, ignoring alternative fixes. The 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.
      • applyCodeReplacements

        public static java.lang.String applyCodeReplacements​(java.util.Collection<CodeReplacement> replacements,
                                                             java.lang.String code)
        Applies the provided set of code replacements to the code and returns the transformed code. The code replacements may not have any overlap.