prefer to not use ExtensionPointName.extensions()

In Kotlin streams should be not used, in Java extensions() maybe not performant if you in any case traverse the whole extension point

GitOrigin-RevId: f9ef0ce23617ffc8c89a4fe6df54142b8f6ca7dc
This commit is contained in:
Vladimir Krivosheev
2022-07-19 14:37:35 +02:00
committed by intellij-monorepo-bot
parent b76c7b7288
commit fe9812cfff
33 changed files with 127 additions and 145 deletions

View File

@@ -1,17 +1,20 @@
// Copyright 2000-2020 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.lang.Language;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.ApiStatus;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
public interface XmlTypedHandlersAdditionalSupport {
ExtensionPointName<XmlTypedHandlersAdditionalSupport> EP_NAME = new ExtensionPointName<>("com.intellij.xml.xmlTypedHandlersAdditionalSupport");
static boolean supportsTypedHandlers(@NotNull PsiFile psiFile) {
return EP_NAME.hasAnyExtensions() && EP_NAME.extensions().anyMatch(supporter -> {
if (!EP_NAME.hasAnyExtensions()) {
return false;
}
return ContainerUtil.exists(EP_NAME.getExtensionList(), supporter -> {
for (Language language : psiFile.getViewProvider().getLanguages()) {
if (supporter.isAvailable(psiFile, language)) return true;
}
@@ -20,7 +23,10 @@ public interface XmlTypedHandlersAdditionalSupport {
}
static boolean supportsTypedHandlers(@NotNull PsiFile psiFile, @NotNull Language lang) {
return EP_NAME.hasAnyExtensions() && EP_NAME.extensions().anyMatch(supporter -> supporter.isAvailable(psiFile, lang));
if (!EP_NAME.hasAnyExtensions()) {
return false;
}
return ContainerUtil.exists(EP_NAME.getExtensionList(), supporter -> supporter.isAvailable(psiFile, lang));
}
boolean isAvailable(@NotNull PsiFile psiFile, @NotNull Language lang);