PluginStartupComponent reworked into startup activity and service
As BaseComponent is deprecated in a platform #KT-35918 Comment
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ import com.intellij.compiler.server.BuildProcessParametersProvider
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.idea.PluginStartupComponent
|
||||
import org.jetbrains.kotlin.idea.PluginStartupService
|
||||
|
||||
class KotlinBuildProcessParametersProvider(private val project: Project) : BuildProcessParametersProvider() {
|
||||
override fun getVMArguments(): MutableList<String> {
|
||||
@@ -28,7 +28,7 @@ class KotlinBuildProcessParametersProvider(private val project: Project) : Build
|
||||
if (Registry.`is`("kotlin.jps.instrument.bytecode", false)) {
|
||||
res.add("-Dkotlin.jps.instrument.bytecode=true")
|
||||
}
|
||||
PluginStartupComponent.getInstance().aliveFlagPath.let {
|
||||
PluginStartupService.getInstance().aliveFlagPath.let {
|
||||
if (!it.isBlank()) {
|
||||
// TODO: consider taking the property name from compiler/daemon/common (check whether dependency will be not too heavy)
|
||||
res.add("-Dkotlin.daemon.client.alive.path=\"$it\"")
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
</project-components>
|
||||
|
||||
<application-components>
|
||||
<component>
|
||||
<implementation-class>org.jetbrains.kotlin.idea.PluginStartupComponent</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<implementation-class>org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent</implementation-class>
|
||||
</component>
|
||||
@@ -233,6 +229,9 @@
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService" />
|
||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.PluginStartupActivity"/>
|
||||
|
||||
<applicationService serviceInterface="org.jetbrains.kotlin.idea.KotlinIconProviderService"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.KotlinIdeFileIconProviderService"/>
|
||||
|
||||
|
||||
+7
-48
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2020 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,13 +18,14 @@ package org.jetbrains.kotlin.idea;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.DocumentListener;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.searches.IndexPatternSearch;
|
||||
@@ -33,28 +34,15 @@ import org.jetbrains.kotlin.idea.reporter.KotlinReportSubmitter;
|
||||
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinTodoSearcher;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.jetbrains.kotlin.idea.TestResourceBundleKt.registerAdditionalResourceBundleInTests;
|
||||
|
||||
public class PluginStartupComponent implements BaseComponent {
|
||||
private static final Logger LOG = Logger.getInstance(PluginStartupComponent.class);
|
||||
public class PluginStartupActivity implements StartupActivity.DumbAware {
|
||||
private static final Logger LOG = Logger.getInstance(PluginStartupActivity.class);
|
||||
|
||||
private static final String KOTLIN_BUNDLED = "KOTLIN_BUNDLED";
|
||||
|
||||
public static PluginStartupComponent getInstance() {
|
||||
return ApplicationManager.getApplication().getComponent(PluginStartupComponent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return PluginStartupComponent.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
public void runActivity(@NotNull Project project) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
registerAdditionalResourceBundleInTests();
|
||||
}
|
||||
@@ -77,7 +65,7 @@ public class PluginStartupComponent implements BaseComponent {
|
||||
KotlinPluginUpdater.Companion.getInstance().kotlinFileEdited(virtualFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, project);
|
||||
|
||||
ServiceManager.getService(IndexPatternSearch.class).registerExecutor(new KotlinTodoSearcher());
|
||||
|
||||
@@ -94,33 +82,4 @@ public class PluginStartupComponent implements BaseComponent {
|
||||
macros.setMacro(KOTLIN_BUNDLED, PathUtil.getKotlinPathsForIdeaPlugin().getHomePath().getPath());
|
||||
}
|
||||
|
||||
private String aliveFlagPath;
|
||||
|
||||
public synchronized String getAliveFlagPath() {
|
||||
if (this.aliveFlagPath == null) {
|
||||
try {
|
||||
File flagFile = File.createTempFile("kotlin-idea-", "-is-running");
|
||||
flagFile.deleteOnExit();
|
||||
this.aliveFlagPath = flagFile.getAbsolutePath();
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.aliveFlagPath = "";
|
||||
}
|
||||
}
|
||||
return this.aliveFlagPath;
|
||||
}
|
||||
|
||||
public synchronized void resetAliveFlag() {
|
||||
if (this.aliveFlagPath != null) {
|
||||
File flagFile = new File(this.aliveFlagPath);
|
||||
if (flagFile.exists()) {
|
||||
if (flagFile.delete()) {
|
||||
this.aliveFlagPath = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PluginStartupService {
|
||||
|
||||
public static PluginStartupService getInstance() {
|
||||
return ApplicationManager.getApplication().getService(PluginStartupService.class);
|
||||
}
|
||||
|
||||
private String aliveFlagPath;
|
||||
|
||||
public synchronized String getAliveFlagPath() {
|
||||
if (this.aliveFlagPath == null) {
|
||||
try {
|
||||
File flagFile = File.createTempFile("kotlin-idea-", "-is-running");
|
||||
flagFile.deleteOnExit();
|
||||
this.aliveFlagPath = flagFile.getAbsolutePath();
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.aliveFlagPath = "";
|
||||
}
|
||||
}
|
||||
return this.aliveFlagPath;
|
||||
}
|
||||
|
||||
public synchronized void resetAliveFlag() {
|
||||
if (this.aliveFlagPath != null) {
|
||||
File flagFile = new File(this.aliveFlagPath);
|
||||
if (flagFile.exists()) {
|
||||
if (flagFile.delete()) {
|
||||
this.aliveFlagPath = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants;
|
||||
import org.jetbrains.kotlin.config.*;
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle;
|
||||
import org.jetbrains.kotlin.idea.PluginStartupComponent;
|
||||
import org.jetbrains.kotlin.idea.PluginStartupService;
|
||||
import org.jetbrains.kotlin.idea.facet.DescriptionListCellRenderer;
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet;
|
||||
import org.jetbrains.kotlin.idea.project.NewInferenceForIDEAnalysisComponent;
|
||||
@@ -557,7 +557,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
|
||||
boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon();
|
||||
compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected());
|
||||
if (keepAliveCheckBox.isSelected() != oldEnableDaemon) {
|
||||
PluginStartupComponent.getInstance().resetAliveFlag();
|
||||
PluginStartupService.getInstance().resetAliveFlag();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -44,6 +44,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -281,7 +282,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper {
|
||||
@NotNull List<ExtractFunctionParameterTablePanel.ParameterInfo> newParameterInfos,
|
||||
@Nullable KotlinType returnType
|
||||
) {
|
||||
Map<Parameter, Parameter> oldToNewParameters = ContainerUtil.newLinkedHashMap();
|
||||
Map<Parameter, Parameter> oldToNewParameters = new LinkedHashMap<>();
|
||||
for (ExtractFunctionParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) {
|
||||
oldToNewParameters.put(parameterInfo.getOriginalParameter(), parameterInfo.toParameter());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user