From a79ec1f885380612d8ec7fe0a3a4d43959073dd5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 21 Aug 2019 11:06:15 +0200 Subject: [PATCH] Register syntax highlighters directly in XML when possible (work in progress) GitOrigin-RevId: 3480dde4157a0132d7e294ce8e4a68706ed724b4 --- .../src/META-INF/built-in-server.xml | 2 +- .../properties/PropertiesCoreEnvironment.java | 6 ++-- .../PropertiesSyntaxHighlighterFactory.java | 32 ------------------- plugins/sh/resources/META-INF/plugin.xml | 1 + .../sh/src/com/intellij/sh/ShLanguage.java | 3 -- .../sh/highlighter/ShHighlighterFactory.java | 14 -------- python/src/META-INF/python-core-buildout.xml | 1 + .../buildout/config/BuildoutCfgLanguage.java | 10 ------ xml/relaxng/src/META-INF/relaxng-plugin.xml | 2 +- .../relaxNG/compact/RngCompactLanguage.java | 10 ------ 10 files changed, 7 insertions(+), 74 deletions(-) delete mode 100644 plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesSyntaxHighlighterFactory.java delete mode 100644 plugins/sh/src/com/intellij/sh/highlighter/ShHighlighterFactory.java diff --git a/platform/platform-resources/src/META-INF/built-in-server.xml b/platform/platform-resources/src/META-INF/built-in-server.xml index b8926761ac25..1cc11142a072 100644 --- a/platform/platform-resources/src/META-INF/built-in-server.xml +++ b/platform/platform-resources/src/META-INF/built-in-server.xml @@ -2,7 +2,7 @@ - + diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesCoreEnvironment.java b/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesCoreEnvironment.java index e59ef1153b3c..06d60ecf39fa 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesCoreEnvironment.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesCoreEnvironment.java @@ -38,7 +38,7 @@ import com.intellij.lang.properties.refactoring.PropertiesRefactoringSettings; import com.intellij.lang.properties.structureView.PropertiesSeparatorManager; import com.intellij.lang.properties.xml.XmlPropertiesIconProvider; import com.intellij.lang.properties.xml.XmlPropertiesIndex; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.LanguageSyntaxHighlighters; import com.intellij.psi.ElementManipulators; import com.intellij.psi.impl.cache.impl.id.IdIndexers; import com.intellij.psi.impl.cache.impl.idCache.PropertiesIdIndexer; @@ -56,8 +56,8 @@ public class PropertiesCoreEnvironment { public static class ApplicationEnvironment { public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) { appEnvironment.registerFileType(PropertiesFileType.INSTANCE, "properties"); - appEnvironment.addExplicitExtension(SyntaxHighlighterFactory.LANGUAGE_FACTORY, PropertiesLanguage.INSTANCE, - new PropertiesSyntaxHighlighterFactory()); + appEnvironment.addExplicitExtension(LanguageSyntaxHighlighters.INSTANCE, PropertiesLanguage.INSTANCE, + new PropertiesHighlighter()); appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, PropertiesLanguage.INSTANCE, new PropertiesParserDefinition()); appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlPropertiesIndex()); appEnvironment.addExtension(StubIndexExtension.EP_NAME, new PropertyKeyIndex()); diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesSyntaxHighlighterFactory.java b/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesSyntaxHighlighterFactory.java deleted file mode 100644 index 1ec761b44960..000000000000 --- a/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertiesSyntaxHighlighterFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ -package com.intellij.properties; - -import com.intellij.lang.properties.PropertiesHighlighter; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import org.jetbrains.annotations.NotNull; - -/** - * @author Anna Bulenkova - */ -public class PropertiesSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { - @NotNull - @Override - protected SyntaxHighlighter createHighlighter() { - return new PropertiesHighlighter(); - } -} diff --git a/plugins/sh/resources/META-INF/plugin.xml b/plugins/sh/resources/META-INF/plugin.xml index 2848b40b9818..a015c762265f 100644 --- a/plugins/sh/resources/META-INF/plugin.xml +++ b/plugins/sh/resources/META-INF/plugin.xml @@ -13,6 +13,7 @@ Adds support for working with shell script files ]]> + diff --git a/plugins/sh/src/com/intellij/sh/ShLanguage.java b/plugins/sh/src/com/intellij/sh/ShLanguage.java index 2601b390c96a..e6b8ccfd307e 100644 --- a/plugins/sh/src/com/intellij/sh/ShLanguage.java +++ b/plugins/sh/src/com/intellij/sh/ShLanguage.java @@ -2,14 +2,11 @@ package com.intellij.sh; import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; -import com.intellij.sh.highlighter.ShHighlighterFactory; public class ShLanguage extends Language { public static final Language INSTANCE = new ShLanguage(); public ShLanguage() { super("Shell Script", "application/x-bsh", "application/x-sh", "text/x-script.sh"); - SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new ShHighlighterFactory()); } } diff --git a/plugins/sh/src/com/intellij/sh/highlighter/ShHighlighterFactory.java b/plugins/sh/src/com/intellij/sh/highlighter/ShHighlighterFactory.java deleted file mode 100644 index bea14f812039..000000000000 --- a/plugins/sh/src/com/intellij/sh/highlighter/ShHighlighterFactory.java +++ /dev/null @@ -1,14 +0,0 @@ -// 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.sh.highlighter; - -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import org.jetbrains.annotations.NotNull; - -public class ShHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { - @Override - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new ShSyntaxHighlighter(); - } -} diff --git a/python/src/META-INF/python-core-buildout.xml b/python/src/META-INF/python-core-buildout.xml index 90607355fc7c..82f9638d9372 100644 --- a/python/src/META-INF/python-core-buildout.xml +++ b/python/src/META-INF/python-core-buildout.xml @@ -8,6 +8,7 @@ + - + diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RngCompactLanguage.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RngCompactLanguage.java index 64998e58ab4d..b15e449ad2db 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RngCompactLanguage.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RngCompactLanguage.java @@ -22,8 +22,6 @@ import com.intellij.lang.Language; import com.intellij.lang.PairedBraceMatcher; import com.intellij.lang.documentation.DocumentationProvider; import com.intellij.lang.refactoring.NamesValidator; -import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; @@ -143,12 +141,4 @@ public class RngCompactLanguage extends Language { return null; } } - - public static class MySyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { - @Override - @NotNull - protected SyntaxHighlighter createHighlighter() { - return new RncHighlighter(); - } - } }