mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support load/unload for <editorHighlighterProvider>
GitOrigin-RevId: b62657d3313c745072e69258820d5febbe3706c7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
15ab3ca8b9
commit
21abe24df3
@@ -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<T> extends KeyedExtensionCollector<T, FileType> {
|
||||
super(epName);
|
||||
}
|
||||
|
||||
public FileTypeExtension(@NotNull ExtensionPointName<KeyedLazyInstance<T>> epName) {
|
||||
super(epName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String keyToString(@NotNull final FileType key) {
|
||||
|
||||
+29
-16
@@ -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<EditorHighlighterProvider> {
|
||||
public static final ExtensionPointName<KeyedLazyInstance<EditorHighlighterProvider>> 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<Editor
|
||||
protected List<EditorHighlighterProvider> buildExtensions(@NotNull String stringKey, @NotNull final FileType key) {
|
||||
List<EditorHighlighterProvider> 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<Editor
|
||||
}
|
||||
return fromEP;
|
||||
}
|
||||
|
||||
private synchronized void checkAddEPListener() {
|
||||
if (!myEPListenerAdded) {
|
||||
myEPListenerAdded = true;
|
||||
|
||||
SyntaxHighlighter.EP_NAME.addExtensionPointListener(new ExtensionPointListener<KeyedFactoryEPBean>() {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ public class EditorHighlighterUpdater {
|
||||
|
||||
updateHighlightersOnExtensionsChange(parentDisposable, LanguageSyntaxHighlighters.EP_NAME);
|
||||
updateHighlightersOnExtensionsChange(parentDisposable, SyntaxHighlighterLanguageFactory.EP_NAME);
|
||||
updateHighlightersOnExtensionsChange(parentDisposable, FileTypeEditorHighlighterProviders.EP_NAME);
|
||||
}
|
||||
|
||||
private <T> void updateHighlightersOnExtensionsChange(@NotNull Disposable parentDisposable, @NotNull ExtensionPointName<KeyedLazyInstance<T>> epName) {
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
<extensionPoint name="statistics.counterUsagesCollector" beanClass="com.intellij.internal.statistic.service.fus.collectors.CounterUsageCollectorEP" dynamic="true"/>
|
||||
<extensionPoint name="statistics.validation.customWhiteListRule" interface="com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomWhiteListRule"/>
|
||||
|
||||
<extensionPoint name="editorHighlighterProvider" beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint">
|
||||
<extensionPoint name="editorHighlighterProvider" beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint" dynamic="true">
|
||||
<with attribute="implementationClass" implements="com.intellij.openapi.fileTypes.EditorHighlighterProvider"/>
|
||||
</extensionPoint>
|
||||
<extensionPoint name="fileDocumentManagerListener" interface="com.intellij.openapi.fileEditor.FileDocumentManagerListener"/>
|
||||
|
||||
Reference in New Issue
Block a user