Skip to content

Commit

Permalink
Merge pull request #267 from jhonnen/master
Browse files Browse the repository at this point in the history
Support IntelliJ 2024.1
  • Loading branch information
krasa authored Jan 31, 2024
2 parents 201ffb6 + 35838f8 commit f0bee7c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package krasa.formatter.action;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.diagnostic.Logger;
Expand All @@ -8,6 +9,7 @@
import com.intellij.openapi.util.IconLoader;
import krasa.formatter.settings.ProjectComponent;
import krasa.formatter.settings.Settings;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

Expand Down Expand Up @@ -68,4 +70,8 @@ private Settings getSettings(AnActionEvent e) {
return settings;
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
}
13 changes: 13 additions & 0 deletions src/main/java/krasa/formatter/plugin/EclipseCodeStyleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public void reformatText(@NotNull PsiFile psiFile, @NotNull Collection<? extends
}
}

// @Override
public void reformatText(@NotNull PsiFile psiFile, @NotNull Collection<? extends TextRange> textRanges, boolean processChangedTextOnly) throws IncorrectOperationException {
if (shouldReformatByEclipse(psiFile)) {
List<TextRange> list = new ArrayList<TextRange>(textRanges);
Collections.sort(list, Collections.reverseOrder(RANGE_COMPARATOR));
formatInternal(psiFile, list, Mode.ALWAYS_FORMAT);
} else if (shouldSkipFormatting(psiFile, textRanges)) {
notifier.notifyFormattingWasDisabled(psiFile);
} else {
original.reformatText(psiFile, textRanges, processChangedTextOnly);
}
}

// @Override
// todo should I even override this method?
public void reformatText(@NotNull final PsiFile psiFile, final int startOffset, final int endOffset) throws IncorrectOperationException {
Expand Down

0 comments on commit f0bee7c

Please sign in to comment.