Make IDEA plugin work with recent IDEA versions, remove some deprecated API usages

This commit is contained in:
Alexey Andreev 2021-01-28 17:56:23 +03:00
parent f435d43996
commit ae1ec8ffe5
11 changed files with 30 additions and 20 deletions

View File

@ -21,6 +21,7 @@ import com.intellij.openapi.extensions.PluginId;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -57,11 +58,16 @@ public final class DaemonUtil {
}
public static List<String> detectClassPath() {
IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("org.teavm.idea"));
Set<File> visited = new HashSet<>();
List<String> classPath = new ArrayList<>();
findInHierarchy(plugin.getPath(), classPath, visited);
return classPath;
PluginId id = PluginId.getId("org.teavm.idea");
for (IdeaPluginDescriptor plugin : PluginManager.getPlugins()) {
if (plugin.getPluginId().compareTo(id) == 0) {
Set<File> visited = new HashSet<>();
List<String> classPath = new ArrayList<>();
findInHierarchy(plugin.getPath(), classPath, visited);
return classPath;
}
}
return Collections.emptyList();
}
private static void findInHierarchy(File file, List<String> targetFiles, Set<File> visited) {

View File

@ -17,6 +17,8 @@ package org.teavm.idea;
import static org.teavm.idea.jps.remote.TeaVMBuilderAssistant.REMOTE_PORT;
import com.intellij.compiler.server.BuildProcessParametersProvider;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
@ -26,9 +28,10 @@ public class TeaVMJPSConfigurator extends BuildProcessParametersProvider {
private TeaVMJPSRemoteService remoteService;
private TeaVMDaemonComponent daemonComponent;
public TeaVMJPSConfigurator(TeaVMJPSRemoteService remoteService, TeaVMDaemonComponent daemonComponent) {
this.remoteService = remoteService;
this.daemonComponent = daemonComponent;
public TeaVMJPSConfigurator() {
Application app = ApplicationManager.getApplication();
this.remoteService = app.getComponent(TeaVMJPSRemoteService.class);
this.daemonComponent = app.getComponent(TeaVMDaemonComponent.class);
}
@NotNull

View File

@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
public class TeaVMWebAssemblyFacetType extends FacetType<TeaVMFacet, TeaVMFacetConfiguration> {
public static final FacetTypeId<TeaVMFacet> TYPE_ID = new FacetTypeId<>("teavm-wasm");
private static final Icon icon = IconLoader.getIcon("/teavm-16.png");
private static final Icon icon = IconLoader.findIcon("/teavm-16.png");
public TeaVMWebAssemblyFacetType() {
super(TYPE_ID, "teavm-wasm", "TeaVM (WebAssembly)");

View File

@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
public class TeaVMDebugConfigurationType extends ConfigurationTypeBase {
public TeaVMDebugConfigurationType() {
super("TeaVMDebugConfiguration", "TeaVM debug server", "Debug server that expects connection from browser "
+ "agent", IconLoader.getIcon("/teavm-16.png"));
+ "agent", IconLoader.findIcon("/teavm-16.png"));
}
private final ConfigurationFactory factory = new ConfigurationFactory(this) {

View File

@ -18,18 +18,18 @@ package org.teavm.idea.debug.ui;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.JBUI;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import org.teavm.idea.debug.TeaVMDebugConfiguration;
class TeaVMDebugSettingsPanel extends JPanel {
private final JBTextField portField = new JBTextField();
public TeaVMDebugSettingsPanel() {
setBorder(new EmptyBorder(10, 10, 10, 10));
setBorder(JBUI.Borders.empty(10));
GridBagConstraints labelConstraints = new GridBagConstraints();
labelConstraints.anchor = GridBagConstraints.BASELINE_LEADING;

View File

@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
public class TeaVMDevServerConfigurationType extends ConfigurationTypeBase {
public TeaVMDevServerConfigurationType() {
super("TeaVMDevServerConfiguration", "TeaVM development server", "TeaVM development server"
+ "agent", IconLoader.getIcon("/teavm-16.png"));
+ "agent", IconLoader.findIcon("/teavm-16.png"));
}
private final ConfigurationFactory factory = new ConfigurationFactory(this) {

View File

@ -25,6 +25,7 @@ import com.intellij.psi.JavaCodeFragment;
import com.intellij.psi.PsiClass;
import com.intellij.psi.util.PsiMethodUtil;
import com.intellij.ui.EditorTextFieldWithBrowseButton;
import com.intellij.util.ui.JBUI;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.text.DecimalFormat;
@ -33,7 +34,6 @@ import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import org.teavm.idea.devserver.TeaVMDevServerConfiguration;
public class TeaVMDevServerSettingsPanel extends JPanel {
@ -89,7 +89,7 @@ public class TeaVMDevServerSettingsPanel extends JPanel {
private void initLayout() {
setLayout(new GridBagLayout());
setBorder(new EmptyBorder(10, 10, 10, 10));
setBorder(JBUI.Borders.empty(10));
GridBagConstraints labelConstraints = new GridBagConstraints();
labelConstraints.insets.right = 5;

View File

@ -15,6 +15,7 @@
*/
package org.teavm.idea.ui;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.SearchableConfigurable;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@ -36,8 +37,8 @@ public class TeaVMSettingsEditorTab implements SearchableConfigurable {
private JCheckBox incrementalCheckBox;
private TeaVMDaemonComponent daemonComponent;
public TeaVMSettingsEditorTab(TeaVMDaemonComponent daemonComponent) {
this.daemonComponent = daemonComponent;
public TeaVMSettingsEditorTab() {
this.daemonComponent = ApplicationManager.getApplication().getComponent(TeaVMDaemonComponent.class);
contentPane = new JPanel();
daemonCheckBox = new JCheckBox("use build daemon (can increase performance in most cases)");

View File

@ -1,6 +1,6 @@
<idea-plugin>
<id>org.teavm.idea</id>
<name>TeaVM IDEA plugin</name>
<name>TeaVM IDEA Integration</name>
<version>${project.version}</version>
<vendor email="info@teavm.org" url="http://teavm.org">TeaVM community</vendor>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">

View File

@ -16,7 +16,7 @@ cat <<EOF >.idea-repository.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugins>
<plugin id="org.teavm.idea" url="https://dl.bintray.com/konsoletyper/teavm/org/teavm/teavm-idea/$NEW_VERSION/teavm-idea-$NEW_VERSION.zip" version="$NEW_VERSION">
<idea-version since-build="173.*" until-build="223.*" />
<idea-version since-build="182.*" until-build="223.*" />
<description>TeaVM support</description>
</plugin>
</plugins>