mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-170039 Honor new foldings 'collapse by default' state - convert Java and XML folding settings to use properties with modification tracking
This commit is contained in:
+16
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.codeInsight.folding;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.util.BooleanTrackableProperty;
|
||||
|
||||
public abstract class JavaCodeFoldingSettings {
|
||||
|
||||
@@ -26,43 +27,57 @@ public abstract class JavaCodeFoldingSettings {
|
||||
|
||||
public abstract boolean isCollapseImports();
|
||||
public abstract void setCollapseImports(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseImportsProperty();
|
||||
|
||||
public abstract boolean isCollapseLambdas();
|
||||
public abstract void setCollapseLambdas(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseLambdasProperty();
|
||||
|
||||
public abstract boolean isCollapseMethods();
|
||||
public abstract void setCollapseMethods(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseMethodsProperty();
|
||||
|
||||
public abstract boolean isCollapseConstructorGenericParameters();
|
||||
public abstract void setCollapseConstructorGenericParameters(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseConstructorGenericParametersProperty();
|
||||
|
||||
public abstract boolean isCollapseAccessors();
|
||||
public abstract void setCollapseAccessors(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseAccessorsProperty();
|
||||
|
||||
public abstract boolean isCollapseOneLineMethods();
|
||||
public abstract void setCollapseOneLineMethods(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseOneLineMethodsProperty();
|
||||
|
||||
public abstract boolean isCollapseInnerClasses();
|
||||
public abstract void setCollapseInnerClasses(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseInnerClassesProperty();
|
||||
|
||||
public abstract boolean isCollapseJavadocs();
|
||||
public abstract void setCollapseJavadocs(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseJavadocsProperty();
|
||||
|
||||
public abstract boolean isCollapseFileHeader();
|
||||
public abstract void setCollapseFileHeader(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseFileHeaderProperty();
|
||||
|
||||
public abstract boolean isCollapseAnonymousClasses();
|
||||
public abstract void setCollapseAnonymousClasses(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseAnonymousClassesProperty();
|
||||
|
||||
public abstract boolean isCollapseAnnotations();
|
||||
public abstract void setCollapseAnnotations(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseAnnotationsProperty();
|
||||
|
||||
public abstract boolean isCollapseI18nMessages();
|
||||
public abstract void setCollapseI18nMessages(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseI18nMessagesProperty();
|
||||
|
||||
public abstract boolean isCollapseSuppressWarnings();
|
||||
public abstract void setCollapseSuppressWarnings(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseSuppressWarningsProperty();
|
||||
|
||||
public abstract boolean isCollapseEndOfLineComments();
|
||||
public abstract void setCollapseEndOfLineComments(boolean value);
|
||||
public abstract BooleanTrackableProperty getCollapseEndOfLineCommentsProperty();
|
||||
}
|
||||
|
||||
+111
-39
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -17,155 +17,227 @@ package com.intellij.codeInsight.folding.impl;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingSettings;
|
||||
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
||||
import com.intellij.util.BooleanTrackableProperty;
|
||||
|
||||
public class JavaCodeFoldingSettingsBase extends JavaCodeFoldingSettings {
|
||||
private boolean COLLAPSE_ACCESSORS;
|
||||
private boolean COLLAPSE_ONE_LINE_METHODS = true;
|
||||
private boolean COLLAPSE_INNER_CLASSES;
|
||||
private boolean COLLAPSE_ANONYMOUS_CLASSES;
|
||||
private boolean COLLAPSE_ANNOTATIONS;
|
||||
private boolean COLLAPSE_CLOSURES = true;
|
||||
private boolean COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS = true;
|
||||
private boolean COLLAPSE_I18N_MESSAGES = true;
|
||||
private boolean COLLAPSE_SUPPRESS_WARNINGS = true;
|
||||
private boolean COLLAPSE_END_OF_LINE_COMMENTS;
|
||||
private BooleanTrackableProperty COLLAPSE_ACCESSORS = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty COLLAPSE_ONE_LINE_METHODS = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty COLLAPSE_INNER_CLASSES = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty COLLAPSE_ANONYMOUS_CLASSES = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty COLLAPSE_ANNOTATIONS = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty COLLAPSE_CLOSURES = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty COLLAPSE_I18N_MESSAGES = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty COLLAPSE_SUPPRESS_WARNINGS = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty COLLAPSE_END_OF_LINE_COMMENTS = new BooleanTrackableProperty();
|
||||
|
||||
@Override
|
||||
public boolean isCollapseImports() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseImports();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseImports(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS = value;
|
||||
CodeFoldingSettings.getInstance().setCollapseImports(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseImportsProperty() {
|
||||
return CodeFoldingSettings.getInstance().getCollapseImportsProperty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseLambdas() {
|
||||
return COLLAPSE_CLOSURES;
|
||||
return COLLAPSE_CLOSURES.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseLambdas(boolean value) {
|
||||
COLLAPSE_CLOSURES = value;
|
||||
COLLAPSE_CLOSURES.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseLambdasProperty() {
|
||||
return COLLAPSE_CLOSURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseConstructorGenericParameters() {
|
||||
return COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS;
|
||||
return COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseConstructorGenericParameters(boolean value) {
|
||||
COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS = value;
|
||||
COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseConstructorGenericParametersProperty() {
|
||||
return COLLAPSE_CONSTRUCTOR_GENERIC_PARAMETERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseMethods() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_METHODS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseMethods();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseMethods(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_METHODS = value;
|
||||
CodeFoldingSettings.getInstance().setCollapseMethods(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseMethodsProperty() {
|
||||
return CodeFoldingSettings.getInstance().getCollapseMethodsProperty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAccessors() {
|
||||
return COLLAPSE_ACCESSORS;
|
||||
return COLLAPSE_ACCESSORS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAccessors(boolean value) {
|
||||
COLLAPSE_ACCESSORS = value;
|
||||
COLLAPSE_ACCESSORS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseAccessorsProperty() {
|
||||
return COLLAPSE_ACCESSORS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseOneLineMethods() {
|
||||
return COLLAPSE_ONE_LINE_METHODS;
|
||||
return COLLAPSE_ONE_LINE_METHODS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseOneLineMethods(boolean value) {
|
||||
COLLAPSE_ONE_LINE_METHODS = value;
|
||||
COLLAPSE_ONE_LINE_METHODS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseOneLineMethodsProperty() {
|
||||
return COLLAPSE_ONE_LINE_METHODS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseInnerClasses() {
|
||||
return COLLAPSE_INNER_CLASSES;
|
||||
return COLLAPSE_INNER_CLASSES.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseInnerClasses(boolean value) {
|
||||
COLLAPSE_INNER_CLASSES = value;
|
||||
COLLAPSE_INNER_CLASSES.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseInnerClassesProperty() {
|
||||
return COLLAPSE_INNER_CLASSES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseJavadocs() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseDocComments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseJavadocs(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS = value;
|
||||
CodeFoldingSettings.getInstance().setCollapseDocComments(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseJavadocsProperty() {
|
||||
return CodeFoldingSettings.getInstance().getCollapseDocCommentsProperty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseFileHeader() {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER;
|
||||
return CodeFoldingSettings.getInstance().isCollapseFileHeader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseFileHeader(boolean value) {
|
||||
CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER = value;
|
||||
CodeFoldingSettings.getInstance().setCollapseFileHeader(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseFileHeaderProperty() {
|
||||
return CodeFoldingSettings.getInstance().getCollapseFileHeaderProperty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAnonymousClasses() {
|
||||
return COLLAPSE_ANONYMOUS_CLASSES;
|
||||
return COLLAPSE_ANONYMOUS_CLASSES.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAnonymousClasses(boolean value) {
|
||||
COLLAPSE_ANONYMOUS_CLASSES = value;
|
||||
COLLAPSE_ANONYMOUS_CLASSES.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseAnonymousClassesProperty() {
|
||||
return COLLAPSE_ANONYMOUS_CLASSES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseAnnotations() {
|
||||
return COLLAPSE_ANNOTATIONS;
|
||||
return COLLAPSE_ANNOTATIONS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseAnnotations(boolean value) {
|
||||
COLLAPSE_ANNOTATIONS = value;
|
||||
COLLAPSE_ANNOTATIONS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseAnnotationsProperty() {
|
||||
return COLLAPSE_ANNOTATIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseI18nMessages() {
|
||||
return COLLAPSE_I18N_MESSAGES;
|
||||
return COLLAPSE_I18N_MESSAGES.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseI18nMessages(boolean value) {
|
||||
COLLAPSE_I18N_MESSAGES = value;
|
||||
COLLAPSE_I18N_MESSAGES.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseI18nMessagesProperty() {
|
||||
return COLLAPSE_I18N_MESSAGES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseSuppressWarnings() {
|
||||
return COLLAPSE_SUPPRESS_WARNINGS;
|
||||
return COLLAPSE_SUPPRESS_WARNINGS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseSuppressWarnings(boolean value) {
|
||||
COLLAPSE_SUPPRESS_WARNINGS = value;
|
||||
COLLAPSE_SUPPRESS_WARNINGS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseSuppressWarningsProperty() {
|
||||
return COLLAPSE_SUPPRESS_WARNINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseEndOfLineComments() {
|
||||
return COLLAPSE_END_OF_LINE_COMMENTS;
|
||||
return COLLAPSE_END_OF_LINE_COMMENTS.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseEndOfLineComments(boolean value) {
|
||||
COLLAPSE_END_OF_LINE_COMMENTS = value;
|
||||
COLLAPSE_END_OF_LINE_COMMENTS.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseEndOfLineCommentsProperty() {
|
||||
return COLLAPSE_END_OF_LINE_COMMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,15 +487,15 @@ class Test {
|
||||
};
|
||||
}
|
||||
"""
|
||||
boolean oldValue = CodeFoldingSettings.instance.COLLAPSE_CUSTOM_FOLDING_REGIONS;
|
||||
boolean oldValue = CodeFoldingSettings.instance.isCollapseCustomFoldingRegions();
|
||||
try {
|
||||
CodeFoldingSettings.instance.COLLAPSE_CUSTOM_FOLDING_REGIONS = true;
|
||||
CodeFoldingSettings.instance.setCollapseCustomFoldingRegions(true);
|
||||
configure text
|
||||
def foldingModel = myFixture.editor.foldingModel as FoldingModelImpl
|
||||
assert foldingModel.getCollapsedRegionAtOffset(text.indexOf("//<editor-fold"))
|
||||
}
|
||||
finally {
|
||||
CodeFoldingSettings.instance.COLLAPSE_CUSTOM_FOLDING_REGIONS = oldValue;
|
||||
CodeFoldingSettings.instance.setCollapseCustomFoldingRegions(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,15 +16,110 @@
|
||||
package com.intellij.codeInsight.folding;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.util.BooleanTrackableProperty;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
|
||||
@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"})
|
||||
public class CodeFoldingSettings {
|
||||
/** @deprecated Use corresponding getters/setters or property */
|
||||
@Transient
|
||||
public boolean COLLAPSE_IMPORTS = true;
|
||||
|
||||
/** @deprecated Use corresponding getters/setters or property */
|
||||
@Transient
|
||||
public boolean COLLAPSE_METHODS;
|
||||
|
||||
/** @deprecated Use corresponding getters/setters or property */
|
||||
@Transient
|
||||
public boolean COLLAPSE_FILE_HEADER = true;
|
||||
|
||||
/** @deprecated Use corresponding getters/setters or property */
|
||||
@Transient
|
||||
public boolean COLLAPSE_DOC_COMMENTS;
|
||||
|
||||
/** @deprecated Use corresponding getters/setters or property */
|
||||
@Transient
|
||||
public boolean COLLAPSE_CUSTOM_FOLDING_REGIONS;
|
||||
|
||||
private BooleanTrackableProperty myCollapseImports = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty myCollapseMethods = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty myCollapseFileHeader = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty myCollapseDocComments = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty myCollapseCustomFoldingRegions = new BooleanTrackableProperty();
|
||||
|
||||
|
||||
public static CodeFoldingSettings getInstance() {
|
||||
return ServiceManager.getService(CodeFoldingSettings.class);
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_IMPORTS")
|
||||
public boolean isCollapseImports() {
|
||||
return COLLAPSE_IMPORTS;
|
||||
}
|
||||
|
||||
public void setCollapseImports(boolean value) {
|
||||
COLLAPSE_IMPORTS = value;
|
||||
myCollapseImports.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty getCollapseImportsProperty() {
|
||||
return myCollapseImports;
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_METHODS")
|
||||
public boolean isCollapseMethods() {
|
||||
return COLLAPSE_METHODS;
|
||||
}
|
||||
|
||||
public void setCollapseMethods(boolean value) {
|
||||
COLLAPSE_METHODS = value;
|
||||
myCollapseMethods.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty getCollapseMethodsProperty() {
|
||||
return myCollapseMethods;
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_FILE_HEADER")
|
||||
public boolean isCollapseFileHeader() {
|
||||
return COLLAPSE_FILE_HEADER;
|
||||
}
|
||||
|
||||
public void setCollapseFileHeader(boolean value) {
|
||||
COLLAPSE_FILE_HEADER = value;
|
||||
myCollapseFileHeader.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty getCollapseFileHeaderProperty() {
|
||||
return myCollapseFileHeader;
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_DOC_COMMENTS")
|
||||
public boolean isCollapseDocComments() {
|
||||
return COLLAPSE_DOC_COMMENTS;
|
||||
}
|
||||
|
||||
public void setCollapseDocComments(boolean value) {
|
||||
COLLAPSE_DOC_COMMENTS = value;
|
||||
myCollapseDocComments.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty getCollapseDocCommentsProperty() {
|
||||
return myCollapseDocComments;
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_CUSTOM_FOLDING_REGIONS")
|
||||
public boolean isCollapseCustomFoldingRegions() {
|
||||
return COLLAPSE_CUSTOM_FOLDING_REGIONS;
|
||||
}
|
||||
|
||||
public void setCollapseCustomFoldingRegions(boolean value) {
|
||||
COLLAPSE_CUSTOM_FOLDING_REGIONS = value;
|
||||
myCollapseCustomFoldingRegions.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty getCollapseCustomFoldingRegionsProperty() {
|
||||
return myCollapseCustomFoldingRegions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -44,6 +44,6 @@ public abstract class CustomFoldingProvider {
|
||||
public abstract String getEndString();
|
||||
|
||||
public boolean isCollapsedByDefault(String text) {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_CUSTOM_FOLDING_REGIONS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseCustomFoldingRegions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.util;
|
||||
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
|
||||
/**
|
||||
* Boolean property that implements {@link ModificationTracker}.
|
||||
* Not thread safe (external synchronization is required).
|
||||
*/
|
||||
public class BooleanTrackableProperty implements ModificationTracker {
|
||||
private boolean myValue;
|
||||
private long myModificationCount;
|
||||
|
||||
public BooleanTrackableProperty() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public BooleanTrackableProperty(boolean value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public boolean getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
boolean oldValue = myValue;
|
||||
myValue = value;
|
||||
if (value != oldValue) myModificationCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return myModificationCount;
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.intellij.application.options.editor;
|
||||
|
||||
import com.intellij.openapi.options.BeanConfigurable;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.codeInsight.folding.CodeFoldingSettings;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.options.BeanConfigurable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -27,10 +27,10 @@ public class BaseCodeFoldingOptionsProvider extends BeanConfigurable<CodeFolding
|
||||
public BaseCodeFoldingOptionsProvider() {
|
||||
super(CodeFoldingSettings.getInstance());
|
||||
CodeFoldingSettings settings = getInstance();
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.file.header"), ()->settings.COLLAPSE_FILE_HEADER, v->settings.COLLAPSE_FILE_HEADER=v);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.title.imports"), ()->settings.COLLAPSE_IMPORTS, v->settings.COLLAPSE_IMPORTS=v);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.javadoc.comments"), ()->settings.COLLAPSE_DOC_COMMENTS, v->settings.COLLAPSE_DOC_COMMENTS=v);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.method.bodies"), ()->settings.COLLAPSE_METHODS, v->settings.COLLAPSE_METHODS=v);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.custom.folding.regions"), ()->settings.COLLAPSE_CUSTOM_FOLDING_REGIONS, v->settings.COLLAPSE_CUSTOM_FOLDING_REGIONS=v);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.file.header"), settings::isCollapseFileHeader, settings::setCollapseFileHeader);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.title.imports"), settings::isCollapseImports, settings::setCollapseImports);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.javadoc.comments"), settings::isCollapseDocComments, settings::setCollapseDocComments);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.method.bodies"), settings::isCollapseMethods, settings::setCollapseMethods);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.custom.folding.regions"), settings::isCollapseCustomFoldingRegions, settings::setCollapseCustomFoldingRegions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -233,15 +233,15 @@ public class PythonFoldingBuilder extends CustomFoldingBuilder implements DumbAw
|
||||
@Override
|
||||
protected boolean isRegionCollapsedByDefault(@NotNull ASTNode node) {
|
||||
if (isImport(node)) {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseImports();
|
||||
}
|
||||
if (node.getElementType() == PyElementTypes.STRING_LITERAL_EXPRESSION) {
|
||||
if (getDocStringOwnerType(node) == PyElementTypes.FUNCTION_DECLARATION && CodeFoldingSettings.getInstance().COLLAPSE_METHODS) {
|
||||
if (getDocStringOwnerType(node) == PyElementTypes.FUNCTION_DECLARATION && CodeFoldingSettings.getInstance().isCollapseMethods()) {
|
||||
// method will be collapsed, no need to also collapse docstring
|
||||
return false;
|
||||
}
|
||||
if (getDocStringOwnerType(node) != null) {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseDocComments();
|
||||
}
|
||||
return PythonFoldingSettings.getInstance().isCollapseLongStrings();
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class PythonFoldingBuilder extends CustomFoldingBuilder implements DumbAw
|
||||
return PythonFoldingSettings.getInstance().isCollapseSequentialComments();
|
||||
}
|
||||
if (node.getElementType() == PyElementTypes.STATEMENT_LIST && node.getTreeParent().getElementType() == PyElementTypes.FUNCTION_DECLARATION) {
|
||||
return CodeFoldingSettings.getInstance().COLLAPSE_METHODS;
|
||||
return CodeFoldingSettings.getInstance().isCollapseMethods();
|
||||
}
|
||||
if (FOLDABLE_COLLECTIONS_LITERALS.contains(node.getElementType())) {
|
||||
return PythonFoldingSettings.getInstance().isCollapseLongCollections();
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -27,9 +27,9 @@ public class XmlCodeFoldingOptionsProvider extends BeanConfigurable<XmlFoldingSe
|
||||
public XmlCodeFoldingOptionsProvider() {
|
||||
super(XmlFoldingSettings.getInstance().getState());
|
||||
XmlFoldingSettings settings = XmlFoldingSettings.getInstance();
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.xml.tags"), settings::isCollapseXmlTags, value->settings.getState().COLLAPSE_XML_TAGS=value);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.html.style.attribute"),settings::isCollapseHtmlStyleAttribute, value->settings.getState().COLLAPSE_HTML_STYLE_ATTRIBUTE=value);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.entities"),settings::isCollapseEntities, value->settings.getState().COLLAPSE_ENTITIES=value);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.data.uri"),settings::isCollapseDataUri, value->settings.getState().COLLAPSE_DATA_URI=value);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.xml.tags"), settings::isCollapseXmlTags, settings::setCollapseXmlTags);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.html.style.attribute"),settings::isCollapseHtmlStyleAttribute, settings::setCollapseHtmlStyleAttribute);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.entities"),settings::isCollapseEntities, settings::setCollapseEntities);
|
||||
checkBox(ApplicationBundle.message("checkbox.collapse.data.uri"),settings::isCollapseDataUri, settings::setCollapseDataUri);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class RncFoldingBuilder implements FoldingBuilder {
|
||||
|
||||
@Override
|
||||
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
|
||||
return isCommentLike(node.getElementType()) && CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
|
||||
return isCommentLike(node.getElementType()) && CodeFoldingSettings.getInstance().isCollapseDocComments();
|
||||
}
|
||||
|
||||
private static void process(@Nullable ASTNode node, Document document, ArrayList<FoldingDescriptor> regions) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -15,9 +15,19 @@
|
||||
*/
|
||||
package com.intellij.lang;
|
||||
|
||||
import com.intellij.util.BooleanTrackableProperty;
|
||||
|
||||
public interface XmlCodeFoldingSettings {
|
||||
boolean isCollapseXmlTags();
|
||||
void setCollapseXmlTags(boolean value);
|
||||
BooleanTrackableProperty getCollapseXmlTagsProperty();
|
||||
boolean isCollapseHtmlStyleAttribute();
|
||||
void setCollapseHtmlStyleAttribute(boolean value);
|
||||
BooleanTrackableProperty getCollapseHtmlStyleAttributeProperty();
|
||||
boolean isCollapseEntities();
|
||||
void setCollapseEntities(boolean value);
|
||||
BooleanTrackableProperty getCollapseEntitiesProperty();
|
||||
boolean isCollapseDataUri();
|
||||
void setCollapseDataUri(boolean value);
|
||||
BooleanTrackableProperty getCollapseDataUriProperty();
|
||||
}
|
||||
|
||||
+72
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -20,7 +20,9 @@ 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.BooleanTrackableProperty;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@State(name = "XmlFoldingSettings", storages = @Storage("editor.codeinsight.xml"))
|
||||
@@ -35,28 +37,68 @@ public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentSta
|
||||
// todo: remove after 2017.1 release
|
||||
CssFoldingSettings cssFoldingSettings = CssFoldingSettings.getInstance();
|
||||
if (cssFoldingSettings != null) {
|
||||
myState.COLLAPSE_DATA_URI = cssFoldingSettings.isCollapseDataUri();
|
||||
myState.myCollapseDataUri.setValue(cssFoldingSettings.isCollapseDataUri());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseXmlTags() {
|
||||
return myState.COLLAPSE_XML_TAGS;
|
||||
return myState.isCollapseXmlTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseXmlTags(boolean value) {
|
||||
myState.myCollapseXmlTags.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseXmlTagsProperty() {
|
||||
return myState.myCollapseXmlTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseHtmlStyleAttribute() {
|
||||
return myState.COLLAPSE_HTML_STYLE_ATTRIBUTE;
|
||||
return myState.isCollapseHtmlStyleAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseHtmlStyleAttribute(boolean value) {
|
||||
myState.myCollapseHtmlStyleAttributes.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseHtmlStyleAttributeProperty() {
|
||||
return myState.myCollapseHtmlStyleAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseEntities() {
|
||||
return myState.COLLAPSE_ENTITIES;
|
||||
return myState.isCollapseEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseEntities(boolean value) {
|
||||
myState.myCollapseEntities.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseEntitiesProperty() {
|
||||
return myState.myCollapseEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapseDataUri() {
|
||||
return myState.COLLAPSE_DATA_URI;
|
||||
return myState.isCollapseDataUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseDataUri(boolean value) {
|
||||
myState.myCollapseDataUri.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanTrackableProperty getCollapseDataUriProperty() {
|
||||
return myState.myCollapseDataUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,9 +113,29 @@ public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentSta
|
||||
}
|
||||
|
||||
public static final class State {
|
||||
public boolean COLLAPSE_XML_TAGS;
|
||||
public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true;
|
||||
public boolean COLLAPSE_ENTITIES = true;
|
||||
public boolean COLLAPSE_DATA_URI = true;
|
||||
private BooleanTrackableProperty myCollapseXmlTags = new BooleanTrackableProperty();
|
||||
private BooleanTrackableProperty myCollapseHtmlStyleAttributes = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty myCollapseEntities = new BooleanTrackableProperty(true);
|
||||
private BooleanTrackableProperty myCollapseDataUri = new BooleanTrackableProperty(true);
|
||||
|
||||
@OptionTag("COLLAPSE_XML_TAGS")
|
||||
public boolean isCollapseXmlTags() {
|
||||
return myCollapseXmlTags.getValue();
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_HTML_STYLE_ATTRIBUTE")
|
||||
public boolean isCollapseHtmlStyleAttribute() {
|
||||
return myCollapseHtmlStyleAttributes.getValue();
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_ENTITIES")
|
||||
public boolean isCollapseEntities() {
|
||||
return myCollapseEntities.getValue();
|
||||
}
|
||||
|
||||
@OptionTag("COLLAPSE_DATA_URI")
|
||||
public boolean isCollapseDataUri() {
|
||||
return myCollapseDataUri.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user