diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 64f737ce376b..00f42a06cd93 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -116,8 +116,8 @@ - + diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java index 3a412bf3ca8c..68c031cea400 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/XsltSupport.java @@ -15,6 +15,8 @@ */ package org.intellij.lang.xpath.xslt; +import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; +import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; @@ -47,6 +49,8 @@ public class XsltSupport { public static final String XSLT_NS = "http://www.w3.org/1999/XSL/Transform"; public static final String PLUGIN_EXTENSIONS_NS = "urn:idea:xslt-plugin#extensions"; public static final Key> FORCE_XSLT_KEY = Key.create("FORCE_XSLT"); + public static final TextAttributesKey XSLT_DIRECTIVE = + TextAttributesKey.createTextAttributesKey("XSLT_DIRECTIVE", DefaultLanguageHighlighterColors.TEMPLATE_LANGUAGE_COLOR); private static final Map XPATH_ATTR_MAP = new THashMap(10); private static final Map> XPATH_AVT_MAP = new THashMap>(10); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltColorPage.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltColorPage.java new file mode 100644 index 000000000000..e4f7f43057f0 --- /dev/null +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltColorPage.java @@ -0,0 +1,61 @@ +/* + * 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 org.intellij.lang.xpath.xslt.validation; + +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.options.colors.AttributesDescriptor; +import com.intellij.openapi.options.colors.pages.XMLColorsPage; +import org.intellij.lang.xpath.xslt.XsltSupport; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Map; + +/** + * @author Dmitry Avdeev + */ +public class XsltColorPage extends XMLColorsPage { + @NotNull + @Override + public String getDisplayName() { + return "XSLT"; + } + + @NotNull + @Override + public AttributesDescriptor[] getAttributeDescriptors() { + return new AttributesDescriptor[] { new AttributesDescriptor("XSLT directive", XsltSupport.XSLT_DIRECTIVE)}; + } + + @NotNull + @Override + public String getDemoText() { + return "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + } + + @Override + public Map getAdditionalHighlightingTagToDescriptorMap() { + return Collections.singletonMap("xsl", XsltSupport.XSLT_DIRECTIVE); + } +} diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltNSColorProvider.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltNSColorProvider.java new file mode 100644 index 000000000000..6687c71e70c2 --- /dev/null +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltNSColorProvider.java @@ -0,0 +1,37 @@ +/* + * 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 org.intellij.lang.xpath.xslt.validation; + +import com.intellij.codeInsight.daemon.impl.analysis.XmlNSColorProvider; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.psi.xml.XmlElement; +import com.intellij.psi.xml.XmlTag; +import org.intellij.lang.xpath.xslt.XsltSupport; +import org.jetbrains.annotations.Nullable; + +/** + * @author Dmitry Avdeev + */ +public class XsltNSColorProvider implements XmlNSColorProvider { + + @Nullable + @Override + public TextAttributesKey getKeyForNamespace(String namespace, XmlElement context) { + if (!(context instanceof XmlTag)) return null; + if (XsltSupport.XSLT_NS.equals(((XmlTag)context).getNamespace())) return XsltSupport.XSLT_DIRECTIVE; + return null; + } +} diff --git a/plugins/xpath/xpath-view/src/META-INF/plugin.xml b/plugins/xpath/xpath-view/src/META-INF/plugin.xml index 840cccb76aca..0be80ec48645 100644 --- a/plugins/xpath/xpath-view/src/META-INF/plugin.xml +++ b/plugins/xpath/xpath-view/src/META-INF/plugin.xml @@ -145,6 +145,9 @@ + + +