mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -351,6 +351,10 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
n.invite(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
}
|
||||
});
|
||||
Object key = typeRef.get() == null ? NO_TYPE : typeRef.get();
|
||||
Set<ArrangementModifier> modifiers = MODIFIERS_BY_TYPE.get(key);
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.ArrangementModifier
|
||||
import org.junit.Before
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.PROTECTED
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.PUBLIC
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/14/12 1:29 PM
|
||||
*/
|
||||
class JavaRearrangerByNameTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
@Before
|
||||
void setUp() {
|
||||
super.setUp()
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 0
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 0
|
||||
}
|
||||
|
||||
void "test only name condition"() {
|
||||
doTest(
|
||||
initial: '''\
|
||||
class Test {
|
||||
public void setI() {}
|
||||
public void getI() {}
|
||||
public void test() {}
|
||||
}''',
|
||||
expected: '''\
|
||||
class Test {
|
||||
public void getI() {}
|
||||
public void setI() {}
|
||||
public void test() {}
|
||||
}''',
|
||||
rules: [rule("get.*")]
|
||||
)
|
||||
}
|
||||
|
||||
void "test name condition and others"() {
|
||||
doTest(
|
||||
initial: '''\
|
||||
class Test {
|
||||
private void getInner() {}
|
||||
public void getOuter() {}
|
||||
protected void test() {}
|
||||
}''',
|
||||
expected: '''\
|
||||
class Test {
|
||||
public void getOuter() {}
|
||||
protected void test() {}
|
||||
private void getInner() {}
|
||||
}''',
|
||||
rules: [rule("get.*", PUBLIC), rule(PROTECTED)]
|
||||
)
|
||||
}
|
||||
}
|
||||
+16
-5
@@ -18,6 +18,7 @@ package com.intellij.psi.codeStyle.arrangement;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementNameMatchCondition;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -32,13 +33,19 @@ import java.util.Set;
|
||||
public class ArrangementConditionInfo {
|
||||
|
||||
@NotNull private final Set<ArrangementAtomMatchCondition> myAtomConditions = ContainerUtilRt.newHashSet();
|
||||
@NotNull private final Set<Object> myConditions = ContainerUtilRt.newHashSet();
|
||||
@NotNull private final Set<Object> myConditions = ContainerUtilRt.newHashSet();
|
||||
|
||||
@Nullable private ArrangementNameMatchCondition myNameCondition;
|
||||
|
||||
public void setNameCondition(@Nullable ArrangementNameMatchCondition condition) {
|
||||
myNameCondition = condition;
|
||||
}
|
||||
|
||||
public void addAtomCondition(@NotNull ArrangementAtomMatchCondition condition) {
|
||||
myAtomConditions.add(condition);
|
||||
myConditions.add(condition.getValue());
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCondition(@NotNull Object condition) {
|
||||
return myConditions.contains(condition);
|
||||
}
|
||||
@@ -59,13 +66,17 @@ public class ArrangementConditionInfo {
|
||||
@Nullable
|
||||
public ArrangementMatchCondition buildCondition() {
|
||||
if (myAtomConditions.isEmpty()) {
|
||||
return null;
|
||||
return myNameCondition == null ? null : myNameCondition;
|
||||
}
|
||||
if (myAtomConditions.size() == 1) {
|
||||
else if (myAtomConditions.size() == 1 && myNameCondition == null) {
|
||||
return myAtomConditions.iterator().next();
|
||||
}
|
||||
else {
|
||||
return new ArrangementCompositeMatchCondition(myAtomConditions);
|
||||
ArrangementCompositeMatchCondition result = new ArrangementCompositeMatchCondition(myAtomConditions);
|
||||
if (myNameCondition != null) {
|
||||
result.addOperand(myNameCondition);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,11 @@ public class ArrangementUtil {
|
||||
operand.invite(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
result.addOperand(condition);
|
||||
}
|
||||
};
|
||||
for (ArrangementMatchCondition node : nodes) {
|
||||
node.invite(visitor);
|
||||
@@ -175,6 +180,11 @@ public class ArrangementUtil {
|
||||
operand.invite(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
result.setNameCondition(condition);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
+24
-14
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.codeStyle.arrangement.match;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
@@ -74,7 +75,8 @@ public class DefaultArrangementEntryMatcherSerializer {
|
||||
private static final Logger LOG = Logger.getInstance("#" + DefaultArrangementEntryMatcherSerializer.class.getName());
|
||||
|
||||
@NotNull private static final String COMPOSITE_CONDITION_NAME = "AND";
|
||||
|
||||
@NotNull private static final String PATTERN_CONDITION_NAME = "NAME";
|
||||
|
||||
private static final Set<String> ATOM_SETTINGS_TYPES = new HashSet<String>();
|
||||
|
||||
static {
|
||||
@@ -113,7 +115,10 @@ public class DefaultArrangementEntryMatcherSerializer {
|
||||
@Nullable
|
||||
private static ArrangementMatchCondition deserializeCondition(@NotNull Element matcherElement) {
|
||||
String name = matcherElement.getName();
|
||||
if (!COMPOSITE_CONDITION_NAME.equals(name)) {
|
||||
if (PATTERN_CONDITION_NAME.equals(name)) {
|
||||
return new ArrangementNameMatchCondition(StringUtil.unescapeStringCharacters(matcherElement.getText()));
|
||||
}
|
||||
else if (!COMPOSITE_CONDITION_NAME.equals(name)) {
|
||||
if (ATOM_SETTINGS_TYPES.contains(name)) {
|
||||
return deserializeAtomCondition(matcherElement);
|
||||
}
|
||||
@@ -163,23 +168,13 @@ public class DefaultArrangementEntryMatcherSerializer {
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementAtomMatchCondition condition) {
|
||||
Element element = new Element(condition.getType().toString()).setText(condition.getValue().toString());
|
||||
if (result == null) {
|
||||
result = element;
|
||||
}
|
||||
if (parent != null) {
|
||||
parent.addContent(element);
|
||||
}
|
||||
register(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
|
||||
Element composite = new Element(COMPOSITE_CONDITION_NAME);
|
||||
if (result == null) {
|
||||
result = composite;
|
||||
}
|
||||
if (parent != null) {
|
||||
parent.addContent(composite);
|
||||
}
|
||||
register(composite);
|
||||
parent = composite;
|
||||
List<ArrangementMatchCondition> operands = new ArrayList<ArrangementMatchCondition>(condition.getOperands());
|
||||
ContainerUtil.sort(operands, CONDITION_COMPARATOR);
|
||||
@@ -187,5 +182,20 @@ public class DefaultArrangementEntryMatcherSerializer {
|
||||
c.invite(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
Element element = new Element(PATTERN_CONDITION_NAME).setText(StringUtil.escapeStringCharacters(condition.getPattern()));
|
||||
register(element);
|
||||
}
|
||||
|
||||
private void register(@NotNull Element element) {
|
||||
if (result == null) {
|
||||
result = element;
|
||||
}
|
||||
if (parent != null) {
|
||||
parent.addContent(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
-12
@@ -16,13 +16,10 @@
|
||||
package com.intellij.psi.codeStyle.arrangement.match;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementEntry;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.*;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -88,11 +85,12 @@ public class StdArrangementEntryMatcher implements ArrangementEntryMatcher {
|
||||
|
||||
private static class MyVisitor implements ArrangementMatchConditionVisitor {
|
||||
|
||||
@NotNull private final List<ArrangementEntryMatcher> myMatchers = new ArrayList<ArrangementEntryMatcher>();
|
||||
@NotNull private final Set<ArrangementEntryType> myTypes = EnumSet.noneOf(ArrangementEntryType.class);
|
||||
@NotNull private final Set<ArrangementModifier> myModifiers = EnumSet.noneOf(ArrangementModifier.class);
|
||||
@NotNull private final List<ArrangementEntryMatcher> myMatchers = ContainerUtilRt.newArrayList();
|
||||
@NotNull private final Set<ArrangementEntryType> myTypes = EnumSet.noneOf(ArrangementEntryType.class);
|
||||
@NotNull private final Set<ArrangementModifier> myModifiers = EnumSet.noneOf(ArrangementModifier.class);
|
||||
@NotNull private final List<String> myNamePatterns = ContainerUtilRt.newArrayList();
|
||||
|
||||
private boolean nestedComposite;
|
||||
private boolean nestedComposite;
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementAtomMatchCondition condition) {
|
||||
@@ -118,16 +116,31 @@ public class StdArrangementEntryMatcher implements ArrangementEntryMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
myNamePatterns.add(condition.getPattern());
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@NotNull
|
||||
public ArrangementEntryMatcher getMatcher() {
|
||||
ByTypeArrangementEntryMatcher byType = myTypes.isEmpty() ? null : new ByTypeArrangementEntryMatcher(myTypes);
|
||||
ByModifierArrangementEntryMatcher byModifiers = myModifiers.isEmpty() ? null : new ByModifierArrangementEntryMatcher(myModifiers);
|
||||
if (byType == null && byModifiers == null && myMatchers.isEmpty()) {
|
||||
ByNameArrangementEntryMatcher byName = myNamePatterns.size() != 1 ? null : new ByNameArrangementEntryMatcher(myNamePatterns.get(0));
|
||||
int i = countNonNulls(byType, byModifiers, byName);
|
||||
if (i == 0 && myMatchers.isEmpty()) {
|
||||
return ArrangementEntryMatcher.EMPTY;
|
||||
}
|
||||
if (myMatchers.isEmpty() && (byType == null ^ byModifiers == null)) {
|
||||
return byModifiers == null ? byType : byModifiers;
|
||||
if (myMatchers.isEmpty() && i == 1) {
|
||||
if (byType != null) {
|
||||
return byType;
|
||||
}
|
||||
else if (byModifiers != null) {
|
||||
return byModifiers;
|
||||
}
|
||||
else {
|
||||
return byName;
|
||||
}
|
||||
}
|
||||
else if (myMatchers.size() == 1) {
|
||||
return myMatchers.get(0);
|
||||
@@ -143,8 +156,21 @@ public class StdArrangementEntryMatcher implements ArrangementEntryMatcher {
|
||||
if (byModifiers != null) {
|
||||
result.addMatcher(byModifiers);
|
||||
}
|
||||
if (byName != null) {
|
||||
result.addMatcher(byName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static int countNonNulls(Object... data) {
|
||||
int result = 0;
|
||||
for (Object o : data) {
|
||||
if (o != null) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -52,10 +52,6 @@ public class ArrangementAtomMatchCondition implements ArrangementMatchCondition
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return myInverted;
|
||||
}
|
||||
|
||||
public void setInverted(boolean inverted) {
|
||||
myInverted = inverted;
|
||||
}
|
||||
|
||||
+2
@@ -26,4 +26,6 @@ public interface ArrangementMatchConditionVisitor {
|
||||
void visit(@NotNull ArrangementAtomMatchCondition condition);
|
||||
|
||||
void visit(@NotNull ArrangementCompositeMatchCondition condition);
|
||||
|
||||
void visit(@NotNull ArrangementNameMatchCondition condition);
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.arrangement.NameAwareArrangementEntry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Condition which works on {@link NameAwareArrangementEntry}
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/14/12 12:18 PM
|
||||
*/
|
||||
public class ArrangementNameMatchCondition implements ArrangementMatchCondition {
|
||||
|
||||
@NotNull private final String myPattern;
|
||||
|
||||
public ArrangementNameMatchCondition(@NotNull String pattern) {
|
||||
myPattern = pattern;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPattern() {
|
||||
return myPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invite(@NotNull ArrangementMatchConditionVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrangementMatchCondition clone() {
|
||||
return new ArrangementNameMatchCondition(myPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myPattern.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ArrangementNameMatchCondition condition = (ArrangementNameMatchCondition)o;
|
||||
return myPattern.equals(condition.myPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("name like '%s'", StringUtil.escapeStringCharacters(myPattern));
|
||||
}
|
||||
}
|
||||
+16
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementNameMatchCondition;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
@@ -106,6 +107,21 @@ public class DefaultArrangementEntryMatcherSerializerTest {
|
||||
checkElements(element, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameConditionOnly() {
|
||||
ArrangementNameMatchCondition condition = new ArrangementNameMatchCondition("get*");
|
||||
doTest(condition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compositeConditionWithName() {
|
||||
ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition();
|
||||
condition.addOperand(new ArrangementAtomMatchCondition(TYPE, METHOD));
|
||||
condition.addOperand(new ArrangementAtomMatchCondition(MODIFIER, SYNCHRONIZED));
|
||||
condition.addOperand(new ArrangementNameMatchCondition("get*"));
|
||||
doTest(condition);
|
||||
}
|
||||
|
||||
private static void checkElements(@NotNull Element expected, @NotNull Element actual) {
|
||||
assertTrue(
|
||||
String.format("Tag name mismatch - expected: '%s', actual: '%s'", expected.getName(), actual.getName()),
|
||||
|
||||
+11
-13
@@ -20,10 +20,7 @@ import com.intellij.application.options.codeStyle.arrangement.ArrangementConstan
|
||||
import com.intellij.application.options.codeStyle.arrangement.ArrangementNodeDisplayManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.*;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -61,16 +58,11 @@ public class ArrangementAndMatchConditionComponent extends JPanel implements Arr
|
||||
setOpaque(false);
|
||||
setLayout(new GridBagLayout());
|
||||
final Map<Object, ArrangementMatchCondition> operands = new HashMap<Object, ArrangementMatchCondition>();
|
||||
final List<ArrangementNameMatchCondition> nameConditions = new ArrayList<ArrangementNameMatchCondition>();
|
||||
ArrangementMatchConditionVisitor visitor = new ArrangementMatchConditionVisitor() {
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementAtomMatchCondition condition) {
|
||||
operands.put(condition.getValue(), condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
|
||||
operands.put(condition, condition);
|
||||
}
|
||||
@Override public void visit(@NotNull ArrangementAtomMatchCondition condition) { operands.put(condition.getValue(), condition); }
|
||||
@Override public void visit(@NotNull ArrangementCompositeMatchCondition condition) { operands.put(condition, condition); }
|
||||
@Override public void visit(@NotNull ArrangementNameMatchCondition condition) { nameConditions.add(condition); }
|
||||
};
|
||||
for (ArrangementMatchCondition operand : setting.getOperands()) {
|
||||
operand.invite(visitor);
|
||||
@@ -86,6 +78,12 @@ public class ArrangementAndMatchConditionComponent extends JPanel implements Arr
|
||||
JComponent uiComponent = component.getUiComponent();
|
||||
add(uiComponent, constraints);
|
||||
}
|
||||
for (ArrangementNameMatchCondition condition : nameConditions) {
|
||||
ArrangementMatchConditionComponent component = factory.getComponent(condition, rule, true);
|
||||
myComponents.add(component);
|
||||
JComponent uiComponent = component.getUiComponent();
|
||||
add(uiComponent, constraints);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
-4
@@ -24,10 +24,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.*;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -83,6 +80,11 @@ public class ArrangementMatchNodeComponentFactory {
|
||||
public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
|
||||
ref.set(new ArrangementAndMatchConditionComponent(rule, condition, ArrangementMatchNodeComponentFactory.this, myDisplayManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(@NotNull ArrangementNameMatchCondition condition) {
|
||||
ref.set(new ArrangementNameConditionComponent(condition));
|
||||
}
|
||||
});
|
||||
return ref.get();
|
||||
}
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.application.options.codeStyle.arrangement.match;
|
||||
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementNameMatchCondition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/14/12 12:24 PM
|
||||
*/
|
||||
public class ArrangementNameConditionComponent implements ArrangementMatchConditionComponent {
|
||||
|
||||
@NotNull private final ArrangementNameMatchCondition myCondition;
|
||||
|
||||
public ArrangementNameConditionComponent(@NotNull ArrangementNameMatchCondition condition) {
|
||||
myCondition = condition;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrangementMatchCondition getMatchCondition() {
|
||||
return myCondition;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getUiComponent() {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle getScreenBounds() {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
// TODO den implement
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle onMouseMove(@NotNull MouseEvent event) {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseRelease(@NotNull MouseEvent event) {
|
||||
// TODO den implement
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle onMouseExited() {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Rectangle onMouseEntered(@NotNull MouseEvent e) {
|
||||
// TODO den implement
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -217,7 +217,7 @@ public class ArrangementEngine {
|
||||
}
|
||||
else {
|
||||
if (dependencies.size() == 1 && dependencies.get(0) == entry.getParent()) {
|
||||
// Handle a situation when the entry is condifured to be at the first parent's children.
|
||||
// Handle a situation when the entry is configured to be at the first parent's children.
|
||||
arranged.add(entry);
|
||||
}
|
||||
else {
|
||||
|
||||
+18
-5
@@ -29,6 +29,7 @@ import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition
|
||||
import com.intellij.psi.codeStyle.arrangement.model.ArrangementNameMatchCondition
|
||||
import com.intellij.psi.codeStyle.arrangement.order.ArrangementEntryOrderType
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
|
||||
import org.jetbrains.annotations.NotNull
|
||||
@@ -59,17 +60,29 @@ abstract class AbstractRearrangerTest extends LightPlatformCodeInsightFixtureTes
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ArrangementGroupingRule group(@NotNull ArrangementGroupingType type) {
|
||||
protected static ArrangementGroupingRule group(@NotNull ArrangementGroupingType type) {
|
||||
group(type, ArrangementEntryOrderType.KEEP)
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ArrangementGroupingRule group(@NotNull ArrangementGroupingType type, @NotNull ArrangementEntryOrderType order) {
|
||||
protected static ArrangementGroupingRule group(@NotNull ArrangementGroupingType type, @NotNull ArrangementEntryOrderType order) {
|
||||
new ArrangementGroupingRule(type, order)
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
protected StdArrangementMatchRule rule(@NotNull Object ... conditions) {
|
||||
protected static StdArrangementMatchRule rule(@NotNull String name) {
|
||||
new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementNameMatchCondition(name)))
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static StdArrangementMatchRule rule(@NotNull String name, Object ... conditions) {
|
||||
def c = conditions.collect { atom(it) }
|
||||
c << new ArrangementNameMatchCondition(name)
|
||||
new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(c as ArrangementMatchCondition[])))
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static StdArrangementMatchRule rule(@NotNull Object ... conditions) {
|
||||
def condition
|
||||
if (conditions.length == 1) {
|
||||
condition = atom(conditions[0])
|
||||
@@ -82,7 +95,7 @@ abstract class AbstractRearrangerTest extends LightPlatformCodeInsightFixtureTes
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ArrangementAtomMatchCondition atom(@NotNull Object condition) {
|
||||
protected static ArrangementAtomMatchCondition atom(@NotNull Object condition) {
|
||||
new ArrangementAtomMatchCondition(ArrangementUtil.parseType(condition), condition)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user