mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-19061 Integrate the Rearranger-plugin into core-IDEA
1. Changed arrangement rules are correctly persistet and restored at the code style settings xml now; 2. Refactoring;
This commit is contained in:
@@ -68,10 +68,9 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
MODIFIERS_BY_TYPE.put(FIELD, concat(commonModifiers, TRANSIENT, VOLATILE));
|
||||
}
|
||||
|
||||
private static final List<ArrangementRule<StdArrangementEntryMatcher>> DEFAULT_RULES =
|
||||
new ArrayList<ArrangementRule<StdArrangementEntryMatcher>>();
|
||||
private static final List<StdArrangementRule> DEFAULT_RULES = new ArrayList<StdArrangementRule>();
|
||||
static {
|
||||
ArrangementModifier[] visibility = { PUBLIC, PROTECTED, PACKAGE_PRIVATE, PRIVATE };
|
||||
ArrangementModifier[] visibility = {PUBLIC, PROTECTED, PACKAGE_PRIVATE, PRIVATE};
|
||||
for (ArrangementModifier modifier : visibility) {
|
||||
and(FIELD, STATIC, FINAL, modifier);
|
||||
}
|
||||
@@ -90,19 +89,19 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
and(CLASS);
|
||||
}
|
||||
|
||||
private static void and(@NotNull Object ... conditions) {
|
||||
private static void and(@NotNull Object... conditions) {
|
||||
if (conditions.length == 1) {
|
||||
DEFAULT_RULES.add(new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(
|
||||
DEFAULT_RULES.add(new StdArrangementRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(
|
||||
ArrangementUtil.parseType(conditions[0]), conditions[0]
|
||||
))));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition(ArrangementOperator.AND);
|
||||
for (Object condition : conditions) {
|
||||
composite.addOperand(new ArrangementAtomMatchCondition(ArrangementUtil.parseType(condition), condition));
|
||||
}
|
||||
DEFAULT_RULES.add(new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(composite)));
|
||||
DEFAULT_RULES.add(new StdArrangementRule(new StdArrangementEntryMatcher(composite)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -210,7 +209,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ArrangementRule<StdArrangementEntryMatcher>> getDefaultRules() {
|
||||
public List<StdArrangementRule> getDefaultRules() {
|
||||
return DEFAULT_RULES;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
package com.intellij.application.options.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.JavaRearranger;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractArrangementRuleEditingModelTest {
|
||||
|
||||
protected void configure(@NotNull ArrangementMatchCondition matchCondition) {
|
||||
Pair<ArrangementRuleEditingModelImpl,TIntIntHashMap> pair = myBuilder.build(
|
||||
new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(matchCondition)), myTree, myRoot, null, myGrouper
|
||||
new StdArrangementRule(new StdArrangementEntryMatcher(matchCondition)), myTree, myRoot, null, myGrouper
|
||||
);
|
||||
myRowMappings.put(pair.first.getRow(), pair.first);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ public class CommonCodeStyleSettings {
|
||||
|
||||
@NonNls private static final String ARRANGEMENT_ELEMENT_NAME = "arrangementRules";
|
||||
|
||||
private final List<ArrangementRule<?>> myArrangementRules = new ArrayList<ArrangementRule<?>>();
|
||||
private final List<ArrangementRule> myArrangementRules
|
||||
= new ArrayList<ArrangementRule>();
|
||||
private final Language myLanguage;
|
||||
private CodeStyleSettings myRootSettings;
|
||||
private IndentOptions myIndentOptions;
|
||||
@@ -123,15 +124,16 @@ public class CommonCodeStyleSettings {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<ArrangementRule<?>> getArrangementRules() {
|
||||
public List<ArrangementRule> getArrangementRules() {
|
||||
return myArrangementRules;
|
||||
}
|
||||
|
||||
public <T extends ArrangementEntryMatcher> void setArrangementRules(@NotNull List<ArrangementRule<T>> rules) {
|
||||
public void setArrangementRules(@NotNull List<? extends ArrangementRule> rules) {
|
||||
myArrangementRules.clear();
|
||||
myArrangementRules.addAll(rules);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommonCodeStyleSettings clone(@NotNull CodeStyleSettings rootSettings) {
|
||||
CommonCodeStyleSettings commonSettings = new CommonCodeStyleSettings(myLanguage, getFileType());
|
||||
copyPublicFields(this, commonSettings);
|
||||
@@ -140,6 +142,9 @@ public class CommonCodeStyleSettings {
|
||||
IndentOptions targetIndentOptions = commonSettings.initIndentOptions();
|
||||
targetIndentOptions.copyFrom(myIndentOptions);
|
||||
}
|
||||
if (!myArrangementRules.isEmpty()) {
|
||||
rootSettings.setArrangementRules(getArrangementRules());
|
||||
}
|
||||
return commonSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,36 +28,37 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 7/17/12 11:07 AM
|
||||
* @param <M> {@link ArrangementEntryMatcher matcher} type
|
||||
*/
|
||||
public class ArrangementRule<M extends ArrangementEntryMatcher> {
|
||||
public class ArrangementRule {
|
||||
|
||||
@NotNull private final M myMatcher;
|
||||
@NotNull private final ArrangementEntryOrderType mySortType;
|
||||
@NotNull public static final ArrangementEntryOrderType DEFAULT_ORDER_TYPE = ArrangementEntryOrderType.KEEP;
|
||||
|
||||
public ArrangementRule(@NotNull M matcher) {
|
||||
this(matcher, ArrangementEntryOrderType.KEEP);
|
||||
@NotNull private final ArrangementEntryMatcher myMatcher;
|
||||
@NotNull private final ArrangementEntryOrderType myOrderType;
|
||||
|
||||
public ArrangementRule(@NotNull ArrangementEntryMatcher matcher) {
|
||||
this(matcher, DEFAULT_ORDER_TYPE);
|
||||
}
|
||||
|
||||
public ArrangementRule(@NotNull M matcher, @NotNull ArrangementEntryOrderType type) {
|
||||
public ArrangementRule(@NotNull ArrangementEntryMatcher matcher, @NotNull ArrangementEntryOrderType type) {
|
||||
myMatcher = matcher;
|
||||
mySortType = type;
|
||||
myOrderType = type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public M getMatcher() {
|
||||
public ArrangementEntryMatcher getMatcher() {
|
||||
return myMatcher;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ArrangementEntryOrderType getOrderType() {
|
||||
return mySortType;
|
||||
return myOrderType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myMatcher.hashCode();
|
||||
result = 31 * result + mySortType.hashCode();
|
||||
result = 31 * result + myOrderType.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -67,11 +68,11 @@ public class ArrangementRule<M extends ArrangementEntryMatcher> {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ArrangementRule that = (ArrangementRule)o;
|
||||
return mySortType == that.mySortType && myMatcher.equals(that.myMatcher);
|
||||
return myOrderType == that.myOrderType && myMatcher.equals(that.myMatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("matcher: %s, sort type: %s", myMatcher, mySortType);
|
||||
return String.format("matcher: %s, sort type: %s", myMatcher, myOrderType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public class ArrangementUtil {
|
||||
//region Serialization
|
||||
|
||||
@NotNull
|
||||
public static List<ArrangementRule<?>> readExternal(@NotNull Element element, @NotNull Language language) {
|
||||
final List<ArrangementRule<?>> result = new ArrayList<ArrangementRule<?>>();
|
||||
public static List<ArrangementRule> readExternal(@NotNull Element element, @NotNull Language language) {
|
||||
final List<ArrangementRule> result = new ArrayList<ArrangementRule>();
|
||||
ArrangementRuleSerializer serializer = getSerializer(language);
|
||||
for (Object child : element.getChildren()) {
|
||||
ArrangementRule rule = serializer.deserialize((Element)child);
|
||||
@@ -53,7 +53,7 @@ public class ArrangementUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void writeExternal(@NotNull Element element, @NotNull List<ArrangementRule<?>> rules, @NotNull Language language) {
|
||||
public static void writeExternal(@NotNull Element element, @NotNull List<ArrangementRule> rules, @NotNull Language language) {
|
||||
if (rules.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
+14
-13
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.DefaultArrangementEntryMatcherSerializer;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.order.ArrangementEntryOrderType;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -30,22 +30,21 @@ public class DefaultArrangementRuleSerializer implements ArrangementRuleSerializ
|
||||
|
||||
public static final ArrangementRuleSerializer INSTANCE = new DefaultArrangementRuleSerializer();
|
||||
|
||||
@NotNull @NonNls private static final String RULE_ELEMENT_NAME = "rule";
|
||||
@NotNull @NonNls private static final String MATCHER_ELEMENT_NAME = "match";
|
||||
@NotNull @NonNls private static final String SORT_TYPE_ELEMENT_NAME = "sort";
|
||||
@NotNull @NonNls private static final String RULE_ELEMENT_NAME = "rule";
|
||||
@NotNull @NonNls private static final String MATCHER_ELEMENT_NAME = "match";
|
||||
@NotNull @NonNls private static final String ORDER_TYPE_ELEMENT_NAME = "order";
|
||||
|
||||
@NotNull private final DefaultArrangementEntryMatcherSerializer myMatcherSerializer = new DefaultArrangementEntryMatcherSerializer();
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ArrangementRule deserialize(@NotNull Element element) {
|
||||
public StdArrangementRule deserialize(@NotNull Element element) {
|
||||
Element matcherElement = element.getChild(MATCHER_ELEMENT_NAME);
|
||||
if (matcherElement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrangementEntryMatcher matcher = null;
|
||||
StdArrangementEntryMatcher matcher = null;
|
||||
for (Object o : matcherElement.getChildren()) {
|
||||
matcher = myMatcherSerializer.deserialize((Element)o);
|
||||
if (matcher != null) {
|
||||
@@ -57,13 +56,13 @@ public class DefaultArrangementRuleSerializer implements ArrangementRuleSerializ
|
||||
return null;
|
||||
}
|
||||
|
||||
Element sortElement = element.getChild(SORT_TYPE_ELEMENT_NAME);
|
||||
ArrangementEntryOrderType sortType = ArrangementEntryOrderType.KEEP;
|
||||
if (sortElement != null) {
|
||||
sortType = ArrangementEntryOrderType.valueOf(sortElement.getText());
|
||||
Element orderTypeElement = element.getChild(ORDER_TYPE_ELEMENT_NAME);
|
||||
ArrangementEntryOrderType orderType = ArrangementRule.DEFAULT_ORDER_TYPE;
|
||||
if (orderTypeElement != null) {
|
||||
orderType = ArrangementEntryOrderType.valueOf(orderTypeElement.getText());
|
||||
}
|
||||
|
||||
return new ArrangementRule(matcher, sortType);
|
||||
return new StdArrangementRule(matcher, orderType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -76,7 +75,9 @@ public class DefaultArrangementRuleSerializer implements ArrangementRuleSerializ
|
||||
|
||||
Element result = new Element(RULE_ELEMENT_NAME);
|
||||
result.addContent(new Element(MATCHER_ELEMENT_NAME).addContent(matcherElement));
|
||||
result.addContent(new Element(SORT_TYPE_ELEMENT_NAME).setText(rule.getOrderType().toString()));
|
||||
if (rule.getOrderType() != ArrangementRule.DEFAULT_ORDER_TYPE) {
|
||||
result.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(rule.getOrderType().toString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.psi.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.order.ArrangementEntryOrderType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Arrangement rule which uses {@link StdArrangementEntryMatcher standard settings-based matcher}.
|
||||
* <p/>
|
||||
* Not thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/28/12 2:59 PM
|
||||
*/
|
||||
public class StdArrangementRule extends ArrangementRule {
|
||||
|
||||
public StdArrangementRule(@NotNull StdArrangementEntryMatcher matcher) {
|
||||
super(matcher);
|
||||
}
|
||||
|
||||
public StdArrangementRule(@NotNull StdArrangementEntryMatcher matcher, @NotNull ArrangementEntryOrderType type) {
|
||||
super(matcher, type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StdArrangementEntryMatcher getMatcher() {
|
||||
return (StdArrangementEntryMatcher)super.getMatcher();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class DefaultArrangementEntryMatcherSerializer {
|
||||
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
@Nullable
|
||||
public ArrangementEntryMatcher deserialize(@NotNull Element matcherElement) {
|
||||
public StdArrangementEntryMatcher deserialize(@NotNull Element matcherElement) {
|
||||
ArrangementMatchCondition condition = deserializeCondition(matcherElement);
|
||||
return condition == null ? null : new StdArrangementEntryMatcher(condition);
|
||||
}
|
||||
|
||||
+2
-3
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement.settings;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,7 +40,7 @@ public interface ArrangementStandardSettingsAware {
|
||||
* <code>null</code> as an indication that no default rules are available
|
||||
*/
|
||||
@Nullable
|
||||
List<ArrangementRule<StdArrangementEntryMatcher>> getDefaultRules();
|
||||
List<StdArrangementRule> getDefaultRules();
|
||||
|
||||
/**
|
||||
* Allows to answer if given entry type can be applied for the rule specified by the given settings node.
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@
|
||||
package com.intellij.application.options.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementOperator;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
@@ -37,15 +37,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ArrangementRuleEditingModel {
|
||||
|
||||
@NotNull
|
||||
ArrangementRule<StdArrangementEntryMatcher> EMPTY_RULE = new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(
|
||||
StdArrangementRule EMPTY_RULE = new StdArrangementRule(new StdArrangementEntryMatcher(
|
||||
new ArrangementCompositeMatchCondition(ArrangementOperator.AND)
|
||||
));
|
||||
|
||||
|
||||
@NotNull
|
||||
ArrangementMatchCondition getCondition();
|
||||
|
||||
|
||||
@NotNull
|
||||
ArrangementRule<StdArrangementEntryMatcher> getRule();
|
||||
StdArrangementRule getRule();
|
||||
|
||||
/**
|
||||
* Asks current model to destroy itself.
|
||||
|
||||
+2
-3
@@ -16,9 +16,8 @@
|
||||
package com.intellij.application.options.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.HierarchicalArrangementConditionNode;
|
||||
import com.intellij.psi.codeStyle.arrangement.settings.ArrangementConditionsGrouper;
|
||||
@@ -72,7 +71,7 @@ public class ArrangementRuleEditingModelBuilder {
|
||||
*/
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
public Pair<ArrangementRuleEditingModelImpl, TIntIntHashMap> build(
|
||||
@NotNull ArrangementRule<StdArrangementEntryMatcher> rule,
|
||||
@NotNull StdArrangementRule rule,
|
||||
@NotNull JTree tree,
|
||||
@NotNull ArrangementTreeNode root,
|
||||
@Nullable ArrangementTreeNode anchor,
|
||||
|
||||
+8
-8
@@ -17,8 +17,8 @@ package com.intellij.application.options.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementUtil;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.*;
|
||||
import com.intellij.psi.codeStyle.arrangement.settings.ArrangementConditionsGrouper;
|
||||
@@ -48,10 +48,10 @@ public class ArrangementRuleEditingModelImpl implements ArrangementRuleEditingMo
|
||||
@NotNull private final ArrangementConditionsGrouper myGrouper;
|
||||
private final boolean myRootVisible;
|
||||
|
||||
@NotNull private ArrangementTreeNode myTopMost;
|
||||
@NotNull private ArrangementTreeNode myBottomMost;
|
||||
@NotNull private ArrangementRule<StdArrangementEntryMatcher> myRule;
|
||||
private int myRow;
|
||||
@NotNull private ArrangementTreeNode myTopMost;
|
||||
@NotNull private ArrangementTreeNode myBottomMost;
|
||||
@NotNull private StdArrangementRule myRule;
|
||||
private int myRow;
|
||||
|
||||
/**
|
||||
* Creates new <code>ArrangementRuleEditingModelImpl</code> object.
|
||||
@@ -68,7 +68,7 @@ public class ArrangementRuleEditingModelImpl implements ArrangementRuleEditingMo
|
||||
* @param rootVisible determines if the root should be count during rows calculations
|
||||
*/
|
||||
public ArrangementRuleEditingModelImpl(@NotNull DefaultTreeModel model,
|
||||
@NotNull ArrangementRule<StdArrangementEntryMatcher> rule,
|
||||
@NotNull StdArrangementRule rule,
|
||||
@NotNull ArrangementTreeNode topMost,
|
||||
@NotNull ArrangementTreeNode bottomMost,
|
||||
@NotNull ArrangementConditionsGrouper grouper,
|
||||
@@ -104,7 +104,7 @@ public class ArrangementRuleEditingModelImpl implements ArrangementRuleEditingMo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrangementRule<StdArrangementEntryMatcher> getRule() {
|
||||
public StdArrangementRule getRule() {
|
||||
return myRule;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ArrangementRuleEditingModelImpl implements ArrangementRuleEditingMo
|
||||
}
|
||||
|
||||
private void applyNewCondition(@NotNull ArrangementMatchCondition newCondition) {
|
||||
myRule = new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(newCondition));
|
||||
myRule = new StdArrangementRule(new StdArrangementEntryMatcher(newCondition));
|
||||
HierarchicalArrangementConditionNode grouped = myGrouper.group(newCondition);
|
||||
Pair<ArrangementTreeNode, Integer> replacement = ArrangementConfigUtil.map(null, grouped, null);
|
||||
ArrangementTreeNode newBottom = replacement.first;
|
||||
|
||||
+8
-9
@@ -18,8 +18,7 @@ package com.intellij.application.options.codeStyle.arrangement;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
@@ -78,7 +77,7 @@ public class ArrangementRuleTree {
|
||||
private boolean myExplicitSelectionChange;
|
||||
private boolean mySkipSelectionChange;
|
||||
|
||||
public ArrangementRuleTree(@NotNull List<ArrangementRule<StdArrangementEntryMatcher>> rules,
|
||||
public ArrangementRuleTree(@NotNull List<StdArrangementRule> rules,
|
||||
@NotNull ArrangementConditionsGrouper grouper,
|
||||
@NotNull ArrangementNodeDisplayManager displayManager)
|
||||
{
|
||||
@@ -310,8 +309,8 @@ public class ArrangementRuleTree {
|
||||
tree.expandPath(parent);
|
||||
}
|
||||
|
||||
private void map(@NotNull List<ArrangementRule<StdArrangementEntryMatcher>> rules) {
|
||||
for (ArrangementRule<StdArrangementEntryMatcher> rule : rules) {
|
||||
private void map(@NotNull List<StdArrangementRule> rules) {
|
||||
for (StdArrangementRule rule : rules) {
|
||||
Pair<ArrangementRuleEditingModelImpl, TIntIntHashMap> pair = myModelBuilder.build(rule, myTree, myRoot, null, myGrouper);
|
||||
myModels.put(pair.first.getRow(), pair.first);
|
||||
pair.first.addListener(myModelChangeListener);
|
||||
@@ -356,17 +355,17 @@ public class ArrangementRuleTree {
|
||||
* @return rules configured at the current tree at the moment
|
||||
*/
|
||||
@NotNull
|
||||
public List<ArrangementRule<StdArrangementEntryMatcher>> getRules() {
|
||||
public List<StdArrangementRule> getRules() {
|
||||
int[] rows = myModels.keys();
|
||||
Arrays.sort(rows);
|
||||
List<ArrangementRule<StdArrangementEntryMatcher>> result = new ArrayList<ArrangementRule<StdArrangementEntryMatcher>>();
|
||||
List<StdArrangementRule> result = new ArrayList<StdArrangementRule>();
|
||||
for (int row : rows) {
|
||||
result.add(myModels.get(row).getRule());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setRules(@NotNull List<ArrangementRule<StdArrangementEntryMatcher>> rules) {
|
||||
public void setRules(@NotNull List<StdArrangementRule> rules) {
|
||||
myRenderers.clear();
|
||||
myModels.clear();
|
||||
while (myRoot.getChildCount() > 0)
|
||||
@@ -376,7 +375,7 @@ public class ArrangementRuleTree {
|
||||
|
||||
if (ArrangementConstants.LOG_RULE_MODIFICATION) {
|
||||
LOG.info("Arrangement tree is refreshed. Given rules:");
|
||||
for (ArrangementRule<StdArrangementEntryMatcher> rule : rules) {
|
||||
for (StdArrangementRule rule : rules) {
|
||||
LOG.info(" " + rule.toString());
|
||||
}
|
||||
LOG.info("Following models have been built:");
|
||||
|
||||
+7
-7
@@ -29,7 +29,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.Rearranger;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.StdArrangementRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.settings.*;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.SideBorder;
|
||||
@@ -187,10 +187,10 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
private List<ArrangementRule<StdArrangementEntryMatcher>> getRules(@NotNull CodeStyleSettings settings) {
|
||||
List<ArrangementRule<?>> storedRules = settings.getCommonSettings(myLanguage).getArrangementRules();
|
||||
private List<StdArrangementRule> getRules(@NotNull CodeStyleSettings settings) {
|
||||
List<ArrangementRule> storedRules = settings.getCommonSettings(myLanguage).getArrangementRules();
|
||||
if (storedRules.isEmpty()) {
|
||||
List<ArrangementRule<StdArrangementEntryMatcher>> defaultRules = mySettingsAware.getDefaultRules();
|
||||
List<StdArrangementRule> defaultRules = mySettingsAware.getDefaultRules();
|
||||
if (defaultRules != null) {
|
||||
return defaultRules;
|
||||
}
|
||||
@@ -199,9 +199,9 @@ public abstract class ArrangementSettingsPanel extends CodeStyleAbstractPanel {
|
||||
// We use unchecked cast here in assumption that current rearranger is based on standard settings if it uses standard
|
||||
// settings-based rule editor.
|
||||
// Note: unchecked cast for the whole collection doesn't work here (compiler error).
|
||||
List<ArrangementRule<StdArrangementEntryMatcher>> result = new ArrayList<ArrangementRule<StdArrangementEntryMatcher>>();
|
||||
for (ArrangementRule<?> rule : storedRules) {
|
||||
result.add((ArrangementRule<StdArrangementEntryMatcher>)rule);
|
||||
List<StdArrangementRule> result = new ArrayList<StdArrangementRule>();
|
||||
for (ArrangementRule rule : storedRules) {
|
||||
result.add((StdArrangementRule)rule);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+3
-3
@@ -51,7 +51,7 @@ public class ArrangementEngine {
|
||||
}
|
||||
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings();
|
||||
final List<ArrangementRule<?>> arrangementRules = settings.getCommonSettings(file.getLanguage()).getArrangementRules();
|
||||
final List<ArrangementRule> arrangementRules = settings.getCommonSettings(file.getLanguage()).getArrangementRules();
|
||||
if (arrangementRules.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class ArrangementEngine {
|
||||
}
|
||||
|
||||
private static void doArrange(@NotNull final Document document,
|
||||
@NotNull List<ArrangementRule<?>> arrangementRules,
|
||||
@NotNull List<ArrangementRule> arrangementRules,
|
||||
@NotNull Collection<? extends ArrangementEntry> entriesToProcess)
|
||||
{
|
||||
// The general idea is to process entries bottom-up where every processed group belongs to the same parent. We may not bother
|
||||
@@ -174,7 +174,7 @@ public class ArrangementEngine {
|
||||
}
|
||||
}
|
||||
|
||||
private static void doArrange(@NotNull List<ArrangementRule<?>> rules,
|
||||
private static void doArrange(@NotNull List<ArrangementRule> rules,
|
||||
@NotNull List<ArrangementEntry> entries,
|
||||
@NotNull Document document)
|
||||
{
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ abstract class AbstractRearrangerTest extends LightPlatformCodeInsightFixtureTes
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
protected ArrangementRule<StdArrangementEntryMatcher> rule(@NotNull ArrangementMatchCondition condition) {
|
||||
new ArrangementRule<StdArrangementEntryMatcher>(new StdArrangementEntryMatcher(condition))
|
||||
protected StdArrangementRule rule(@NotNull ArrangementMatchCondition condition) {
|
||||
new StdArrangementRule(new StdArrangementEntryMatcher(condition))
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user