diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index fb0ab61a8f02d..02c16408a64a6 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -375,6 +375,7 @@ group.code.folding=Code Folding checkbox.collapse.xml.tags=XML tags checkbox.collapse.html.style.attribute=HTML 'style' attribute checkbox.collapse.entities=XML entities +checkbox.collapse.data.uri=Data URIs checkbox.collapse.anonymous.classes=Anonymous classes checkbox.collapse.closures="Closures" (anonymous classes implementing one method, before Java 8) checkbox.collapse.generic.constructor.parameters=Generic constructor and method parameters diff --git a/xml/impl/src/com/intellij/application/options/editor/XmlCodeFoldingOptionsProvider.java b/xml/impl/src/com/intellij/application/options/editor/XmlCodeFoldingOptionsProvider.java index abdb42ee438b8..ace39250c6ed5 100644 --- a/xml/impl/src/com/intellij/application/options/editor/XmlCodeFoldingOptionsProvider.java +++ b/xml/impl/src/com/intellij/application/options/editor/XmlCodeFoldingOptionsProvider.java @@ -29,5 +29,6 @@ public XmlCodeFoldingOptionsProvider() { checkBox("COLLAPSE_XML_TAGS", ApplicationBundle.message("checkbox.collapse.xml.tags")); checkBox("COLLAPSE_HTML_STYLE_ATTRIBUTE", ApplicationBundle.message("checkbox.collapse.html.style.attribute")); checkBox("COLLAPSE_ENTITIES", ApplicationBundle.message("checkbox.collapse.entities")); + checkBox("COLLAPSE_DATA_URI", ApplicationBundle.message("checkbox.collapse.data.uri")); } } \ No newline at end of file diff --git a/xml/xml-psi-api/src/com/intellij/lang/XmlCodeFoldingSettings.java b/xml/xml-psi-api/src/com/intellij/lang/XmlCodeFoldingSettings.java index ae2a895c90bd0..c4b444612dbea 100644 --- a/xml/xml-psi-api/src/com/intellij/lang/XmlCodeFoldingSettings.java +++ b/xml/xml-psi-api/src/com/intellij/lang/XmlCodeFoldingSettings.java @@ -1,7 +1,23 @@ +/* + * Copyright 2000-2016 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.lang; public interface XmlCodeFoldingSettings { boolean isCollapseXmlTags(); boolean isCollapseHtmlStyleAttribute(); boolean isCollapseEntities(); + boolean isCollapseDataUri(); } diff --git a/xml/xml-psi-impl/src/com/intellij/application/options/editor/CssFoldingSettings.java b/xml/xml-psi-impl/src/com/intellij/application/options/editor/CssFoldingSettings.java new file mode 100644 index 0000000000000..264eb995b2be3 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/application/options/editor/CssFoldingSettings.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2016 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.application.options.editor; + +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.util.xmlb.XmlSerializerUtil; +import org.jetbrains.annotations.Nullable; + +/** + * User: zolotov + * Date: 4/18/13 + * @deprecated use {@link XmlFoldingSettings} + * todo: delete after 2017.1 release + */ +@State( + name="CssFoldingSettings", + storages= { + @Storage(value = "editor.codeinsight.xml", deprecated = true)} +) +public class CssFoldingSettings implements PersistentStateComponent { + public static CssFoldingSettings getInstance() { + return ServiceManager.getService(CssFoldingSettings.class); + } + + private boolean myCollapseDataUri = true; + + public boolean isCollapseDataUri() { + return myCollapseDataUri; + } + + @SuppressWarnings("UnusedDeclaration") + public void setCollapseDataUri(boolean value) { + myCollapseDataUri = value; + } + + @Nullable + @Override + public CssFoldingSettings getState() { + return this; + } + + @Override + public void loadState(CssFoldingSettings state) { + XmlSerializerUtil.copyBean(state, this); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java b/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java index 70ad3b4fad575..103e9c8015e95 100644 --- a/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java +++ b/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java @@ -20,15 +20,24 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; +import com.intellij.util.xmlb.XmlSerializerUtil; @State(name = "XmlFoldingSettings", storages = @Storage("editor.codeinsight.xml")) public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentStateComponent { - private XmlFoldingSettings.State myState; + private final XmlFoldingSettings.State myState = new State(); public static XmlFoldingSettings getInstance() { return ServiceManager.getService(XmlFoldingSettings.class); } + public XmlFoldingSettings() { + // todo: remove after 2017.1 release + CssFoldingSettings cssFoldingSettings = CssFoldingSettings.getInstance(); + if (cssFoldingSettings != null) { + myState.COLLAPSE_DATA_URI = cssFoldingSettings.isCollapseDataUri(); + } + } + @Override public boolean isCollapseXmlTags() { return myState.COLLAPSE_XML_TAGS; @@ -43,6 +52,11 @@ public boolean isCollapseEntities() { return myState.COLLAPSE_ENTITIES; } + @Override + public boolean isCollapseDataUri() { + return myState.COLLAPSE_DATA_URI; + } + @Override public State getState() { return myState; @@ -50,12 +64,13 @@ public State getState() { @Override public void loadState(State state) { - myState = state; + XmlSerializerUtil.copyBean(state, myState); } public static final class State { public boolean COLLAPSE_XML_TAGS = false; public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true; public boolean COLLAPSE_ENTITIES = true; + public boolean COLLAPSE_DATA_URI = true; } } \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java b/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java index 6bad0fd8d0abe..eac4396847da2 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -28,7 +28,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiWhiteSpace; -import com.intellij.psi.impl.source.html.HtmlFileImpl; import com.intellij.psi.impl.source.xml.XmlEntityRefImpl; import com.intellij.psi.impl.source.xml.XmlTokenImpl; import com.intellij.psi.tree.TokenSet; @@ -266,7 +265,7 @@ protected boolean isEntity(PsiElement psi) { } private static boolean isAttributeShouldBeFolded(XmlAttribute child) { - return child.getContainingFile() instanceof HtmlFileImpl && + return HtmlUtil.isHtmlFile(child.getContainingFile()) && HtmlUtil.STYLE_ATTRIBUTE_NAME.equalsIgnoreCase(child.getName()); }