mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer to use ProjectExtensionPointName
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.core;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingSettings;
|
||||
@@ -18,10 +18,7 @@ import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.impl.CoreCommandProcessor;
|
||||
import com.intellij.openapi.components.ExtensionAreas;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeExtension;
|
||||
@@ -105,7 +102,7 @@ public class CoreApplicationEnvironment {
|
||||
VirtualFileManagerImpl virtualFileManager = new VirtualFileManagerImpl(fs, myApplication.getMessageBus());
|
||||
registerApplicationComponent(VirtualFileManager.class, virtualFileManager);
|
||||
|
||||
//fake EP for cleaning resources after area disposing (otherwise KeyedExtensionCollector listener will be copied to the next area)
|
||||
//fake EP for cleaning resources after area disposing (otherwise KeyedExtensionCollector listener will be copied to the next area)
|
||||
registerApplicationExtensionPoint(new ExtensionPointName<>("com.intellij.virtualFileSystem"), KeyedLazyInstanceEP.class);
|
||||
|
||||
registerApplicationService(EncodingManager.class, new CoreEncodingRegistry());
|
||||
@@ -263,12 +260,16 @@ public class CoreApplicationEnvironment {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static <T> void registerExtensionPoint(@NotNull ExtensionsArea area,
|
||||
@NotNull ExtensionPointName<T> extensionPointName,
|
||||
@NotNull Class<? extends T> aClass) {
|
||||
final String name = extensionPointName.getName();
|
||||
registerExtensionPoint(area, name, aClass);
|
||||
registerExtensionPoint(area, extensionPointName.getName(), aClass);
|
||||
}
|
||||
|
||||
public static <T> void registerExtensionPoint(@NotNull ExtensionsArea area,
|
||||
@NotNull BaseExtensionPointName extensionPointName,
|
||||
@NotNull Class<? extends T> aClass) {
|
||||
registerExtensionPoint(area, extensionPointName.getName(), aClass);
|
||||
}
|
||||
|
||||
public static <T> void registerExtensionPoint(@NotNull ExtensionsArea area, @NotNull String name, @NotNull Class<? extends T> aClass) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.psi.impl;
|
||||
|
||||
@@ -344,7 +344,7 @@ public class PsiManagerImpl extends PsiManagerEx {
|
||||
preprocessor.treeChanged(event);
|
||||
}
|
||||
boolean enableOutOfCodeBlockTracking = ((PsiModificationTrackerImpl)myModificationTracker).isEnableCodeBlockTracker();
|
||||
for (PsiTreeChangePreprocessor preprocessor : PsiTreeChangePreprocessor.EP_NAME.getExtensions(myProject)) {
|
||||
for (PsiTreeChangePreprocessor preprocessor : PsiTreeChangePreprocessor.EP.getExtensions(myProject)) {
|
||||
if (!enableOutOfCodeBlockTracking && preprocessor instanceof PsiTreeChangePreprocessorBase) continue;
|
||||
try {
|
||||
preprocessor.treeChanged(event);
|
||||
@@ -354,7 +354,7 @@ public class PsiManagerImpl extends PsiManagerEx {
|
||||
}
|
||||
}
|
||||
if (!enableOutOfCodeBlockTracking) {
|
||||
for (PsiTreeChangePreprocessor preprocessor : PsiTreeChangePreprocessor.EP_NAME.getExtensions(myProject)) {
|
||||
for (PsiTreeChangePreprocessor preprocessor : PsiTreeChangePreprocessor.EP.getExtensions(myProject)) {
|
||||
if (!(preprocessor instanceof PsiTreeChangePreprocessorBase)) continue;
|
||||
try {
|
||||
((PsiTreeChangePreprocessorBase)preprocessor).onOutOfCodeBlockModification(event);
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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-2019 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.psi.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.ProjectExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An extension called before notifying {@link com.intellij.psi.PsiTreeChangeListener}s of events.<p></p>
|
||||
*
|
||||
* <p>
|
||||
* Try to avoid processing PSI events at all cost! See {@link com.intellij.psi.PsiTreeChangeEvent} documentation for more details.
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public interface PsiTreeChangePreprocessor {
|
||||
ProjectExtensionPointName<PsiTreeChangePreprocessor> EP = new ProjectExtensionPointName<>("com.intellij.psi.treeChangePreprocessor");
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #EP}
|
||||
*/
|
||||
@Deprecated
|
||||
ExtensionPointName<PsiTreeChangePreprocessor> EP_NAME = ExtensionPointName.create("com.intellij.psi.treeChangePreprocessor");
|
||||
|
||||
void treeChanged(@NotNull PsiTreeChangeEventImpl event);
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
/*
|
||||
* 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-2019 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.ide.projectView;
|
||||
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.ProjectExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,6 +13,12 @@ import java.util.Collection;
|
||||
* Allows a plugin to modify the structure of a project as displayed in the project view.
|
||||
*/
|
||||
public interface TreeStructureProvider {
|
||||
ProjectExtensionPointName<TreeStructureProvider> EP = new ProjectExtensionPointName<>("com.intellij.treeStructureProvider");
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #EP}
|
||||
*/
|
||||
@Deprecated
|
||||
ExtensionPointName<TreeStructureProvider> EP_NAME = ExtensionPointName.create("com.intellij.treeStructureProvider");
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.ide.impl;
|
||||
|
||||
import com.intellij.ide.CompositeSelectInTarget;
|
||||
@@ -139,8 +139,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
|
||||
}
|
||||
|
||||
private TreeStructureProvider[] getProvidersDumbAware() {
|
||||
TreeStructureProvider[] allProviders = TreeStructureProvider.EP_NAME.getExtensions(myProject);
|
||||
List<TreeStructureProvider> dumbAware = DumbService.getInstance(myProject).filterByDumbAwareness(allProviders);
|
||||
List<TreeStructureProvider> dumbAware = DumbService.getInstance(myProject).filterByDumbAwareness(TreeStructureProvider.EP.getExtensions(myProject));
|
||||
return dumbAware.toArray(new TreeStructureProvider[0]);
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.ide.projectView.impl;
|
||||
|
||||
import com.intellij.ide.projectView.TreeStructureProvider;
|
||||
@@ -14,6 +14,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -22,10 +24,10 @@ import java.util.Objects;
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
public final class CompoundTreeStructureProvider implements TreeStructureProvider {
|
||||
private static final TreeStructureProvider EMPTY = new CompoundTreeStructureProvider();
|
||||
private static final TreeStructureProvider EMPTY = new CompoundTreeStructureProvider(Collections.emptyList());
|
||||
private static final Key<TreeStructureProvider> KEY = Key.create("TreeStructureProvider");
|
||||
private static final Logger LOG = Logger.getInstance(CompoundTreeStructureProvider.class);
|
||||
private final TreeStructureProvider[] providers;
|
||||
private final List<TreeStructureProvider> providers;
|
||||
|
||||
/**
|
||||
* @return a shared instance for the specified project
|
||||
@@ -35,12 +37,12 @@ public final class CompoundTreeStructureProvider implements TreeStructureProvide
|
||||
if (project == null || project.isDisposed()) return EMPTY;
|
||||
TreeStructureProvider provider = project.getUserData(KEY);
|
||||
if (provider != null) return provider;
|
||||
provider = new CompoundTreeStructureProvider(EP_NAME.getExtensions(project));
|
||||
provider = new CompoundTreeStructureProvider(EP.getExtensions(project));
|
||||
project.putUserData(KEY, provider);
|
||||
return provider;
|
||||
}
|
||||
|
||||
public CompoundTreeStructureProvider(@NotNull TreeStructureProvider... providers) {
|
||||
public CompoundTreeStructureProvider(@NotNull List<TreeStructureProvider> providers) {
|
||||
this.providers = providers;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2019 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.ide.projectView.impl;
|
||||
|
||||
@@ -19,8 +19,7 @@ public abstract class ProjectAbstractTreeStructureBase extends AbstractTreeStruc
|
||||
@Override
|
||||
public List<TreeStructureProvider> getProviders() {
|
||||
if (myProviders == null) {
|
||||
final TreeStructureProvider[] providers = TreeStructureProvider.EP_NAME.getExtensions(myProject);
|
||||
myProviders = Arrays.asList(providers);
|
||||
myProviders = TreeStructureProvider.EP.getExtensions(myProject);
|
||||
}
|
||||
return myProviders;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
@@ -137,7 +134,7 @@ public class PlatformTestUtil {
|
||||
}
|
||||
|
||||
public static <T> void registerExtension(@NotNull ExtensionsArea area,
|
||||
@NotNull ExtensionPointName<T> name,
|
||||
@NotNull BaseExtensionPointName name,
|
||||
@NotNull T t,
|
||||
@NotNull Disposable parentDisposable) {
|
||||
ExtensionPoint<T> extensionPoint = area.getExtensionPoint(name.getName());
|
||||
|
||||
@@ -185,8 +185,7 @@ public class TestCoreEnvironment extends AbstractCoreEnvironment {
|
||||
|
||||
private void registerProjectExtensionPoints() {
|
||||
ExtensionsArea area = Extensions.getArea(myProject);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(
|
||||
area, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, PsiTreeChangePreprocessor.EP, PsiTreeChangePreprocessor.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(
|
||||
area, PsiElementFinder.EP_NAME, PsiElementFinder.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user