prefer extension list, conditional iterable

This commit is contained in:
Vladimir Krivosheev
2019-04-07 09:21:00 +02:00
parent b3c0b35875
commit 21d19df3d4
13 changed files with 31 additions and 129 deletions
@@ -28,7 +28,7 @@ public abstract class BaseJavaApplicationCommandLineState<T extends RunConfigura
protected void setupJavaParameters(JavaParameters params) throws ExecutionException {
JavaParametersUtil.configureConfiguration(params, myConfiguration);
for (RunConfigurationExtension ext : RunConfigurationExtension.EP_NAME.getExtensions()) {
for (RunConfigurationExtension ext : RunConfigurationExtension.EP_NAME.getExtensionList()) {
ext.updateJavaParameters(getConfiguration(), params, getRunnerSettings(), getEnvironment().getExecutor());
}
}
@@ -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.testDiscovery;
import com.intellij.openapi.diagnostic.Logger;
@@ -50,7 +50,7 @@ public interface TestDiscoveryProducer {
return new THashSet<>();
}
};
for (TestDiscoveryProducer producer : EP.getExtensions()) {
for (TestDiscoveryProducer producer : EP.getExtensionList()) {
for (Map.Entry<String, Collection<String>> 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<Couple<String>> testFqns, @NotNull Consumer<? super String> 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<? super String> 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);
}
@@ -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);
@@ -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<ComboboxWithBrowseButton> im
}
final Set<String> 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);
@@ -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<JUnitRecognizer> 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;
}
}
@@ -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<Filter> getFilters(@NotNull GlobalSearchScope searchScope) {
ExceptionFilterFactory[] extensions = ExceptionFilterFactory.EP_NAME.getExtensions();
List<Filter> filters = new ArrayList<>(extensions.length);
List<ExceptionFilterFactory> extensions = ExceptionFilterFactory.EP_NAME.getExtensionList();
List<Filter> filters = new ArrayList<>(extensions.size());
for (ExceptionFilterFactory extension : extensions) {
filters.add(extension.create(searchScope));
}
@@ -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<Settings extends RunnerSettings> extends GenericProgramRunner<Settings> {
public abstract void patch(JavaParameters javaParameters, RunnerSettings settings, RunProfile runProfile, final boolean beforeExecution) throws ExecutionException;
@@ -33,7 +15,7 @@ public abstract class JavaPatchableProgramRunner<Settings extends RunnerSettings
Executor executor,
RunProfile runProfile) {
if (runProfile != null) {
for (JavaProgramPatcher patcher : JavaProgramPatcher.EP_NAME.getExtensions()) {
for (JavaProgramPatcher patcher : JavaProgramPatcher.EP_NAME.getExtensionList()) {
patcher.patchJavaParameters(executor, runProfile, javaParameters);
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.json.JsonBundle;
@@ -42,7 +28,7 @@ public class JsonLiteralAnnotator implements Annotator {
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
JsonLiteralChecker[] extensions = JsonLiteralChecker.EP_NAME.getExtensions();
List<JsonLiteralChecker> extensions = JsonLiteralChecker.EP_NAME.getExtensionList();
if (element instanceof JsonReferenceExpression) {
highlightPropertyKey(element, holder);
}
@@ -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;
}
@@ -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;
}
@@ -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<JsonSchemaEnabler> 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<JsonWidgetSuppressor> suppressors = JsonWidgetSuppressor.EXTENSION_POINT_NAME.getExtensionList();
if (suppressors.stream().anyMatch(s -> s.suppressSwitcherWidget(file, myProject))) {
return WidgetState.HIDDEN;
}
@@ -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);
}
@@ -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);