API for unregistering extension without creating its instance

This commit is contained in:
Dmitry Jemerov
2018-05-29 15:21:37 +02:00
parent e2f2b1e4fd
commit 5aaa4edcf8
3 changed files with 20 additions and 38 deletions
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.extensions;
import com.intellij.openapi.Disposable;
@@ -29,6 +27,11 @@ public interface ExtensionPoint<T> {
void unregisterExtension(@NotNull T extension);
/**
* Unregisters an extension of the specified type.
*/
void unregisterExtension(@NotNull Class<? extends T> extensionClass);
void addExtensionPointListener(@NotNull ExtensionPointListener<T> listener, @NotNull Disposable parentDisposable);
void addExtensionPointListener(@NotNull ExtensionPointListener<T> listener);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.extensions.impl;
import com.intellij.openapi.Disposable;
@@ -320,6 +306,17 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
unregisterExtension(extension, null);
}
@Override
public void unregisterExtension(@NotNull Class<? extends T> extensionClass) {
for (ExtensionComponentAdapter adapter : ContainerUtil.concat(myExtensionAdapters, myLoadedAdapters)) {
if (adapter.getAssignableToClassName().equals(extensionClass.getCanonicalName())) {
unregisterExtensionAdapter(adapter);
return;
}
}
throw new IllegalArgumentException("Extension to be removed not found: " + extensionClass);
}
private int getExtensionIndex(@NotNull T extension) {
for (int i = 0; i < myLoadedAdapters.size(); i++) {
ExtensionComponentAdapter adapter = myLoadedAdapters.get(i);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.edu;
import com.google.common.collect.Sets;
@@ -329,11 +315,7 @@ public class PyCharmEduInitialConfigurator {
}
}
for (DirectoryProjectConfigurator ep : Extensions.getExtensions(DirectoryProjectConfigurator.EP_NAME)) {
if (ep instanceof PlatformProjectViewOpener) {
rootArea.getExtensionPoint(DirectoryProjectConfigurator.EP_NAME).unregisterExtension(ep);
}
}
rootArea.getExtensionPoint(DirectoryProjectConfigurator.EP_NAME).unregisterExtension(PlatformProjectViewOpener.class);
// unregister unrelated tips
for (TipAndTrickBean tip : Extensions.getExtensions(TipAndTrickBean.EP_NAME)) {