mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-85100 Deleting wrapped lines with Ctrl+Y doen't work properly with "soft wrapped" lines
More tests have been checked and added
This commit is contained in:
@@ -113,9 +113,9 @@ public class ClassEntry extends ClassContentsEntry implements FilePopupEntry {
|
||||
return new JLabel(myName);
|
||||
}
|
||||
|
||||
protected void parseRemainingClassContents(final Project project,
|
||||
protected void parseRemainingClassContents(@NotNull final Project project,
|
||||
int startingIndex,
|
||||
final PsiElement psiClass
|
||||
@NotNull final PsiElement psiClass
|
||||
) {
|
||||
final PsiSearchHelper psh = PsiSearchHelper.SERVICE.getInstance(project);
|
||||
int lastIndex = startingIndex;
|
||||
|
||||
@@ -186,13 +186,11 @@ abstract public class RangeEntry implements PopupTreeRangeEntry {
|
||||
// -------------------------- OTHER METHODS --------------------------
|
||||
|
||||
public void checkForComment() {
|
||||
if (CommentUtil.getCommentMatchers().size() == 0) {
|
||||
if (CommentUtil.getCommentMatchers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
createAlternateValueString();
|
||||
/**
|
||||
* for each separator comment specified by the user, check to see if this comment matches.
|
||||
*/
|
||||
// For each separator comment specified by the user, check to see if this comment matches.
|
||||
for (Matcher matcher : CommentUtil.getCommentMatchers()) {
|
||||
matcher.reset(myAlternateValue);
|
||||
boolean foundMatch = matcher.find();
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class CommentRuleInstance implements RuleInstance, FilePopupEntr
|
||||
}
|
||||
|
||||
/**
|
||||
* beginning at the index of ruleStatistics (which is a comment entry), find nRules in the direction indicated,
|
||||
* Beginning at the index of ruleStatistics (which is a comment entry), find nRules in the direction indicated,
|
||||
* and test to see if all or any of them had entries that matched.
|
||||
*
|
||||
* @param nRules number of rules to consider for matching algorithm.
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class PrecedingCommentRuleInstance extends CommentRuleInstance {
|
||||
public void determineEmit(List<RuleInstance> resultRuleInstances, int startIndex) {
|
||||
if (match(
|
||||
resultRuleInstances,
|
||||
myCommentRule.getnPrecedingRulesToMatch(),
|
||||
myCommentRule.getNPrecedingRulesToMatch(),
|
||||
-1,
|
||||
startIndex,
|
||||
myCommentRule.isAllPrecedingRules()))
|
||||
|
||||
+2
-4
@@ -26,9 +26,7 @@ import com.wrq.rearranger.settings.CommentRule;
|
||||
import java.util.List;
|
||||
|
||||
/** Used to store a generated comment which is emitted based on whether it matches subsequent rules. */
|
||||
public class SubsequentCommentRuleInstance
|
||||
extends CommentRuleInstance
|
||||
{
|
||||
public class SubsequentCommentRuleInstance extends CommentRuleInstance {
|
||||
|
||||
public SubsequentCommentRuleInstance(final CommentRule commentRule) {
|
||||
super(commentRule);
|
||||
@@ -38,7 +36,7 @@ public class SubsequentCommentRuleInstance
|
||||
public void determineEmit(List<RuleInstance> resultRuleInstances, int startIndex) {
|
||||
if (match(
|
||||
resultRuleInstances,
|
||||
myCommentRule.getnSubsequentRulesToMatch(),
|
||||
myCommentRule.getNSubsequentRulesToMatch(),
|
||||
+1,
|
||||
startIndex,
|
||||
myCommentRule.isAllSubsequentRules()
|
||||
|
||||
+2
-2
@@ -38,14 +38,14 @@ public class SurroundingCommentRuleInstance
|
||||
public void determineEmit(List<RuleInstance> resultRuleInstances, int startIndex) {
|
||||
if (match(
|
||||
resultRuleInstances,
|
||||
myCommentRule.getnPrecedingRulesToMatch(),
|
||||
myCommentRule.getNPrecedingRulesToMatch(),
|
||||
-1,
|
||||
startIndex,
|
||||
myCommentRule.isAllPrecedingRules()
|
||||
) &&
|
||||
match(
|
||||
resultRuleInstances,
|
||||
myCommentRule.getnSubsequentRulesToMatch(),
|
||||
myCommentRule.getNSubsequentRulesToMatch(),
|
||||
+1,
|
||||
startIndex,
|
||||
myCommentRule.isAllSubsequentRules()
|
||||
|
||||
@@ -88,26 +88,26 @@ public final class CommentRule
|
||||
this.emitCondition = emitCondition;
|
||||
}
|
||||
|
||||
private int nPrecedingRulesToMatch; // default 1
|
||||
private int nSubsequentRulesToMatch; // default 1
|
||||
private boolean allPrecedingRules; // if false, ANY preceding rules
|
||||
private int myNPrecedingRulesToMatch; // default 1
|
||||
private int myNSubsequentRulesToMatch; // default 1
|
||||
private boolean myAllPrecedingRules; // if false, ANY preceding rules
|
||||
|
||||
public final boolean isAllPrecedingRules() {
|
||||
return allPrecedingRules;
|
||||
return myAllPrecedingRules;
|
||||
}
|
||||
|
||||
public final void setAllPrecedingRules(final boolean allPrecedingRules) {
|
||||
this.allPrecedingRules = allPrecedingRules;
|
||||
this.myAllPrecedingRules = allPrecedingRules;
|
||||
}
|
||||
|
||||
private boolean allSubsequentRules; // if false, ANY subsequent rules
|
||||
private boolean myAllSubsequentRules; // if false, ANY subsequent rules
|
||||
|
||||
public final boolean isAllSubsequentRules() {
|
||||
return allSubsequentRules;
|
||||
return myAllSubsequentRules;
|
||||
}
|
||||
|
||||
public final void setAllSubsequentRules(final boolean allSubsequentRules) {
|
||||
this.allSubsequentRules = allSubsequentRules;
|
||||
this.myAllSubsequentRules = allSubsequentRules;
|
||||
}
|
||||
|
||||
private CommentFillString commentFillString;
|
||||
@@ -140,10 +140,10 @@ public final class CommentRule
|
||||
result.commentText = unescape(text);
|
||||
}
|
||||
result.emitCondition = RearrangerSettings.getIntAttribute(item, "condition", 0);
|
||||
result.nPrecedingRulesToMatch = RearrangerSettings.getIntAttribute(item, "nPrecedingRulesToMatch", 1);
|
||||
result.nSubsequentRulesToMatch = RearrangerSettings.getIntAttribute(item, "nSubsequentRulesToMatch", 1);
|
||||
result.allPrecedingRules = RearrangerSettings.getBooleanAttribute(item, "allPrecedingRules", true);
|
||||
result.allSubsequentRules = RearrangerSettings.getBooleanAttribute(item, "allSubsequentRules", true);
|
||||
result.myNPrecedingRulesToMatch = RearrangerSettings.getIntAttribute(item, "nPrecedingRulesToMatch", 1);
|
||||
result.myNSubsequentRulesToMatch = RearrangerSettings.getIntAttribute(item, "nSubsequentRulesToMatch", 1);
|
||||
result.myAllPrecedingRules = RearrangerSettings.getBooleanAttribute(item, "allPrecedingRules", true);
|
||||
result.myAllSubsequentRules = RearrangerSettings.getBooleanAttribute(item, "allSubsequentRules", true);
|
||||
result.commentFillString = CommentFillString.readExternal(item);
|
||||
return result;
|
||||
}
|
||||
@@ -201,10 +201,10 @@ public final class CommentRule
|
||||
public CommentRule() {
|
||||
commentText = "";
|
||||
emitCondition = EMIT_ALWAYS;
|
||||
nPrecedingRulesToMatch = 1;
|
||||
nSubsequentRulesToMatch = 1;
|
||||
allPrecedingRules = true;
|
||||
allSubsequentRules = true;
|
||||
myNPrecedingRulesToMatch = 1;
|
||||
myNSubsequentRulesToMatch = 1;
|
||||
myAllPrecedingRules = true;
|
||||
myAllSubsequentRules = true;
|
||||
commentFillString = new CommentFillString();
|
||||
}
|
||||
|
||||
@@ -353,15 +353,15 @@ public final class CommentRule
|
||||
}
|
||||
|
||||
private String precedingRuleString() {
|
||||
return (nPrecedingRulesToMatch == 1) ? "preceding rule is matched" :
|
||||
(allPrecedingRules ? "all" : "any") +
|
||||
" of preceding " + (nPrecedingRulesToMatch) + " rules are matched";
|
||||
return (myNPrecedingRulesToMatch == 1) ? "preceding rule is matched" :
|
||||
(myAllPrecedingRules ? "all" : "any") +
|
||||
" of preceding " + (myNPrecedingRulesToMatch) + " rules are matched";
|
||||
}
|
||||
|
||||
private String subsequentRuleString() {
|
||||
return (nSubsequentRulesToMatch == 1) ? "subsequent rule is matched" :
|
||||
(allSubsequentRules ? "all" : "any") +
|
||||
" of subsequent " + (nSubsequentRulesToMatch) + " rules are matched";
|
||||
return (myNSubsequentRulesToMatch == 1) ? "subsequent rule is matched" :
|
||||
(myAllSubsequentRules ? "all" : "any") +
|
||||
" of subsequent " + (myNSubsequentRulesToMatch) + " rules are matched";
|
||||
}
|
||||
|
||||
public final String getExpandedCommentText() {
|
||||
@@ -388,12 +388,12 @@ public final class CommentRule
|
||||
throw new UnsupportedOperationException("CommentRule.isAlphabetize() not implemented");
|
||||
}
|
||||
|
||||
public final void setnPrecedingRulesToMatch(final int nPrecedingRulesToMatch) {
|
||||
this.nPrecedingRulesToMatch = nPrecedingRulesToMatch;
|
||||
public final void setNPrecedingRulesToMatch(final int nPrecedingRulesToMatch) {
|
||||
this.myNPrecedingRulesToMatch = nPrecedingRulesToMatch;
|
||||
}
|
||||
|
||||
public final void setnSubsequentRulesToMatch(final int nSubsequentRulesToMatch) {
|
||||
this.nSubsequentRulesToMatch = nSubsequentRulesToMatch;
|
||||
public final void setNSubsequentRulesToMatch(final int nSubsequentRulesToMatch) {
|
||||
this.myNSubsequentRulesToMatch = nSubsequentRulesToMatch;
|
||||
}
|
||||
|
||||
// ------------------------------------------------- CANONICAL METHODS -------------------------------------------------
|
||||
@@ -403,10 +403,10 @@ public final class CommentRule
|
||||
final CommentRule c = (CommentRule)object;
|
||||
return commentText.equals(c.commentText) &&
|
||||
emitCondition == c.emitCondition &&
|
||||
nPrecedingRulesToMatch == c.nPrecedingRulesToMatch &&
|
||||
nSubsequentRulesToMatch == c.nSubsequentRulesToMatch &&
|
||||
allPrecedingRules == c.allPrecedingRules &&
|
||||
allSubsequentRules == c.allSubsequentRules &&
|
||||
myNPrecedingRulesToMatch == c.myNPrecedingRulesToMatch &&
|
||||
myNSubsequentRulesToMatch == c.myNSubsequentRulesToMatch &&
|
||||
myAllPrecedingRules == c.myAllPrecedingRules &&
|
||||
myAllSubsequentRules == c.myAllSubsequentRules &&
|
||||
commentFillString.equals(c.commentFillString);
|
||||
}
|
||||
|
||||
@@ -423,10 +423,10 @@ public final class CommentRule
|
||||
final CommentRule comment = new CommentRule();
|
||||
comment.commentText = commentText;
|
||||
comment.emitCondition = emitCondition;
|
||||
comment.nPrecedingRulesToMatch = nPrecedingRulesToMatch;
|
||||
comment.nSubsequentRulesToMatch = nSubsequentRulesToMatch;
|
||||
comment.allPrecedingRules = allPrecedingRules;
|
||||
comment.allSubsequentRules = allSubsequentRules;
|
||||
comment.myNPrecedingRulesToMatch = myNPrecedingRulesToMatch;
|
||||
comment.myNSubsequentRulesToMatch = myNSubsequentRulesToMatch;
|
||||
comment.myAllPrecedingRules = myAllPrecedingRules;
|
||||
comment.myAllSubsequentRules = myAllSubsequentRules;
|
||||
comment.commentFillString = commentFillString.deepCopy();
|
||||
return comment;
|
||||
}
|
||||
@@ -435,10 +435,10 @@ public final class CommentRule
|
||||
final Element me = new Element("Comment");
|
||||
me.setText(escape(commentText));
|
||||
me.setAttribute("condition", "" + emitCondition);
|
||||
me.setAttribute("nPrecedingRulesToMatch", "" + nPrecedingRulesToMatch);
|
||||
me.setAttribute("nSubsequentRulesToMatch", "" + nSubsequentRulesToMatch);
|
||||
me.setAttribute("allPrecedingRules", "" + allPrecedingRules);
|
||||
me.setAttribute("allSubsequentRules", "" + allSubsequentRules);
|
||||
me.setAttribute("nPrecedingRulesToMatch", "" + myNPrecedingRulesToMatch);
|
||||
me.setAttribute("nSubsequentRulesToMatch", "" + myNSubsequentRulesToMatch);
|
||||
me.setAttribute("allPrecedingRules", "" + myAllPrecedingRules);
|
||||
me.setAttribute("allSubsequentRules", "" + myAllSubsequentRules);
|
||||
commentFillString.writeExternal(me);
|
||||
parent.getChildren().add(me);
|
||||
}
|
||||
@@ -496,12 +496,12 @@ public final class CommentRule
|
||||
|
||||
// --------------------------------------------------- OTHER METHODS ---------------------------------------------------
|
||||
|
||||
public int getnPrecedingRulesToMatch() {
|
||||
return nPrecedingRulesToMatch;
|
||||
public int getNPrecedingRulesToMatch() {
|
||||
return myNPrecedingRulesToMatch;
|
||||
}
|
||||
|
||||
public final int getnSubsequentRulesToMatch() {
|
||||
return nSubsequentRulesToMatch;
|
||||
public final int getNSubsequentRulesToMatch() {
|
||||
return myNSubsequentRulesToMatch;
|
||||
}
|
||||
|
||||
// --------------------------------------------------- INNER CLASSES ---------------------------------------------------
|
||||
@@ -527,8 +527,8 @@ public final class CommentRule
|
||||
anyAllCheckbox = new JCheckBox("items match");
|
||||
anyAllCheckbox.setSelected((emitCondition & (preceding ? 1 : 2)) > 0);
|
||||
anyAllComboBox = new JComboBox(new String[]{"any", "all"});
|
||||
anyAllComboBox.setSelectedIndex(preceding ? (allPrecedingRules ? 1 : 0)
|
||||
: (allSubsequentRules ? 1 : 0));
|
||||
anyAllComboBox.setSelectedIndex(preceding ? (myAllPrecedingRules ? 1 : 0)
|
||||
: (myAllSubsequentRules ? 1 : 0));
|
||||
Dimension d = anyAllComboBox.getPreferredSize();
|
||||
d.width += 3; // make room for "any", if "all" is narrower and is first selection.
|
||||
anyAllComboBox.setPreferredSize(d);
|
||||
@@ -546,7 +546,7 @@ public final class CommentRule
|
||||
d = anyAllPrevNumber.getPreferredSize();
|
||||
d.width += 3;
|
||||
anyAllPrevNumber.setPreferredSize(d);
|
||||
anyAllPrevNumber.setValue(preceding ? nPrecedingRulesToMatch : nSubsequentRulesToMatch);
|
||||
anyAllPrevNumber.setValue(preceding ? myNPrecedingRulesToMatch : myNSubsequentRulesToMatch);
|
||||
anyAllPrevNumber.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
|
||||
rulesLabel = new JLabel("rules");
|
||||
constraints.insets = new Insets(0, 10, 0, 0);
|
||||
@@ -580,10 +580,10 @@ public final class CommentRule
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final int s = anyAllComboBox.getSelectedIndex();
|
||||
if (preceding) {
|
||||
allPrecedingRules = (s == 1);
|
||||
myAllPrecedingRules = (s == 1);
|
||||
}
|
||||
else {
|
||||
allSubsequentRules = (s == 1);
|
||||
myAllSubsequentRules = (s == 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -595,10 +595,10 @@ public final class CommentRule
|
||||
anyAllPrevNumber.setValue(n);
|
||||
}
|
||||
if (preceding) {
|
||||
nPrecedingRulesToMatch = n;
|
||||
myNPrecedingRulesToMatch = n;
|
||||
}
|
||||
else {
|
||||
nSubsequentRulesToMatch = n;
|
||||
myNSubsequentRulesToMatch = n;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
@@ -585,7 +586,11 @@ public final class RearrangerSettings {
|
||||
|
||||
// -------------------------- OTHER METHODS --------------------------
|
||||
|
||||
public final void addClass(final AttributeGroup ca, final int index) {
|
||||
public void addClass(@NotNull AttributeGroup group) {
|
||||
myClassOrderAttributeList.add(group);
|
||||
}
|
||||
|
||||
public final void insertClass(@NotNull final AttributeGroup ca, final int index) {
|
||||
if (myClassOrderAttributeList.size() < index) {
|
||||
myClassOrderAttributeList.add(ca);
|
||||
}
|
||||
@@ -594,7 +599,11 @@ public final class RearrangerSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public final void addItem(final AttributeGroup ia, final int index) {
|
||||
public void addItem(@NotNull AttributeGroup group) {
|
||||
myItemOrderAttributeList.add(group);
|
||||
}
|
||||
|
||||
public final void insertItem(@NotNull final AttributeGroup ia, final int index) {
|
||||
if (myItemOrderAttributeList.size() < index) {
|
||||
myItemOrderAttributeList.add(ia);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest', 'RearrangementResult2') {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.protectionLevelAttributes.plPublic = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.protectionLevelAttributes.plPublic = true
|
||||
attributes.protectionLevelAttributes.invertProtectionLevel = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
attributes.protectionLevelAttributes.plPackage = true
|
||||
attributes.protectionLevelAttributes.plPublic = true
|
||||
attributes.constructorMethodType = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest', 'RearrangementResult5') {
|
||||
def attributes = new ClassAttributes()
|
||||
attributes.protectionLevelAttributes.plPackage = true
|
||||
mySettings.addClass(attributes, 0)
|
||||
mySettings.addClass(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.finalAttribute.value = true
|
||||
attributes.staticAttribute.value = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest7', 'RearrangementResult7') {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.initialisedByAnonymousClassAttr.value = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
def fieldAttributes = new FieldAttributes()
|
||||
fieldAttributes.nameAttribute.match = true
|
||||
fieldAttributes.nameAttribute.expression = '.*5'
|
||||
mySettings.addItem(fieldAttributes, 0)
|
||||
mySettings.addItem(fieldAttributes)
|
||||
|
||||
def methodAttributes = new MethodAttributes()
|
||||
methodAttributes.nameAttribute.match = true
|
||||
methodAttributes.nameAttribute.expression = '.*2'
|
||||
mySettings.addItem(methodAttributes, 1)
|
||||
mySettings.addItem(methodAttributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest8', 'RearrangementResult8A') {
|
||||
def methodAttributes = new MethodAttributes()
|
||||
methodAttributes.staticAttribute.value = true
|
||||
mySettings.addItem(methodAttributes, 0)
|
||||
mySettings.addItem(methodAttributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
attributes.otherMethodType = true
|
||||
attributes.constructorMethodType = false
|
||||
attributes.sortOptions.byName = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
mySettings.keepGettersSettersTogether = false
|
||||
}
|
||||
}
|
||||
@@ -147,89 +147,67 @@ class RearrangerTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest('RearrangementTest', 'RearrangementResult10') {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.protectionLevelAttributes.plPublic = true
|
||||
mySettings.addItem(attributes, 0)
|
||||
mySettings.addItem(attributes)
|
||||
|
||||
def comment = new CommentRule()
|
||||
comment.commentText = '// simple comment **********'
|
||||
comment.emitCondition = CommentRule.EMIT_IF_ITEMS_MATCH_PRECEDING_RULE
|
||||
mySettings.addItem(comment, 1)
|
||||
mySettings.addItem(comment)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete old comment and insert (identical) new one. This tests proper identification and deletion of old
|
||||
* comments.
|
||||
*
|
||||
* @throws Exception test exception
|
||||
*/
|
||||
public final void testReplayComment() throws Exception {
|
||||
doTest('RearrangementResult10', 'RearrangementResult10') {
|
||||
def attributes = new FieldAttributes()
|
||||
attributes.protectionLevelAttributes.plPublic = true
|
||||
mySettings.addItem(attributes)
|
||||
|
||||
def comment = new CommentRule()
|
||||
comment.commentText = '// simple comment **********'
|
||||
comment.emitCondition = CommentRule.EMIT_IF_ITEMS_MATCH_PRECEDING_RULE
|
||||
mySettings.addItem(comment)
|
||||
}
|
||||
}
|
||||
|
||||
public final void testMultipleRuleCommentMatch() throws Exception {
|
||||
doTest('RearrangementTest11', 'RearrangementResult11') {
|
||||
def allFieldsComment = new CommentRule()
|
||||
allFieldsComment.commentText = '// FIELDS:'
|
||||
allFieldsComment.emitCondition = CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE
|
||||
allFieldsComment.allSubsequentRules = false
|
||||
mySettings.addItem(allFieldsComment)
|
||||
|
||||
def finalFieldsComment = new CommentRule()
|
||||
finalFieldsComment.commentText = '// FINAL FIELDS:'
|
||||
finalFieldsComment.emitCondition = CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE
|
||||
finalFieldsComment.allSubsequentRules = true
|
||||
finalFieldsComment.NSubsequentRulesToMatch = 1
|
||||
mySettings.addItem(finalFieldsComment)
|
||||
|
||||
def finalFields = new FieldAttributes()
|
||||
finalFields.finalAttribute.value = true
|
||||
mySettings.addItem(finalFields)
|
||||
|
||||
def nonFinalFieldsComment = new CommentRule()
|
||||
nonFinalFieldsComment.commentText = '// NON-FINAL FIELDS:'
|
||||
nonFinalFieldsComment.emitCondition = CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE
|
||||
nonFinalFieldsComment.allSubsequentRules = true
|
||||
nonFinalFieldsComment.NSubsequentRulesToMatch = 1
|
||||
mySettings.addItem(nonFinalFieldsComment)
|
||||
|
||||
def nonFinalFields = new FieldAttributes()
|
||||
nonFinalFields.finalAttribute.value = true
|
||||
nonFinalFields.finalAttribute.invert = true
|
||||
mySettings.addItem(nonFinalFields)
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Delete old comment and insert (identical) new one. This tests proper identification and deletion of old
|
||||
// * comments.
|
||||
// *
|
||||
// * @throws Exception test exception
|
||||
// */
|
||||
// public final void testReplayComment() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementResult10.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// final FieldAttributes fa = new FieldAttributes();
|
||||
// fa.getPlAttr().setPlPublic(true);
|
||||
// rs.addItem(fa, 0);
|
||||
// final CommentRule c = new CommentRule();
|
||||
// c.setCommentText("// simple comment **********");
|
||||
// c.setEmitCondition(CommentRule.EMIT_IF_ITEMS_MATCH_PRECEDING_RULE);
|
||||
// rs.addItem(c, 1);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult10.java");
|
||||
// }
|
||||
//
|
||||
// public final void testMultipleRuleCommentMatch() throws Exception {
|
||||
// configureByFile("/com/wrq/rearranger/RearrangementTest11.java");
|
||||
// final PsiFile file = getFile();
|
||||
// final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
// CommentRule c;
|
||||
// FieldAttributes fa;
|
||||
//
|
||||
// c = new CommentRule();
|
||||
// c.setCommentText("// FIELDS:");
|
||||
// c.setEmitCondition(CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE);
|
||||
// c.setAllSubsequentRules(false);
|
||||
// c.setnSubsequentRulesToMatch(3);
|
||||
// rs.addItem(c, 0);
|
||||
//
|
||||
// c = new CommentRule();
|
||||
// c.setCommentText("// PROTECTED FIELDS:");
|
||||
// c.setEmitCondition(CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE);
|
||||
// c.setAllSubsequentRules(false);
|
||||
// c.setnSubsequentRulesToMatch(1);
|
||||
// rs.addItem(c, 1);
|
||||
//
|
||||
// fa = new FieldAttributes();
|
||||
// fa.getPlAttr().setPlProtected(true);
|
||||
// rs.addItem(fa, 2);
|
||||
//
|
||||
// c = new CommentRule();
|
||||
// c.setCommentText("// FINAL FIELDS:");
|
||||
// c.setEmitCondition(CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE);
|
||||
// c.setAllSubsequentRules(true);
|
||||
// c.setnSubsequentRulesToMatch(1);
|
||||
// rs.addItem(c, 3);
|
||||
//
|
||||
// fa = new FieldAttributes();
|
||||
// fa.getfAttr().setValue(true);
|
||||
// rs.addItem(fa, 4);
|
||||
//
|
||||
// c = new CommentRule();
|
||||
// c.setCommentText("// NON-FINAL FIELDS:");
|
||||
// c.setEmitCondition(CommentRule.EMIT_IF_ITEMS_MATCH_SUBSEQUENT_RULE);
|
||||
// c.setAllSubsequentRules(true);
|
||||
// c.setnSubsequentRulesToMatch(1);
|
||||
// rs.addItem(c, 5);
|
||||
//
|
||||
// fa = new FieldAttributes();
|
||||
// fa.getfAttr().setValue(true);
|
||||
// fa.getfAttr().setInvert(true);
|
||||
// rs.addItem(fa, 6);
|
||||
// final RearrangerActionHandler rah = new RearrangerActionHandler();
|
||||
// rah.rearrangeDocument(getProject(), file, rs, doc);
|
||||
// super.checkResultByFile("/com/wrq/rearranger/RearrangementResult11.java");
|
||||
// }
|
||||
//
|
||||
// public final void testOpsBlockingQueueExample() throws Exception {
|
||||
// testOpsBlockingQueueExampleWorker(false, "/com/wrq/rearranger/OpsBlockingQueue.java",
|
||||
// false, "/com/wrq/rearranger/OpsBlockingQueue.java");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
public class RearrangementTest11 {
|
||||
// FIELDS:
|
||||
// FIELDS:
|
||||
// FINAL FIELDS:
|
||||
final int i;
|
||||
public final int k;
|
||||
// NON-FINAL FIELDS:
|
||||
// NON-FINAL FIELDS:
|
||||
int j;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user