Class ApplySuggestedFixes

java.lang.Object
com.google.javascript.refactoring.ApplySuggestedFixes

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

    • applySuggestedFixesToFiles

      public static void applySuggestedFixesToFiles(Iterable<SuggestedFix> fixes) throws 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:
      IOException
    • applyAllSuggestedFixChoicesToCode

      public static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<String,String>> applyAllSuggestedFixChoicesToCode(Iterable<SuggestedFix> fixChoices, Map<String,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<String,String> applySuggestedFixesToCode(Iterable<SuggestedFix> fixes, Map<String,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 String applyCodeReplacements(Collection<CodeReplacement> replacements, 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.