diff --git a/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeExtension.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeExtension.java index c186aa65bdfc..104243cd2713 100644 --- a/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeExtension.java +++ b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeExtension.java @@ -1,24 +1,11 @@ -/* - * 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. /* * @author max */ package com.intellij.openapi.fileTypes; +import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.KeyedExtensionCollector; import com.intellij.util.KeyedLazyInstance; import org.jetbrains.annotations.NonNls; @@ -33,6 +20,10 @@ public class FileTypeExtension extends KeyedExtensionCollector { super(epName); } + public FileTypeExtension(@NotNull ExtensionPointName> epName) { + super(epName); + } + @NotNull @Override protected String keyToString(@NotNull final FileType key) { diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java index 5f8e766931b9..1f490554e3eb 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java @@ -1,25 +1,16 @@ -/* - * 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.openapi.fileTypes; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; +import com.intellij.openapi.extensions.ExtensionPointListener; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.extensions.KeyedFactoryEPBean; +import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.KeyedLazyInstance; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,10 +21,13 @@ import java.util.List; * @author yole */ public class FileTypeEditorHighlighterProviders extends FileTypeExtension { + public static final ExtensionPointName> EP_NAME = ExtensionPointName.create("com.intellij.editorHighlighterProvider"); public static final FileTypeEditorHighlighterProviders INSTANCE = new FileTypeEditorHighlighterProviders(); + private boolean myEPListenerAdded = false; + private FileTypeEditorHighlighterProviders() { - super("com.intellij.editorHighlighterProvider"); + super(EP_NAME); } @NotNull @@ -41,6 +35,7 @@ public class FileTypeEditorHighlighterProviders extends FileTypeExtension buildExtensions(@NotNull String stringKey, @NotNull final FileType key) { List fromEP = super.buildExtensions(stringKey, key); if (fromEP.isEmpty()) { + checkAddEPListener(); EditorHighlighterProvider defaultProvider = new EditorHighlighterProvider() { @Override public EditorHighlighter getEditorHighlighter(@Nullable Project project, @@ -55,4 +50,22 @@ public class FileTypeEditorHighlighterProviders extends FileTypeExtension() { + @Override + public void extensionAdded(@NotNull KeyedFactoryEPBean extension, @NotNull PluginDescriptor pluginDescriptor) { + invalidateCacheForExtension(extension.key); + } + + @Override + public void extensionRemoved(@NotNull KeyedFactoryEPBean extension, @NotNull PluginDescriptor pluginDescriptor) { + invalidateCacheForExtension(extension.key); + } + }, null); + } + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/EditorHighlighterUpdater.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/EditorHighlighterUpdater.java index 64a947fe57f3..8b41c1e1cfa0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/EditorHighlighterUpdater.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/EditorHighlighterUpdater.java @@ -55,6 +55,7 @@ public class EditorHighlighterUpdater { updateHighlightersOnExtensionsChange(parentDisposable, LanguageSyntaxHighlighters.EP_NAME); updateHighlightersOnExtensionsChange(parentDisposable, SyntaxHighlighterLanguageFactory.EP_NAME); + updateHighlightersOnExtensionsChange(parentDisposable, FileTypeEditorHighlighterProviders.EP_NAME); } private void updateHighlightersOnExtensionsChange(@NotNull Disposable parentDisposable, @NotNull ExtensionPointName> epName) { diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 2910cf5ca846..456fb96a0410 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -229,7 +229,7 @@ - +