Skip to content

Commit

Permalink
Rework fix for IntelliJ 2023.3 EAP compatibility. Dropping compatibil…
Browse files Browse the repository at this point in the history
…ity for 2023.1 and earlier. (#1439)
  • Loading branch information
ahus1 committed Sep 22, 2023
1 parent 1d00c23 commit c6480fd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This document provides a high-level view of the changes introduced by release.
[[releasenotes]]
== Release notes

=== 0.40.1

- Rework fix for IntelliJ 2023.3 EAP compatibility. Dropping compatibility for 2023.1 and earlier. (#1439)

=== 0.39.9

- Fix IntelliJ 2023.3 EAP compatibility (#1439)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions
# skipping IC-223.7571.182 do to disk space limitations on GHA runners
pluginVerifierIdeVersions = IC-222.3739.54, IC-231.9225.16, IC-232.9559.62
pluginVerifierIdeVersions = IC-232.9559.62, IC-233.6745.305
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.asciidoc.intellij.ui;

import com.intellij.openapi.fileEditor.AsyncFileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.progress.CoroutinesKt;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

public abstract class SplitTextEditorProvider implements FileEditorProvider, DumbAware {
public abstract class SplitTextEditorProvider implements AsyncFileEditorProvider, DumbAware {

private static final String FIRST_EDITOR = "first_editor";
private static final String SECOND_EDITOR = "second_editor";
Expand Down Expand Up @@ -40,7 +42,7 @@ public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
return createSplitEditor(myFirstProvider.createEditor(project, file), mySecondProvider.createEditor(project, file));
return createEditorAsync(project, file).build();
}

@NotNull
Expand All @@ -49,6 +51,24 @@ public String getEditorTypeId() {
return myEditorTypeId;
}

@NotNull
@Override
public Builder createEditorAsync(@NotNull final Project project, @NotNull final VirtualFile file) {
final Builder firstBuilder = getBuilderFromEditorProvider(myFirstProvider, project, file);
final Builder secondBuilder = getBuilderFromEditorProvider(mySecondProvider, project, file);

return new Builder() {
@Override
public @NotNull FileEditor build() {
// FileEditorManagerImpl$dumbModeFinished$fileToNewProviders will call this in a background thread
// EditorImpl wants to be called from EDT only, let's switch to EDT for this.
// This is a known problem: https://youtrack.jetbrains.com/issue/IDEA-318259 in 2023.2 and will be fixed in 2023.3
// A workaround didn't work as expected, reverting it.
return createSplitEditor(firstBuilder.build(), secondBuilder.build());
}
};
}

@NotNull
@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
Expand Down Expand Up @@ -107,4 +127,20 @@ public FileEditorPolicy getPolicy() {
return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
}

@NotNull
private static Builder getBuilderFromEditorProvider(@NotNull final FileEditorProvider provider,
@NotNull final Project project,
@NotNull final VirtualFile file) {
if (provider instanceof AsyncFileEditorProvider) {
return CoroutinesKt.runBlockingMaybeCancellable((coroutineScope, continuation) ->
((AsyncFileEditorProvider) provider).createEditorBuilder(project, file, continuation));
} else {
return new Builder() {
@Override
public FileEditor build() {
return provider.createEditor(project, file);
}
};
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
on how to target different products -->
<idea-version since-build="222.3739.54"/> <!-- 2022.2.1 -->
<idea-version since-build="232.9559.62"/> <!-- 2023.2.1 -->
<!-- please see https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -->
<depends>com.intellij.modules.lang</depends>
<depends optional="true" config-file="org.asciidoctor.intellij.asciidoc-javafx.xml">com.intellij.javafx</depends>
Expand Down

0 comments on commit c6480fd

Please sign in to comment.