From 21d19df3d481d7d524a226c411cd3f8b1da3ba22 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 7 Apr 2019 09:21:00 +0200 Subject: [PATCH] prefer extension list, conditional iterable --- .../BaseJavaApplicationCommandLineState.java | 2 +- .../testDiscovery/TestDiscoveryProducer.java | 8 +++---- .../execution/ui/AlternativeJREPanel.java | 18 ++------------- .../intellij/execution/ui/JrePathEditor.java | 4 ++-- .../intellij/execution/JUnitRecognizer.java | 10 ++------- .../execution/filters/ExceptionFilters.java | 20 +++-------------- .../runners/JavaPatchableProgramRunner.java | 22 ++----------------- .../codeinsight/JsonLiteralAnnotator.java | 18 ++------------- .../JsonStandardComplianceProvider.java | 22 ++----------------- .../remote/JsonSchemaCatalogManager.java | 4 ++-- .../widget/JsonSchemaStatusWidget.java | 11 +++++----- .../fileTypes/impl/FileTypeManagerImpl.java | 2 +- .../coverage/JavaCoverageAnnotator.java | 19 +++------------- 13 files changed, 31 insertions(+), 129 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java b/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java index 35411380df96..2ac55a8ab4f6 100644 --- a/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java +++ b/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java @@ -28,7 +28,7 @@ public abstract class BaseJavaApplicationCommandLineState(); } }; - for (TestDiscoveryProducer producer : EP.getExtensions()) { + for (TestDiscoveryProducer producer : EP.getExtensionList()) { for (Map.Entry> entry : ContainerUtil.concat( producer.getDiscoveredTests(project, classesAndMethods, frameworkId).entrySet(), producer.getDiscoveredTestsForFiles(project, filePaths, frameworkId).entrySet())) { @@ -77,7 +77,7 @@ public interface TestDiscoveryProducer { // testFqn - (className, methodName) static void consumeAffectedPaths(@NotNull Project project, @NotNull List> testFqns, @NotNull Consumer pathsConsumer, byte frameworkId) throws IOException { - for (TestDiscoveryProducer extension : EP.getExtensions()) { + for (TestDiscoveryProducer extension : EP.getExtensionList()) { for (String path : extension.getAffectedFilePaths(project, testFqns, frameworkId)) { pathsConsumer.consume(path); } @@ -85,7 +85,7 @@ public interface TestDiscoveryProducer { } static void consumeAffectedPaths(@NotNull Project project, @NotNull String testClassName, @NotNull Consumer pathsConsumer, byte frameworkId) throws IOException { - for (TestDiscoveryProducer extension : EP.getExtensions()) { + for (TestDiscoveryProducer extension : EP.getExtensionList()) { for (String path : extension.getAffectedFilePathsByClassName(project, testClassName, frameworkId)) { pathsConsumer.consume(path); } diff --git a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java index b938ddb3bcb5..e7bdb022f70c 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java +++ b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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.execution.ui; import com.intellij.execution.ExecutionBundle; @@ -63,7 +49,7 @@ public class AlternativeJREPanel extends JPanel implements PanelWithAnchor { foundJDKs.add(sdk.getName()); } - for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { + for (JreProvider provider : JreProvider.EP_NAME.getExtensionList()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { foundJDKs.add(path); diff --git a/java/execution/impl/src/com/intellij/execution/ui/JrePathEditor.java b/java/execution/impl/src/com/intellij/execution/ui/JrePathEditor.java index 436cf6b1ae30..201af6b8deaf 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/JrePathEditor.java +++ b/java/execution/impl/src/com/intellij/execution/ui/JrePathEditor.java @@ -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.execution.ui; import com.intellij.execution.ExecutionBundle; @@ -61,7 +61,7 @@ public class JrePathEditor extends LabeledComponent im } final Set jrePaths = new HashSet<>(); - for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) { + for (JreProvider provider : JreProvider.EP_NAME.getExtensionList()) { String path = provider.getJrePath(); if (!StringUtil.isEmpty(path)) { jrePaths.add(path); diff --git a/java/execution/openapi/src/com/intellij/execution/JUnitRecognizer.java b/java/execution/openapi/src/com/intellij/execution/JUnitRecognizer.java index d39c9fa34263..8695b44a8115 100644 --- a/java/execution/openapi/src/com/intellij/execution/JUnitRecognizer.java +++ b/java/execution/openapi/src/com/intellij/execution/JUnitRecognizer.java @@ -1,27 +1,21 @@ +// 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.execution; import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; import org.jetbrains.annotations.NotNull; -/** - * @author Sergey Evdokimov - */ public abstract class JUnitRecognizer { - public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.junitRecognizer"); public abstract boolean isTestAnnotated(@NotNull PsiMethod method); public static boolean willBeAnnotatedAfterCompilation(@NotNull PsiMethod method) { - for (JUnitRecognizer jUnitRecognizer : EP_NAME.getExtensions()) { + for (JUnitRecognizer jUnitRecognizer : EP_NAME.getIterable(null)) { if (jUnitRecognizer.isTestAnnotated(method)) { return true; } } - return false; } - } diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java index f4d993d36c08..74757330fe91 100644 --- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java +++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2011 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.execution.filters; import com.intellij.psi.search.GlobalSearchScope; @@ -27,8 +13,8 @@ public class ExceptionFilters { @NotNull public static List getFilters(@NotNull GlobalSearchScope searchScope) { - ExceptionFilterFactory[] extensions = ExceptionFilterFactory.EP_NAME.getExtensions(); - List filters = new ArrayList<>(extensions.length); + List extensions = ExceptionFilterFactory.EP_NAME.getExtensionList(); + List filters = new ArrayList<>(extensions.size()); for (ExceptionFilterFactory extension : extensions) { filters.add(extension.create(searchScope)); } diff --git a/java/execution/openapi/src/com/intellij/execution/runners/JavaPatchableProgramRunner.java b/java/execution/openapi/src/com/intellij/execution/runners/JavaPatchableProgramRunner.java index a7f94f76f15a..aafcafd2dd0d 100644 --- a/java/execution/openapi/src/com/intellij/execution/runners/JavaPatchableProgramRunner.java +++ b/java/execution/openapi/src/com/intellij/execution/runners/JavaPatchableProgramRunner.java @@ -1,18 +1,4 @@ -/* - * 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.execution.runners; import com.intellij.execution.ExecutionException; @@ -21,11 +7,7 @@ import com.intellij.execution.configurations.JavaParameters; import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.configurations.RunnerSettings; -/** - * @author spleaner - */ public abstract class JavaPatchableProgramRunner extends GenericProgramRunner { - public abstract void patch(JavaParameters javaParameters, RunnerSettings settings, RunProfile runProfile, final boolean beforeExecution) throws ExecutionException; @@ -33,7 +15,7 @@ public abstract class JavaPatchableProgramRunner extensions = JsonLiteralChecker.EP_NAME.getExtensionList(); if (element instanceof JsonReferenceExpression) { highlightPropertyKey(element, holder); } diff --git a/json/src/com/intellij/json/codeinsight/JsonStandardComplianceProvider.java b/json/src/com/intellij/json/codeinsight/JsonStandardComplianceProvider.java index 996cc82a6867..578962437a05 100644 --- a/json/src/com/intellij/json/codeinsight/JsonStandardComplianceProvider.java +++ b/json/src/com/intellij/json/codeinsight/JsonStandardComplianceProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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.json.codeinsight; import com.intellij.openapi.extensions.ExtensionPointName; @@ -30,11 +16,7 @@ public abstract class JsonStandardComplianceProvider { public abstract boolean isCommentAllowed(@NotNull PsiComment comment); public static boolean shouldWarnAboutComment(@NotNull PsiComment comment) { - JsonStandardComplianceProvider[] providers = EP_NAME.getExtensions(); - if (providers.length == 0) { - return true; - } - for (JsonStandardComplianceProvider provider : providers) { + for (JsonStandardComplianceProvider provider : EP_NAME.getIterable(null)) { if (provider.isCommentAllowed(comment)) { return false; } diff --git a/json/src/com/jetbrains/jsonSchema/remote/JsonSchemaCatalogManager.java b/json/src/com/jetbrains/jsonSchema/remote/JsonSchemaCatalogManager.java index 67977f4d6959..559cf9023b92 100644 --- a/json/src/com/jetbrains/jsonSchema/remote/JsonSchemaCatalogManager.java +++ b/json/src/com/jetbrains/jsonSchema/remote/JsonSchemaCatalogManager.java @@ -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.jetbrains.jsonSchema.remote; import com.intellij.openapi.project.Project; @@ -53,7 +53,7 @@ public class JsonSchemaCatalogManager { @Nullable public VirtualFile getSchemaFileForFile(@NotNull VirtualFile file) { if (!JsonSchemaCatalogProjectConfiguration.getInstance(myProject).isCatalogEnabled()) return null; - for (JsonSchemaCatalogExclusion exclusion : JsonSchemaCatalogExclusion.EP_NAME.getExtensions()) { + for (JsonSchemaCatalogExclusion exclusion : JsonSchemaCatalogExclusion.EP_NAME.getIterable(null)) { if (exclusion.isExcluded(file)) { return null; } diff --git a/json/src/com/jetbrains/jsonSchema/widget/JsonSchemaStatusWidget.java b/json/src/com/jetbrains/jsonSchema/widget/JsonSchemaStatusWidget.java index 913c3c970d2d..1d7029a7628e 100644 --- a/json/src/com/jetbrains/jsonSchema/widget/JsonSchemaStatusWidget.java +++ b/json/src/com/jetbrains/jsonSchema/widget/JsonSchemaStatusWidget.java @@ -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.jetbrains.jsonSchema.widget; import com.intellij.codeInsight.hint.HintUtil; @@ -34,7 +34,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Objects; @@ -95,8 +94,8 @@ class JsonSchemaStatusWidget extends EditorBasedStatusBarPopup { return WidgetState.HIDDEN; } - JsonSchemaEnabler[] enablers = JsonSchemaEnabler.EXTENSION_POINT_NAME.getExtensions(); - if (Arrays.stream(enablers).noneMatch(e -> e.isEnabledForFile(file) && e.shouldShowSwitcherWidget(file))) { + List enablers = JsonSchemaEnabler.EXTENSION_POINT_NAME.getExtensionList(); + if (enablers.stream().noneMatch(e -> e.isEnabledForFile(file) && e.shouldShowSwitcherWidget(file))) { return WidgetState.HIDDEN; } @@ -108,8 +107,8 @@ class JsonSchemaStatusWidget extends EditorBasedStatusBarPopup { return WidgetState.getDumbModeState("JSON schema service", isJsonFile ? JSON_SCHEMA_BAR : JSON_SCHEMA_BAR_OTHER_FILES); } - JsonWidgetSuppressor[] suppressors = JsonWidgetSuppressor.EXTENSION_POINT_NAME.getExtensions(); - if (Arrays.stream(suppressors).anyMatch(s -> s.suppressSwitcherWidget(file, myProject))) { + List suppressors = JsonWidgetSuppressor.EXTENSION_POINT_NAME.getExtensionList(); + if (suppressors.stream().anyMatch(s -> s.suppressSwitcherWidget(file, myProject))) { return WidgetState.HIDDEN; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 0c6b78396ede..81fa81f33f62 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -291,7 +291,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent } }; - for (FileTypeFactory factory : FileTypeFactory.FILE_TYPE_FACTORY_EP.getExtensions()) { + for (FileTypeFactory factory : FileTypeFactory.FILE_TYPE_FACTORY_EP.getExtensionList()) { try { factory.createFileTypes(consumer); } diff --git a/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java b/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java index 053cfbc9169c..906a0db76f4e 100644 --- a/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java +++ b/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.coverage; import com.intellij.openapi.application.ApplicationManager; @@ -293,7 +279,8 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator { if (cachedInfo != null) { return cachedInfo; } - for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { + + for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getIterable(null)) { PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(this, value); if (info != null) { myExtensionCoverageInfos.put(value, info);