From b027328077a8a8c2e0fdb268fc395f93ee364293 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Sun, 4 Jul 2021 23:27:44 +0100 Subject: [PATCH 1/2] Fix: Support intellij 212 (2021.2 EAP) --- .../intellij/CodeStyleManagerDecorator.java | 6 +++--- .../intellij/PalantirCodeStyleManager.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/CodeStyleManagerDecorator.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/CodeStyleManagerDecorator.java index bb4cc5aff..043a5a9f9 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/CodeStyleManagerDecorator.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/CodeStyleManagerDecorator.java @@ -45,7 +45,7 @@ * * The https://github.com/JetBrains/intellij-community/commit/2d5740176cc9206db2d5ab5d8f67cec74b85a017 * added a CodeManager#scheduleReformatWhenSettingsComputed(PsiFile) method in idea/202.5103.13 where the - * default implementation throws an UnsuportedOperationException. + * default implementation throws an UnsupportedOperationException. * See https://youtrack.jetbrains.com/issue/IDEA-244645 for more details. */ @SuppressWarnings("deprecation") @@ -93,7 +93,7 @@ public void reformatText(PsiFile file, int startOffset, int endOffset) throws In } @Override - public void reformatText(PsiFile file, Collection ranges) throws IncorrectOperationException { + public void reformatText(PsiFile file, Collection ranges) throws IncorrectOperationException { delegate.reformatText(file, ranges); } @@ -104,7 +104,7 @@ public void reformatTextWithContext(PsiFile psiFile, ChangedRangesInfo changedRa } @Override - public void reformatTextWithContext(PsiFile file, Collection ranges) throws IncorrectOperationException { + public void reformatTextWithContext(PsiFile file, Collection ranges) throws IncorrectOperationException { delegate.reformatTextWithContext(file, ranges); } diff --git a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirCodeStyleManager.java b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirCodeStyleManager.java index 5dca4b902..0329d7da3 100644 --- a/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirCodeStyleManager.java +++ b/idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirCodeStyleManager.java @@ -90,7 +90,7 @@ public PalantirCodeStyleManager(@NotNull Project project) { } static Map getReplacements( - FormatterService formatter, String text, Collection ranges) { + FormatterService formatter, String text, Collection ranges) { try { ImmutableMap.Builder replacements = ImmutableMap.builder(); formatter.getFormatReplacements(text, toRanges(ranges)).forEach(replacement -> { @@ -103,7 +103,7 @@ static Map getReplacements( } } - private static Collection> toRanges(Collection textRanges) { + private static Collection> toRanges(Collection textRanges) { return textRanges.stream() .map(textRange -> Range.closedOpen(textRange.getStartOffset(), textRange.getEndOffset())) .collect(Collectors.toList()); @@ -125,7 +125,7 @@ public void reformatText(PsiFile file, int startOffset, int endOffset) throws In } @Override - public void reformatText(PsiFile file, Collection ranges) throws IncorrectOperationException { + public void reformatText(PsiFile file, Collection ranges) throws IncorrectOperationException { if (overrideFormatterForFile(file)) { formatInternal(file, ranges); } else { @@ -140,7 +140,7 @@ public void reformatTextWithContext(PsiFile psiFile, ChangedRangesInfo changedRa } @Override - public void reformatTextWithContext(PsiFile file, Collection ranges) { + public void reformatTextWithContext(PsiFile file, Collection ranges) { if (overrideFormatterForFile(file)) { formatInternal(file, ranges); } else { @@ -176,7 +176,7 @@ private boolean overrideFormatterForFile(PsiFile file) { && PalantirJavaFormatSettings.getInstance(getProject()).isEnabled(); } - private void formatInternal(PsiFile file, Collection ranges) { + private void formatInternal(PsiFile file, Collection ranges) { ApplicationManager.getApplication().assertWriteAccessAllowed(); PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject()); documentManager.commitAllDocuments(); @@ -220,7 +220,7 @@ private static URL[] listDirAsUrlsUnchecked(Path dir) { *

Overriding methods will need to modify the document with the result of the external formatter (usually using * {@link #performReplacements(Document, Map)}. */ - private void format(Document document, Collection ranges) { + private void format(Document document, Collection ranges) { PalantirJavaFormatSettings settings = PalantirJavaFormatSettings.getInstance(getProject()); FormatterService formatter = implementationCache.get(settings.getImplementationClassPath()); From 8bc3582f611b149cbdb9f6b140afee253b14da62 Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Sun, 4 Jul 2021 22:30:36 +0000 Subject: [PATCH 2/2] Add generated changelog entries --- changelog/@unreleased/pr-502.v2.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog/@unreleased/pr-502.v2.yml diff --git a/changelog/@unreleased/pr-502.v2.yml b/changelog/@unreleased/pr-502.v2.yml new file mode 100644 index 000000000..8c9312bb8 --- /dev/null +++ b/changelog/@unreleased/pr-502.v2.yml @@ -0,0 +1,7 @@ +type: fix +fix: + description: Support Intellij 212 API level (2021.2 EAP). The type signature changed + from `Collection` to `Collection`. This is inspired + by same fix in bazel intellij plugin to avoid compiling multiple versions + links: + - https://github.com/palantir/palantir-java-format/pull/502