mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make allForLanguage() always include the ones for a baseLanguage
This commit is contained in:
@@ -27,7 +27,6 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ExternalLanguageAnnotators extends LanguageExtension<ExternalAnnotator> {
|
||||
public static final ExtensionPointName<LanguageExtensionPoint<ExternalAnnotator>> EP_NAME = ExtensionPointName.create("com.intellij.externalAnnotator");
|
||||
@@ -40,12 +39,8 @@ public class ExternalLanguageAnnotators extends LanguageExtension<ExternalAnnota
|
||||
|
||||
@NotNull
|
||||
public static List<ExternalAnnotator> allForFile(@NotNull Language language, @NotNull final PsiFile file) {
|
||||
final Set<ExternalAnnotator> annotators = ContainerUtil.newHashSet();
|
||||
while (language != null) {
|
||||
annotators.addAll(INSTANCE.forKey(language));
|
||||
language = language.getBaseLanguage();
|
||||
}
|
||||
final ExternalAnnotatorsFilter[] filters = Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
|
||||
List<ExternalAnnotator> annotators = INSTANCE.allForLanguage(language);
|
||||
ExternalAnnotatorsFilter[] filters = Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
|
||||
return ContainerUtil.findAll(annotators, annotator -> {
|
||||
for (ExternalAnnotatorsFilter filter : filters) {
|
||||
if (filter.isProhibited(annotator, file)) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.lang;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.KeyedExtensionCollector;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -86,15 +87,25 @@ public class LanguageExtension<T> extends KeyedExtensionCollector<T, Language> {
|
||||
* @see #allForLanguageOrAny(Language)
|
||||
*/
|
||||
@NotNull
|
||||
public List<T> allForLanguage(@NotNull Language l) {
|
||||
List<T> list = forKey(l);
|
||||
if (list.isEmpty()) {
|
||||
Language base = l.getBaseLanguage();
|
||||
if (base != null) {
|
||||
return allForLanguage(base);
|
||||
public List<T> allForLanguage(@NotNull Language language) {
|
||||
boolean copyList = true;
|
||||
List<T> result = null;
|
||||
for (Language l = language; l != null; l = l.getBaseLanguage()) {
|
||||
List<T> list = forKey(l);
|
||||
if (result == null) {
|
||||
result = list;
|
||||
}
|
||||
else if (!list.isEmpty()) {
|
||||
if (copyList) {
|
||||
result = ContainerUtil.newArrayList(ContainerUtil.concat(result, list));
|
||||
copyList = false;
|
||||
}
|
||||
else {
|
||||
result.addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user