Skip to content

Commit

Permalink
Fixes before commit reformatting option for IntelliJ IDEA
Browse files Browse the repository at this point in the history
Runs the plugin formatter instead of the default IDE Code Style formatting when "Reformat Code" is enabled in the Before Commit options.

Fixes #228.

Fixes #557

COPYBARA_INTEGRATE_REVIEW=#557 from momenso:bugfix-228 bd995d9
PiperOrigin-RevId: 354103277
  • Loading branch information
momenso authored and google-java-format Team committed Jan 27, 2021
1 parent 24ec96c commit 69ba30f
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.ChangedRangesInfo;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.impl.CheckUtil;
import com.intellij.util.IncorrectOperationException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
Expand Down Expand Up @@ -69,6 +71,12 @@ public void reformatText(PsiFile file, Collection<TextRange> ranges)
}
}

@Override
public void reformatTextWithContext(PsiFile file, ChangedRangesInfo changedRangesInfo)
throws IncorrectOperationException {
reformatTextWithContext(file, Collections.singletonList(file.getTextRange()));
}

@Override
public void reformatTextWithContext(PsiFile file, Collection<TextRange> ranges) {
if (overrideFormatterForFile(file)) {
Expand Down

0 comments on commit 69ba30f

Please sign in to comment.