mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -496,8 +496,6 @@ def layout_core(String home, String target) {
|
||||
module("core-impl")
|
||||
module("boot")
|
||||
module("extensions")
|
||||
module("indexing-api")
|
||||
module("indexing-impl")
|
||||
module("java-psi-api")
|
||||
module("java-psi-impl")
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
final String defaultCharset = EncodingManager.getInstance().getDefaultCharsetName();
|
||||
if (defaultCharset != null) {
|
||||
if (!StringUtil.isEmpty(defaultCharset)) {
|
||||
cmdBuilder.setGlobalEncoding(defaultCharset);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,14 @@ PsiJavaFile:Extension.java
|
||||
PsiParameterList:()
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiKeyword:throws('throws')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:E
|
||||
PsiIdentifier:E('E')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:default('default')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class DeclarationParserTest extends JavaParsingTestCase {
|
||||
public void testMethodNormal1() { doParserTest("{ void f(); }", false, false); }
|
||||
public void testSemicolons() { doParserTest("{ void f() {}; void g() {}; }", false, false); }
|
||||
public void testUnclosed0() { doParserTest("{ void f() }", false, false); }
|
||||
public void testExtension() { doParserTest("{ int f() default { return 42; } }", false, false); }
|
||||
public void testExtension() { doParserTest("{ int f() throws E default { return 42; } }", false, false); }
|
||||
public void testUnclosed1() { doParserTest("{ void f( }", false, false); }
|
||||
public void testUnclosed2() { doParserTest("{ void f()\n void g(); }", false, false); }
|
||||
public void testUnclosed3() { doParserTest("{ void f(int a }", false, false); }
|
||||
|
||||
@@ -477,7 +477,7 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
final String loadPath = isDirectoryBased(projectFile) ? new File(projectFile, IDEA_PROJECT_DIRNAME).getPath() : projectPath;
|
||||
IdeaProjectLoader.loadFromPath(project, loadPath, myPathVars, null, new SystemOutErrorReporter(false));
|
||||
final String globalEncoding = myGlobalEncoding;
|
||||
if (globalEncoding != null && project.getProjectCharset() == null) {
|
||||
if (!StringUtil.isEmpty(globalEncoding) && project.getProjectCharset() == null) {
|
||||
project.setProjectCharset(globalEncoding);
|
||||
}
|
||||
project.getIgnoredFilePatterns().loadFromString(myIgnorePatterns);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16
-6
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.formatting;
|
||||
|
||||
import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -85,12 +87,20 @@ public abstract class AbstractBlockAlignmentProcessor implements BlockAlignmentP
|
||||
// alignment of blocks located before them and post error every time we detect endless cycle.
|
||||
Set<LeafBlockWrapper> blocksCausedRealignment = context.backwardShiftedAlignedBlocks.get(offsetResponsibleBlock);
|
||||
if (blocksCausedRealignment != null && blocksCausedRealignment.contains(context.targetBlock)) {
|
||||
LOG.error(String.format("Please create dedicated ticket at the tracker with the content of the current editor attached%n%n"
|
||||
+ "Formatting error - code block %s is set to be shifted right because of its alignment with "
|
||||
+ "block %s more than once. I.e. moving the former block because of alignment algorithm causes "
|
||||
+ "subsequent block to be shifted right as well - cyclic dependency.%nDebug info: %s",
|
||||
offsetResponsibleBlock.getTextRange(), context.targetBlock.getTextRange(), context.targetBlock.getDebugInfo()
|
||||
));
|
||||
StringBuilder messageBuilder = new StringBuilder();
|
||||
TextRange targetRange = context.targetBlock.getTextRange();
|
||||
messageBuilder.append(
|
||||
String.format("Formatting error - code block %s is set to be shifted right because of its alignment with "
|
||||
+ "block %s more than once. I.e. moving the former block because of alignment algorithm causes "
|
||||
+ "subsequent block to be shifted right as well - cyclic dependency.",
|
||||
offsetResponsibleBlock.getTextRange(), targetRange
|
||||
));
|
||||
messageBuilder.append(context.targetBlock.getDebugInfo());
|
||||
messageBuilder.append("\nBlock content: '")
|
||||
.append(context.document.getText().substring(targetRange.getStartOffset(), targetRange.getEndOffset()))
|
||||
.append("'\n");
|
||||
messageBuilder.append("Note: document text is attached to this report.");
|
||||
LogMessageEx.error(LOG, messageBuilder.toString(), context.document.getText());
|
||||
blocksCausedRealignment.add(context.targetBlock);
|
||||
return Result.UNABLE_TO_ALIGN_BACKWARD_BLOCK;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.SyntheticElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
@@ -57,4 +59,9 @@ public class RenameElementAction extends BaseRefactoringAction {
|
||||
protected boolean isAvailableForLanguage(Language language) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
|
||||
return getHandler(context) != null;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -148,7 +148,7 @@ public abstract class CallerChooserBase<M extends PsiElement> extends DialogWrap
|
||||
});
|
||||
|
||||
final M caller = node.getMethod();
|
||||
final M callee = parentNode != null ? parentNode.getMethod() : null;
|
||||
final PsiElement callee = parentNode != null ? parentNode.getElementToSearch() : null;
|
||||
if (caller != null && caller.isPhysical() && callee != null) {
|
||||
HighlightManager highlighter = HighlightManager.getInstance(myProject);
|
||||
EditorColorsManager colorManager = EditorColorsManager.getInstance();
|
||||
@@ -161,7 +161,7 @@ public abstract class CallerChooserBase<M extends PsiElement> extends DialogWrap
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<PsiElement> findElementsToHighlight(M caller, M callee) {
|
||||
protected Collection<PsiElement> findElementsToHighlight(M caller, PsiElement callee) {
|
||||
Query<PsiReference> references = ReferencesSearch.search(callee, new LocalSearchScope(caller), false);
|
||||
return ContainerUtil.mapNotNull(references, new Function<PsiReference, PsiElement>() {
|
||||
@Override
|
||||
|
||||
@@ -115,4 +115,9 @@ public abstract class MethodNodeBase<M extends PsiElement> extends CheckedTreeNo
|
||||
public M getMethod() {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
public PsiElement getElementToSearch() {
|
||||
return getMethod();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -86,7 +86,8 @@ public final class RequestFocusInEditorComponentCmd extends FinalizableCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner instanceof IdeFrameImpl && IdeFrameImpl.getActiveFrame() != owner) {
|
||||
final Window activeFrame = IdeFrameImpl.getActiveFrame();
|
||||
if (activeFrame != null && owner instanceof IdeFrameImpl && activeFrame != owner) {
|
||||
myDoneCallback.setRejected();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ replace.switch.with.if.intention.name=Replace 'switch' with 'if'
|
||||
replace.switch.with.if.intention.family.name=Replace Switch with If
|
||||
simplify.variable.intention.name=Replace with Java-style array declaration
|
||||
simplify.variable.intention.family.name=Replace with Java Style Array Declaration
|
||||
constant.expression.intention.name=Compute constant value
|
||||
constant.expression.intention.family.name=Compute Constant Value
|
||||
create.assert.intention.name=Create JUnit Assertion
|
||||
create.assert.intention.family.name=Create JUnit Assertion
|
||||
@@ -176,7 +175,7 @@ add.braces.intention.name=Add Braces to ''{0}'' statement
|
||||
remove.braces.intention.name=Remove braces from ''{0}'' statement
|
||||
flip.commutative.method.call.intention.name=Flip ''.{0}()''
|
||||
flip.commutative.method.call.intention.name1=Flip ''.{0}()'' (may change semantics)
|
||||
constant.subexpression.intention.name=Compute constant value of ''{0}''
|
||||
constant.expression.intention.name=Compute constant value of ''{0}''
|
||||
status.bar.escape.highlighting.message=Press Escape to remove the highlighting
|
||||
1.fully.qualified.name.status.bar.escape.highlighting.message=1 fully qualified name replaced with import (press Escape to remove highlighting)
|
||||
multiple.fully.qualified.names.status.bar.escape.highlighting.message={0} fully qualified names replaced with import (press Escape to remove highlighting)
|
||||
|
||||
+18
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* 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,24 @@
|
||||
package com.siyeh.ipp.constant;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ipp.base.Intention;
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.base.MutablyNamedIntention;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
import com.siyeh.ipp.psiutils.ExpressionUtils;
|
||||
import com.siyeh.ipp.psiutils.HighlightUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConstantExpressionIntention extends Intention {
|
||||
public class ConstantExpressionIntention extends MutablyNamedIntention {
|
||||
|
||||
@Override
|
||||
protected String getTextForElement(PsiElement element) {
|
||||
final String text = HighlightUtil.getPresentableText(element);
|
||||
return IntentionPowerPackBundle.message("constant.expression.intention.name", text);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -33,22 +42,16 @@ public class ConstantExpressionIntention extends Intention {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIntention(PsiElement element)
|
||||
throws IncorrectOperationException {
|
||||
final PsiExpression expression =
|
||||
(PsiExpression)element;
|
||||
final Object value =
|
||||
ExpressionUtils.computeConstantExpression(expression);
|
||||
public void processIntention(PsiElement element) throws IncorrectOperationException {
|
||||
final PsiExpression expression = (PsiExpression)element;
|
||||
final Object value = ExpressionUtils.computeConstantExpression(expression);
|
||||
@NonNls final String newExpression;
|
||||
if (value instanceof String) {
|
||||
final String string = (String)value;
|
||||
newExpression =
|
||||
'"' + StringUtil.escapeStringCharacters(string) + '"';
|
||||
newExpression = '"' + StringUtil.escapeStringCharacters(string) + '"';
|
||||
}
|
||||
else if (value instanceof Character) {
|
||||
newExpression =
|
||||
'\'' + StringUtil.escapeStringCharacters(value.toString()) +
|
||||
'\'';
|
||||
newExpression = '\'' + StringUtil.escapeStringCharacters(value.toString()) + '\'';
|
||||
}
|
||||
else if (value instanceof Long) {
|
||||
newExpression = value.toString() + 'L';
|
||||
|
||||
+20
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,28 +24,35 @@ import com.siyeh.ipp.psiutils.ExpressionUtils;
|
||||
class ConstantExpressionPredicate implements PsiElementPredicate {
|
||||
|
||||
public boolean satisfiedBy(PsiElement element) {
|
||||
if (!(element instanceof PsiBinaryExpression)) {
|
||||
if (!(element instanceof PsiPolyadicExpression)) {
|
||||
return false;
|
||||
}
|
||||
if (element instanceof PsiLiteralExpression ||
|
||||
element instanceof PsiClassObjectAccessExpression) {
|
||||
if (element instanceof PsiLiteralExpression || element instanceof PsiClassObjectAccessExpression) {
|
||||
return false;
|
||||
}
|
||||
final PsiBinaryExpression expression = (PsiBinaryExpression)element;
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
if (rhs == null) {
|
||||
final PsiPolyadicExpression expression = (PsiPolyadicExpression)element;
|
||||
final PsiType expressionType = expression.getType();
|
||||
if (expressionType == null) return false;
|
||||
if (expressionType.equalsToText("java.lang.String")) {
|
||||
// intention disabled for string concatenations because of performance issues on
|
||||
// relatively common large string expressions.
|
||||
return false;
|
||||
}
|
||||
final PsiType type = rhs.getType();
|
||||
if (type == null || type.equalsToText("java.lang.String")) {
|
||||
return false;
|
||||
final PsiExpression[] operands = expression.getOperands();
|
||||
for (PsiExpression operand : operands) {
|
||||
if (operand == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType type = operand.getType();
|
||||
if (type == null || type.equalsToText("java.lang.String")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!PsiUtil.isConstantExpression(expression)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
final Object value =
|
||||
ExpressionUtils.computeConstantExpression(expression, true);
|
||||
final Object value = ExpressionUtils.computeConstantExpression(expression, true);
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -54,7 +61,6 @@ class ConstantExpressionPredicate implements PsiElementPredicate {
|
||||
return false;
|
||||
}
|
||||
final PsiElement parent = element.getParent();
|
||||
return !(parent instanceof PsiExpression &&
|
||||
PsiUtil.isConstantExpression((PsiExpression)parent));
|
||||
return !(parent instanceof PsiExpression) || !PsiUtil.isConstantExpression((PsiExpression)parent);
|
||||
}
|
||||
}
|
||||
+96
-99
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,17 +15,13 @@
|
||||
*/
|
||||
package com.siyeh.ipp.constant;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiBinaryExpression;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiJavaToken;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.base.MutablyNamedIntention;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
import com.siyeh.ipp.psiutils.ConcatenationUtils;
|
||||
import com.siyeh.ipp.psiutils.ExpressionUtils;
|
||||
import com.siyeh.ipp.psiutils.HighlightUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConstantSubexpressionIntention extends MutablyNamedIntention {
|
||||
@@ -38,108 +34,109 @@ public class ConstantSubexpressionIntention extends MutablyNamedIntention {
|
||||
|
||||
@Override
|
||||
protected String getTextForElement(PsiElement element) {
|
||||
final PsiBinaryExpression binaryExpression =
|
||||
(PsiBinaryExpression)element.getParent();
|
||||
assert binaryExpression != null;
|
||||
final PsiExpression lhs = binaryExpression.getLOperand();
|
||||
final PsiExpression leftSide;
|
||||
if (lhs instanceof PsiBinaryExpression) {
|
||||
final PsiBinaryExpression lhsBinaryExpression =
|
||||
(PsiBinaryExpression)lhs;
|
||||
leftSide = lhsBinaryExpression.getROperand();
|
||||
final PsiJavaToken token;
|
||||
if (element instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)element;
|
||||
} else {
|
||||
final PsiElement prevSibling = element.getPrevSibling();
|
||||
if (prevSibling instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)prevSibling;
|
||||
} else {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
else {
|
||||
leftSide = lhs;
|
||||
}
|
||||
final PsiJavaToken operationSign = binaryExpression.getOperationSign();
|
||||
final PsiExpression rhs = binaryExpression.getROperand();
|
||||
assert rhs != null;
|
||||
assert leftSide != null;
|
||||
return IntentionPowerPackBundle.message(
|
||||
"constant.subexpression.intention.name", leftSide.getText() +
|
||||
' ' + operationSign.getText() + ' ' + rhs.getText());
|
||||
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)element.getParent();
|
||||
final PsiPolyadicExpression subexpression = ConstantSubexpressionPredicate.getSubexpression(polyadicExpression, token);
|
||||
final String text = HighlightUtil.getPresentableText(subexpression);
|
||||
return IntentionPowerPackBundle.message("constant.expression.intention.name", text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIntention(@NotNull PsiElement element)
|
||||
throws IncorrectOperationException {
|
||||
final PsiExpression expression = (PsiExpression)element.getParent();
|
||||
assert expression != null;
|
||||
String newExpression = "";
|
||||
final Object constantValue;
|
||||
if (expression instanceof PsiBinaryExpression) {
|
||||
final PsiBinaryExpression copy =
|
||||
(PsiBinaryExpression)expression.copy();
|
||||
final PsiExpression lhs = copy.getLOperand();
|
||||
if (lhs instanceof PsiBinaryExpression) {
|
||||
final PsiBinaryExpression lhsBinaryExpression =
|
||||
(PsiBinaryExpression)lhs;
|
||||
newExpression += getLeftSideText(lhsBinaryExpression);
|
||||
final PsiExpression rightSide =
|
||||
lhsBinaryExpression.getROperand();
|
||||
assert rightSide != null;
|
||||
lhs.replace(rightSide);
|
||||
}
|
||||
if (ConcatenationUtils.isConcatenation(expression)) {
|
||||
constantValue = computeConstantStringExpression(copy);
|
||||
}
|
||||
else {
|
||||
constantValue =
|
||||
ExpressionUtils.computeConstantExpression(copy);
|
||||
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
final PsiJavaToken token;
|
||||
if (element instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)element;
|
||||
} else {
|
||||
final PsiElement prevSibling = element.getPrevSibling();
|
||||
if (prevSibling instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)prevSibling;
|
||||
} else {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
else {
|
||||
constantValue =
|
||||
ExpressionUtils.computeConstantExpression(expression);
|
||||
}
|
||||
if (constantValue instanceof String) {
|
||||
newExpression += '"' + StringUtil.escapeStringCharacters(
|
||||
constantValue.toString()) + '"';
|
||||
}
|
||||
else if (constantValue != null) {
|
||||
if (constantValue instanceof Number) {
|
||||
final Number number = (Number)constantValue;
|
||||
if (0 > number.doubleValue()) {
|
||||
newExpression += " ";
|
||||
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)element.getParent();
|
||||
final PsiPolyadicExpression subexpression = ConstantSubexpressionPredicate.getSubexpression(polyadicExpression, token);
|
||||
final Object value = ExpressionUtils.computeConstantExpression(subexpression);
|
||||
final StringBuilder newExpressionText = new StringBuilder();
|
||||
final PsiExpression[] operands = polyadicExpression.getOperands();
|
||||
PsiExpression prevOperand = null;
|
||||
PsiJavaToken prevToken = null;
|
||||
for (PsiExpression operand : operands) {
|
||||
final PsiJavaToken currentToken = polyadicExpression.getTokenBeforeOperand(operand);
|
||||
if (token == currentToken) {
|
||||
if (prevToken != null) {
|
||||
newExpressionText.append(prevToken.getText());
|
||||
}
|
||||
if (newExpressionText.length() > 0) {
|
||||
newExpressionText.append(' ');
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
newExpressionText.append(value).append('L');
|
||||
} else if (value instanceof Double) {
|
||||
final double v = ((Double)value).doubleValue();
|
||||
if (Double.isNaN(v)) {
|
||||
newExpressionText.append("java.lang.Double.NaN");
|
||||
}
|
||||
else if (Double.isInfinite(v)) {
|
||||
if (v > 0.0) {
|
||||
newExpressionText.append("java.lang.Double.POSITIVE_INFINITY");
|
||||
}
|
||||
else {
|
||||
newExpressionText.append("java.lang.Double.NEGATIVE_INFINITY");
|
||||
}
|
||||
}
|
||||
else {
|
||||
newExpressionText.append(Double.toString(v));
|
||||
}
|
||||
}
|
||||
else if (value instanceof Float) {
|
||||
final float v = ((Float)value).floatValue();
|
||||
if (Float.isNaN(v)) {
|
||||
newExpressionText.append("java.lang.Float.NaN");
|
||||
}
|
||||
else if (Float.isInfinite(v)) {
|
||||
if (v > 0.0F) {
|
||||
newExpressionText.append("java.lang.Float.POSITIVE_INFINITY");
|
||||
}
|
||||
else {
|
||||
newExpressionText.append("java.lang.Float.NEGATIVE_INFINITY");
|
||||
}
|
||||
}
|
||||
else {
|
||||
newExpressionText.append(Float.toString(v)).append('f');
|
||||
}
|
||||
} else {
|
||||
newExpressionText.append(value);
|
||||
}
|
||||
prevOperand = null;
|
||||
prevToken = null;
|
||||
} else {
|
||||
if (prevToken != null) {
|
||||
newExpressionText.append(prevToken.getText());
|
||||
}
|
||||
if (prevOperand != null) {
|
||||
newExpressionText.append(prevOperand.getText());
|
||||
}
|
||||
prevOperand = operand;
|
||||
prevToken = currentToken;
|
||||
}
|
||||
newExpression += constantValue.toString();
|
||||
}
|
||||
replaceExpression(newExpression, expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* handles the specified expression as if it was part of a string expression
|
||||
* (even if it's of another type) and computes a constant string expression
|
||||
* from it.
|
||||
*/
|
||||
private static String computeConstantStringExpression(
|
||||
PsiBinaryExpression expression) {
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
final String lhsText = lhs.getText();
|
||||
String result;
|
||||
if (lhsText.charAt(0) == '\'' || lhsText.charAt(0) == '"') {
|
||||
result = lhsText.substring(1, lhsText.length() - 1);
|
||||
if (prevToken != null) {
|
||||
newExpressionText.append(prevToken.getText());
|
||||
}
|
||||
else {
|
||||
result = lhsText;
|
||||
if (prevOperand != null) {
|
||||
newExpressionText.append(prevOperand.getText());
|
||||
}
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
assert rhs != null;
|
||||
final String rhsText = rhs.getText();
|
||||
if (rhsText.charAt(0) == '\'' || rhsText.charAt(0) == '"') {
|
||||
result += rhsText.substring(1, rhsText.length() - 1);
|
||||
}
|
||||
else {
|
||||
result += rhsText;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String getLeftSideText(
|
||||
PsiBinaryExpression binaryExpression) {
|
||||
final PsiExpression lhs = binaryExpression.getLOperand();
|
||||
final PsiJavaToken sign = binaryExpression.getOperationSign();
|
||||
return lhs.getText() + sign.getText();
|
||||
replaceExpression(newExpressionText.toString(), polyadicExpression);
|
||||
}
|
||||
}
|
||||
+43
-53
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,47 +19,71 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
import com.siyeh.ipp.psiutils.ExpressionUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class ConstantSubexpressionPredicate implements PsiElementPredicate {
|
||||
|
||||
public boolean satisfiedBy(PsiElement element) {
|
||||
if (!(element instanceof PsiJavaToken) &&
|
||||
!(element.getPrevSibling() instanceof PsiJavaToken)) {
|
||||
return false;
|
||||
final PsiJavaToken token;
|
||||
if (element instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)element;
|
||||
}
|
||||
else {
|
||||
final PsiElement prevSibling = element.getPrevSibling();
|
||||
if (prevSibling instanceof PsiJavaToken) {
|
||||
token = (PsiJavaToken)prevSibling;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiBinaryExpression)) {
|
||||
if (!(parent instanceof PsiPolyadicExpression)) {
|
||||
return false;
|
||||
}
|
||||
final PsiBinaryExpression binaryExpression =
|
||||
(PsiBinaryExpression)parent;
|
||||
final PsiType type = binaryExpression.getType();
|
||||
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)parent;
|
||||
final PsiType type = polyadicExpression.getType();
|
||||
if (type == null || type.equalsToText("java.lang.String")) {
|
||||
// handled by JoinConcatenatedStringLiteralsIntention
|
||||
return false;
|
||||
}
|
||||
final PsiBinaryExpression subexpression =
|
||||
getSubexpression(binaryExpression);
|
||||
final PsiPolyadicExpression subexpression = getSubexpression(polyadicExpression, token);
|
||||
if (subexpression == null) {
|
||||
return false;
|
||||
}
|
||||
if (binaryExpression.equals(subexpression) &&
|
||||
!isPartOfConstantExpression(binaryExpression)) {
|
||||
// handled by ConstantExpressonIntention
|
||||
if (!isPartOfLargerExpression(polyadicExpression)) {
|
||||
// handled by ConstantExpressionIntention
|
||||
return false;
|
||||
}
|
||||
if (!PsiUtil.isConstantExpression(subexpression)) {
|
||||
return false;
|
||||
}
|
||||
final Object value =
|
||||
ExpressionUtils.computeConstantExpression(subexpression);
|
||||
final Object value = ExpressionUtils.computeConstantExpression(subexpression);
|
||||
return value != null;
|
||||
}
|
||||
|
||||
private static boolean isPartOfConstantExpression(
|
||||
PsiBinaryExpression binaryExpression) {
|
||||
final PsiElement containingElement = binaryExpression.getParent();
|
||||
static PsiPolyadicExpression getSubexpression(PsiPolyadicExpression expression, PsiJavaToken token) {
|
||||
final PsiExpression[] operands = expression.getOperands();
|
||||
if (operands.length == 2) {
|
||||
return expression;
|
||||
}
|
||||
for (int i = 1; i < operands.length; i++) {
|
||||
final PsiExpression operand = operands[i];
|
||||
final PsiJavaToken currentToken = expression.getTokenBeforeOperand(operand);
|
||||
if (currentToken == token) {
|
||||
final String binaryExpressionText = operands[i - 1].getText() + ' ' + token.getText() + ' ' + operand.getText();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(expression.getProject());
|
||||
return (PsiBinaryExpression)factory.createExpressionFromText(binaryExpressionText, expression);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isPartOfLargerExpression(PsiPolyadicExpression expression) {
|
||||
if (expression.getOperands().length > 2) {
|
||||
return true;
|
||||
}
|
||||
final PsiElement containingElement = expression.getParent();
|
||||
if (containingElement instanceof PsiExpression) {
|
||||
final PsiExpression containingExpression =
|
||||
(PsiExpression)containingElement;
|
||||
@@ -72,38 +96,4 @@ class ConstantSubexpressionPredicate implements PsiElementPredicate {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smallest subexpression (if precendence allows it). example:
|
||||
* variable + 2 + 3 normally gets evaluated left to right -> (variable + 2)
|
||||
* + 3 this method returns the right most legal subexpression -> 2 + 3
|
||||
*/
|
||||
@Nullable
|
||||
private static PsiBinaryExpression getSubexpression(
|
||||
PsiBinaryExpression expression) {
|
||||
final PsiExpression rhs = expression.getROperand();
|
||||
if (rhs == null) {
|
||||
return null;
|
||||
}
|
||||
final PsiExpression lhs = expression.getLOperand();
|
||||
if (!(lhs instanceof PsiBinaryExpression)) {
|
||||
return expression;
|
||||
}
|
||||
final PsiBinaryExpression lhsBinaryExpression =
|
||||
(PsiBinaryExpression)lhs;
|
||||
final PsiExpression leftSide = lhsBinaryExpression.getROperand();
|
||||
if (leftSide == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final PsiBinaryExpression binaryExpression =
|
||||
(PsiBinaryExpression)expression.copy();
|
||||
final PsiExpression lOperand = binaryExpression.getLOperand();
|
||||
lOperand.replace(leftSide);
|
||||
return binaryExpression;
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2011 Bas Leijdekkers
|
||||
* Copyright 2007-2012 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -51,32 +52,24 @@ public class HighlightUtil {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
application.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final PsiElement[] elements =
|
||||
PsiUtilBase.toPsiElementArray(elementCollection);
|
||||
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
|
||||
final PsiElement firstElement = elements[0];
|
||||
if (!firstElement.isValid()) {
|
||||
return;
|
||||
}
|
||||
final Project project = firstElement.getProject();
|
||||
final FileEditorManager editorManager =
|
||||
FileEditorManager.getInstance(project);
|
||||
final EditorColorsManager editorColorsManager =
|
||||
EditorColorsManager.getInstance();
|
||||
final FileEditorManager editorManager = FileEditorManager.getInstance(project);
|
||||
final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
|
||||
final Editor editor = editorManager.getSelectedTextEditor();
|
||||
if (editor == null) {
|
||||
return;
|
||||
}
|
||||
final EditorColorsScheme globalScheme =
|
||||
editorColorsManager.getGlobalScheme();
|
||||
final TextAttributes textattributes =
|
||||
globalScheme.getAttributes(
|
||||
final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
|
||||
final TextAttributes textattributes = globalScheme.getAttributes(
|
||||
EditorColors.SEARCH_RESULT_ATTRIBUTES);
|
||||
final HighlightManager highlightManager =
|
||||
HighlightManager.getInstance(project);
|
||||
highlightManager.addOccurrenceHighlights(
|
||||
editor, elements, textattributes, true, null);
|
||||
final FindManager findmanager =
|
||||
FindManager.getInstance(project);
|
||||
final HighlightManager highlightManager = HighlightManager.getInstance(project);
|
||||
highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
|
||||
final FindManager findmanager = FindManager.getInstance(project);
|
||||
FindModel findmodel = findmanager.getFindNextModel();
|
||||
if (findmodel == null) {
|
||||
findmodel = findmanager.getFindInFileModel();
|
||||
@@ -86,11 +79,11 @@ public class HighlightUtil {
|
||||
findmanager.setFindNextModel(findmodel);
|
||||
application.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final WindowManager windowManager =
|
||||
WindowManager.getInstance();
|
||||
final StatusBar statusBar =
|
||||
windowManager.getStatusBar(project);
|
||||
statusBar.setInfo(statusBarText);
|
||||
final WindowManager windowManager = WindowManager.getInstance();
|
||||
final StatusBar statusBar = windowManager.getStatusBar(project);
|
||||
if (statusBar != null) {
|
||||
statusBar.setInfo(statusBarText);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -102,4 +95,27 @@ public class HighlightUtil {
|
||||
final List<PsiElement> elements = Collections.singletonList(element);
|
||||
highlightElements(elements, statusBarText);
|
||||
}
|
||||
|
||||
public static String getPresentableText(PsiElement element) {
|
||||
return getPresentableText(element, new StringBuilder()).toString();
|
||||
}
|
||||
|
||||
private static StringBuilder getPresentableText(PsiElement element, StringBuilder builder) {
|
||||
if (element == null) {
|
||||
return builder;
|
||||
}
|
||||
if (element instanceof PsiWhiteSpace) {
|
||||
return builder.append(' ');
|
||||
}
|
||||
final PsiElement[] children = element.getChildren();
|
||||
if (children.length != 0) {
|
||||
for (PsiElement child : children) {
|
||||
getPresentableText(child, builder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(element.getText());
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -100,8 +100,9 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
|
||||
public GitRepository getRepositoryForFile(@NotNull VirtualFile file) {
|
||||
final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
|
||||
if (vcsRoot == null) { return null; }
|
||||
if (!myVcs.equals(vcsRoot.vcs)) {
|
||||
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcsRoot.vcs.getDisplayName(), file));
|
||||
final AbstractVcs vcs = vcsRoot.vcs;
|
||||
if (!myVcs.equals(vcs)) {
|
||||
LOG.info(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs != null ? vcs.getDisplayName() : vcs, file));
|
||||
return null;
|
||||
}
|
||||
return getRepositoryForRoot(vcsRoot.path);
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.JavaDirectoryService;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
@@ -112,6 +113,7 @@ public class NewGroovyClassAction extends JavaCreateTemplateInPackageAction<GrTy
|
||||
final String fileName = className + NewGroovyActionBase.GROOVY_EXTENSION;
|
||||
final PsiFile fromTemplate = GroovyTemplatesFactory.createFromTemplate(dir, className, fileName, templateName);
|
||||
if (fromTemplate instanceof GroovyFile) {
|
||||
CodeStyleManager.getInstance(fromTemplate.getManager()).reformat(fromTemplate);
|
||||
return ((GroovyFile)fromTemplate).getTypeDefinitions()[0];
|
||||
}
|
||||
final String description = fromTemplate.getFileType().getDescription();
|
||||
|
||||
@@ -34,10 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrForStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
|
||||
/**
|
||||
@@ -118,7 +115,7 @@ public class GroovyBraceEnforcer extends GroovyRecursiveElementVisitor {
|
||||
}
|
||||
|
||||
private void processStatement(GrStatement statement, GrStatement blockCandidate, int options) {
|
||||
if (blockCandidate instanceof GrCodeBlock || blockCandidate == null) return;
|
||||
if (blockCandidate instanceof GrCodeBlock || blockCandidate instanceof GrBlockStatement || blockCandidate == null) return;
|
||||
if (options == CommonCodeStyleSettings.FORCE_BRACES_ALWAYS ||
|
||||
options == CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE && PostFormatProcessorHelper.isMultiline(statement)) {
|
||||
replaceWithBlock(statement, blockCandidate);
|
||||
|
||||
+4
@@ -78,6 +78,10 @@ public abstract class GroovySpacingProcessorBasic {
|
||||
return LAZY_SPACING;
|
||||
}
|
||||
|
||||
if (leftType == GROOVY_DOC_COMMENT) {
|
||||
return COMMON_SPACING_WITH_NL;
|
||||
}
|
||||
|
||||
//For type parameters
|
||||
if (mLT == leftType && right instanceof GrTypeParameter ||
|
||||
mGT == rightType && left instanceof GrTypeParameter ||
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
ShowMatchedRules="false" ShowComments="false" RemoveBlanksInsideCodeBlocks="true">
|
||||
<Items>
|
||||
<Comment condition="2" nPrecedingRulesToMatch="1" nSubsequentRulesToMatch="7" allPrecedingRules="true" allSubsequentRules="false"
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n//\ ------------------------------\ FIELDS\
|
||||
------------------------------\n
|
||||
</Comment>
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n// ------------------------------ FIELDS ------------------------------\n</Comment>
|
||||
<Field priority="1">
|
||||
<ProtectionLevel public="true" private="false" protected="false" package="false" invert="false"/>
|
||||
<Static value="true" invert="false"/>
|
||||
@@ -247,9 +245,7 @@
|
||||
</TrailingComment>
|
||||
</Interface>
|
||||
<Comment condition="2" nPrecedingRulesToMatch="1" nSubsequentRulesToMatch="1" allPrecedingRules="true" allSubsequentRules="true"
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n//\ --------------------------\ OTHER\ METHODS\
|
||||
--------------------------\n
|
||||
</Comment>
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n// -------------------------- OTHER METHODS --------------------------\n</Comment>
|
||||
<Method priority="1">
|
||||
<ProtectionLevel public="false" private="false" protected="false" package="false" invert="false"/>
|
||||
<Static value="false" invert="false"/>
|
||||
@@ -285,9 +281,7 @@
|
||||
<Enum value="true" invert="false"/>
|
||||
</InnerClass>
|
||||
<Comment condition="2" nPrecedingRulesToMatch="1" nSubsequentRulesToMatch="1" allPrecedingRules="true" allSubsequentRules="true"
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n//\ --------------------------\ INNER\ CLASSES\
|
||||
--------------------------\n
|
||||
</Comment>
|
||||
fillString="" useProjectWidthForFill="true" fillWidth="0">\n// -------------------------- INNER CLASSES --------------------------\n</Comment>
|
||||
<InnerClass priority="1">
|
||||
<ProtectionLevel public="false" private="false" protected="false" package="false" invert="false"/>
|
||||
<Static value="false" invert="false"/>
|
||||
|
||||
@@ -30,11 +30,8 @@ import com.wrq.rearranger.settings.RearrangerSettings;
|
||||
* Date: Mar 30, 2004
|
||||
*/
|
||||
@SkipInHeadlessEnvironment
|
||||
public class InteractiveTest
|
||||
extends LightCodeInsightFixtureTestCase
|
||||
{
|
||||
public static final String DEFAULT_CONFIGURATION_ROOT = ".."; // up one level from test
|
||||
public static final String DEFAULT_CONFIGURATION = DEFAULT_CONFIGURATION_ROOT + "/src/com/wrq/rearranger/defaultConfiguration.xml";
|
||||
public class InteractiveTest extends LightCodeInsightFixtureTestCase {
|
||||
public static final String DEFAULT_CONFIGURATION = "/src/com/wrq/rearranger/defaultConfiguration.xml";
|
||||
private RearrangerSettings mySettings;
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@ import org.junit.Assert
|
||||
public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
|
||||
@NotNull def RearrangerSettings settings
|
||||
private int depth
|
||||
|
||||
/**
|
||||
* Holds rule customization handlers in the form {@code 'property id -> closure'} where <code>'property id'</code>
|
||||
@@ -30,25 +31,33 @@ public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
{ key -> Assert.fail("No handler for the rule attribute '${key}'") }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getCurrent() {
|
||||
if (!super.current) {
|
||||
current = createRule()
|
||||
}
|
||||
super.current
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void nodeCompleted(Object parent, Object node) {
|
||||
if (!parent && node) {
|
||||
if (--depth <= 0) {
|
||||
// Top level call on the build object has been reached.
|
||||
registerRule(settings, node as T)
|
||||
current = null
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setParent(Object parent, Object child) {
|
||||
depth++
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name) {
|
||||
if (name == 'create') {
|
||||
return createRule()
|
||||
}
|
||||
createNode(name, [:], [])
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Object value) {
|
||||
createNode(name, [:], value)
|
||||
@@ -61,6 +70,9 @@ public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Map attributes, Object value) {
|
||||
if (!myHandlers.containsKey(name)) {
|
||||
return current
|
||||
}
|
||||
if (value) {
|
||||
for (i in [value].flatten()) {
|
||||
myHandlers[name](i, attributes, current)
|
||||
@@ -70,7 +82,7 @@ public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
myHandlers[name](null, attributes, current)
|
||||
}
|
||||
|
||||
getCurrent()
|
||||
current
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -83,7 +95,7 @@ public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
* <p/>
|
||||
* Example:
|
||||
* <pre>
|
||||
* register('modifier', PsiModifier.FINAL, { rule, value, attributes ->
|
||||
* register('modifier', PsiModifier.FINAL, { value, attributes, rule ->
|
||||
* rule.finalAttribute.value = value
|
||||
* if (attributes.invert) rule.finalAttribute.invert = true
|
||||
* })
|
||||
@@ -143,10 +155,4 @@ public abstract class AbstractRuleBuilder<T> extends BuilderSupport {
|
||||
rule."$propertyName".expression = value
|
||||
}
|
||||
}
|
||||
|
||||
protected static void setIf(@NotNull RearrangerTestDsl dslProperty, map, rulePropertyName, rule) {
|
||||
if (map.containsKey(dslProperty.value)) {
|
||||
rule."$rulePropertyName" = map[dslProperty.value]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,18 @@ class CommentRuleBuilder extends AbstractRuleBuilder<CommentRule> {
|
||||
{
|
||||
registerHandler(RearrangerTestDsl.COMMENT, { data, attributes, rule ->
|
||||
rule.commentText = data
|
||||
setIf(RearrangerTestDsl.CONDITION, attributes, 'emitCondition', rule)
|
||||
setIf(RearrangerTestDsl.ALL_SUBSEQUENT, attributes, 'allSubsequentRules', rule)
|
||||
setIf(RearrangerTestDsl.ALL_PRECEDING, attributes, 'allPrecedingRules', rule)
|
||||
setIf(RearrangerTestDsl.SUBSEQUENT_RULES_TO_MATCH, attributes, 'NSubsequentRulesToMatch', rule)
|
||||
setIf(RearrangerTestDsl.PRECEDING_RULES_TO_MATCH, attributes, 'NPrecedingRulesToMatch', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.CONDITION, attributes, 'emitCondition', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_SUBSEQUENT, attributes, 'allSubsequentRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALL_PRECEDING, attributes, 'allPrecedingRules', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.SUBSEQUENT_RULES_TO_MATCH, attributes, 'NSubsequentRulesToMatch', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.PRECEDING_RULES_TO_MATCH, attributes, 'NPrecedingRulesToMatch', rule)
|
||||
|
||||
def fillString = rule.commentFillString
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.USE_PROJECT_WIDTH_FOR_COMMENT_FILL, attributes, 'useProjectWidthForFill', fillString)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.FILL_WIDTH, attributes, 'fillWidth', fillString)
|
||||
if (attributes[RearrangerTestDsl.FILL_STRING.value]) {
|
||||
rule.commentFillString.fillString = attributes[RearrangerTestDsl.FILL_STRING.value]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @since 5/17/12 12:57 PM
|
||||
*/
|
||||
public enum RearrangerTestDsl {
|
||||
|
||||
// Settings
|
||||
EXTRACTED_METHODS("extracted methods"),
|
||||
OVERLOADED_METHODS("overloaded methods"),
|
||||
DEPTH_FIRST_ORDER("depth-first order"),
|
||||
ORDER,
|
||||
COMMENT_TYPE("commentType"),
|
||||
KEEP_TOGETHER("keep together"),
|
||||
OVERLOADED,
|
||||
GETTERS_SETTERS("getters and setters"),
|
||||
GETTERS_SETTERS_WITH_PROPERTY("getters and setters with property"),
|
||||
|
||||
// Rules
|
||||
NAME,
|
||||
MODIFIER,
|
||||
/** Field initializer type. */
|
||||
@@ -17,23 +29,41 @@ public enum RearrangerTestDsl {
|
||||
/** Method target type (e.g. constructor). */
|
||||
TARGET,
|
||||
TYPE,
|
||||
RETURN_TYPE("returnType"),
|
||||
SORT,
|
||||
RETURN_TYPE("return type"),
|
||||
SORT("sort by"),
|
||||
NOT_SORT("not sort by"),
|
||||
COMMENT,
|
||||
GETTER_CRITERIA("getterCriteria"),
|
||||
SETTER_CRITERIA("setterCriteria"),
|
||||
GETTER_CRITERIA("getter criteria"),
|
||||
SETTER_CRITERIA("setter criteria"),
|
||||
SPACING,
|
||||
PRECEDING_COMMENT("preceding comment"),
|
||||
TRAILING_COMMENT("trailing comment"),
|
||||
SETUP,
|
||||
GROUP_EXTRACTED_METHODS("group extracted methods"),
|
||||
ALPHABETIZE,
|
||||
PRIORITY,
|
||||
|
||||
// Attributes
|
||||
INVERT,
|
||||
CONDITION,
|
||||
ALL_SUBSEQUENT("allSubsequent"),
|
||||
ALL_PRECEDING("allPreceding"),
|
||||
SUBSEQUENT_RULES_TO_MATCH("subsequentRulesToMatch"),
|
||||
PRECEDING_RULES_TO_MATCH("precedingRulesToMatch"),
|
||||
ALL_SUBSEQUENT("all subsequent"),
|
||||
ALL_PRECEDING("all preceding"),
|
||||
SUBSEQUENT_RULES_TO_MATCH("subsequent rules to match"),
|
||||
PRECEDING_RULES_TO_MATCH("preceding rules to match"),
|
||||
BODY,
|
||||
ANCHOR,
|
||||
BLANK_LINES("lines");
|
||||
BLANK_LINES("lines"),
|
||||
REMOVE_BLANK_LINES("remove blank lines"),
|
||||
BELOW_FIRST_CALLER("below first caller"),
|
||||
NON_PRIVATE_TREATMENT("non-private treatment"),
|
||||
REARRANGE_INNER_CLASSES("rearranger inner classes"),
|
||||
CLASS_COMMENT("class comment"),
|
||||
ARGUMENTS_NUMBER("arguments number"),
|
||||
FROM,
|
||||
TO,
|
||||
FILL_STRING("fill string"),
|
||||
USE_PROJECT_WIDTH_FOR_COMMENT_FILL("use project width for fill"),
|
||||
FILL_WIDTH("fill width");
|
||||
|
||||
@NotNull private final String myValue;
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.wrq.rearranger.util
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/22/12 11:11 AM
|
||||
*/
|
||||
public class RearrangerTestUtil {
|
||||
|
||||
private RearrangerTestUtil() {
|
||||
}
|
||||
|
||||
public static void setIf(@NotNull RearrangerTestDsl dslProperty, map, rulePropertyName, rule) {
|
||||
if (map.containsKey(dslProperty.value)) {
|
||||
rule."$rulePropertyName" = map[dslProperty.value]
|
||||
}
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.wrq.rearranger.util
|
||||
|
||||
import com.wrq.rearranger.settings.CommentRule
|
||||
import com.wrq.rearranger.settings.RearrangerSettings
|
||||
|
||||
import static com.wrq.rearranger.util.RearrangerTestUtil.setIf
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/22/12 11:07 AM
|
||||
*/
|
||||
class SettingsConfigurationBuilder extends BuilderSupport {
|
||||
|
||||
def RearrangerSettings settings
|
||||
|
||||
@Override
|
||||
protected void setParent(Object parent, Object child) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name) {
|
||||
createNode(name, [:], [])
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Object value) {
|
||||
createNode(name, [:], value)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Map attributes) {
|
||||
createNode(name, attributes, [])
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Map attributes, Object value) {
|
||||
def commentHandler = { RearrangerTestDsl dslName, propertyName ->
|
||||
if (attributes.containsKey(dslName.value)) {
|
||||
def comment = new CommentRule()
|
||||
comment.commentText = attributes[dslName.value]
|
||||
settings.extractedMethodsSettings."$propertyName" = comment
|
||||
}
|
||||
}
|
||||
|
||||
switch (name) {
|
||||
case RearrangerTestDsl.EXTRACTED_METHODS.value:
|
||||
settings.extractedMethodsSettings.moveExtractedMethods = true
|
||||
setIf(RearrangerTestDsl.DEPTH_FIRST_ORDER, attributes, 'depthFirstOrdering', settings.extractedMethodsSettings)
|
||||
setIf(RearrangerTestDsl.ORDER, attributes, 'ordering', settings.extractedMethodsSettings)
|
||||
setIf(RearrangerTestDsl.COMMENT_TYPE, attributes, 'commentType', settings.extractedMethodsSettings)
|
||||
setIf(RearrangerTestDsl.BELOW_FIRST_CALLER, attributes, 'belowFirstCaller', settings.extractedMethodsSettings)
|
||||
setIf(RearrangerTestDsl.NON_PRIVATE_TREATMENT, attributes, 'nonPrivateTreatment', settings.extractedMethodsSettings)
|
||||
|
||||
commentHandler(RearrangerTestDsl.PRECEDING_COMMENT, 'precedingComment')
|
||||
commentHandler(RearrangerTestDsl.TRAILING_COMMENT, 'trailingComment')
|
||||
break
|
||||
case RearrangerTestDsl.KEEP_TOGETHER.value:
|
||||
def m = [
|
||||
(RearrangerTestDsl.OVERLOADED.value) : 'keepOverloadedMethodsTogether',
|
||||
(RearrangerTestDsl.GETTERS_SETTERS.value) : 'keepGettersSettersTogether',
|
||||
(RearrangerTestDsl.GETTERS_SETTERS_WITH_PROPERTY.value) : 'keepGettersSettersWithProperty'
|
||||
]
|
||||
for (i in [value].flatten()) {
|
||||
settings."${m[i]}" = true
|
||||
}
|
||||
break
|
||||
case RearrangerTestDsl.OVERLOADED_METHODS.value:
|
||||
setIf(RearrangerTestDsl.ORDER, attributes, 'overloadedOrder', settings)
|
||||
setIf(RearrangerTestDsl.KEEP_TOGETHER, attributes, 'keepOverloadedMethodsTogether', settings)
|
||||
break
|
||||
case RearrangerTestDsl.GETTER_CRITERIA.value:
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'getterNameCriterion', settings.defaultGSDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'getterBodyCriterion', settings.defaultGSDefinition)
|
||||
break
|
||||
case RearrangerTestDsl.SETTER_CRITERIA.value:
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'setterNameCriterion', settings.defaultGSDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'setterBodyCriterion', settings.defaultGSDefinition)
|
||||
break
|
||||
default:
|
||||
setIf(RearrangerTestDsl.REARRANGE_INNER_CLASSES, attributes, 'rearrangeInnerClasses', settings)
|
||||
if (attributes[RearrangerTestDsl.CLASS_COMMENT.value]) {
|
||||
def comment = new CommentRule()
|
||||
comment.commentText = attributes[RearrangerTestDsl.CLASS_COMMENT.value]
|
||||
settings.classOrderAttributeList.add(0, comment)
|
||||
}
|
||||
}
|
||||
settings
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -18,10 +18,17 @@ abstract class AbstractJavaRuleBuilder<T> extends AbstractRuleBuilder<T> {{
|
||||
})
|
||||
|
||||
// Sort
|
||||
def sortOptions = [ (SortType.BY_NAME) : "byName"]
|
||||
def sortOptions = [
|
||||
(SortOption.BY_NAME) : 'byName',
|
||||
(SortOption.BY_TYPE) : 'byType',
|
||||
(SortOption.TYPE_CASE_INSENSITIVE) : 'typeCaseInsensitive',
|
||||
]
|
||||
registerHandler(RearrangerTestDsl.SORT, { data, attributes, rule ->
|
||||
rule.sortOptions."${sortOptions[data]}" = true
|
||||
})
|
||||
registerHandler(RearrangerTestDsl.NOT_SORT, { data, attributes, rule ->
|
||||
rule.sortOptions."${sortOptions[data]}" = false
|
||||
})
|
||||
|
||||
// Modifiers
|
||||
// Visibility
|
||||
@@ -48,4 +55,9 @@ abstract class AbstractJavaRuleBuilder<T> extends AbstractRuleBuilder<T> {{
|
||||
genericHandlers[value](attributes, rule)
|
||||
}
|
||||
})
|
||||
|
||||
// Priority.
|
||||
registerHandler(RearrangerTestDsl.PRIORITY, { value, attributes, rule ->
|
||||
rule.priority = value
|
||||
})
|
||||
}}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.wrq.rearranger.util.java
|
||||
|
||||
import com.wrq.rearranger.settings.attributeGroups.InterfaceAttributes
|
||||
import com.wrq.rearranger.settings.RearrangerSettings
|
||||
import com.wrq.rearranger.util.RearrangerTestDsl
|
||||
import com.wrq.rearranger.settings.CommentRule
|
||||
import com.wrq.rearranger.util.RearrangerTestUtil
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/22/12 11:56 AM
|
||||
*/
|
||||
class JavaInterfaceRuleBuilder extends AbstractJavaRuleBuilder<InterfaceAttributes> {
|
||||
|
||||
{
|
||||
def commentHandler = { rule, commentText, propertyName ->
|
||||
def comment = new CommentRule()
|
||||
comment.commentText = commentText
|
||||
rule."$propertyName" = comment
|
||||
}
|
||||
|
||||
def nameHandler = createStringAttributeHandler('nameAttr')
|
||||
|
||||
registerHandler(RearrangerTestDsl.PRECEDING_COMMENT, { value, attributes, rule -> commentHandler(rule, value, 'precedingComment') })
|
||||
registerHandler(RearrangerTestDsl.TRAILING_COMMENT, { value, attributes, rule -> commentHandler(rule, value, 'trailingComment') })
|
||||
registerHandler(RearrangerTestDsl.SETUP, { value, attributes, rule ->
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.GROUP_EXTRACTED_METHODS, attributes, 'noExtractedMethods', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ORDER, attributes, 'methodOrder', rule)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.ALPHABETIZE, attributes, 'alphabetizeInterfaces', rule)
|
||||
if (attributes[RearrangerTestDsl.NAME.value]) {
|
||||
nameHandler(attributes[RearrangerTestDsl.NAME.value], attributes, rule)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InterfaceAttributes createRule() {
|
||||
new InterfaceAttributes()
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRule(RearrangerSettings settings, InterfaceAttributes rule) {
|
||||
settings.addItem(rule)
|
||||
}
|
||||
}
|
||||
+25
-6
@@ -4,6 +4,7 @@ import com.wrq.rearranger.settings.RearrangerSettings
|
||||
import com.wrq.rearranger.settings.attributeGroups.MethodAttributes
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import com.wrq.rearranger.util.RearrangerTestDsl
|
||||
import com.wrq.rearranger.util.RearrangerTestUtil
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -13,19 +14,37 @@ class JavaMethodRuleBuilder extends AbstractJavaRuleBuilder<MethodAttributes> {
|
||||
|
||||
{
|
||||
def handlers = [
|
||||
(MethodType.CONSTRUCTOR) : createRawBooleanAttributeHandler('constructorMethodType'),
|
||||
(MethodType.CONSTRUCTOR) : createRawBooleanAttributeHandler('constructorMethodType'),
|
||||
(MethodType.GETTER_OR_SETTER) : createRawBooleanAttributeHandler('getterSetterMethodType'),
|
||||
(MethodType.OTHER) : createRawBooleanAttributeHandler('otherMethodType')
|
||||
(MethodType.OTHER) : createRawBooleanAttributeHandler('otherMethodType')
|
||||
]
|
||||
registerHandler(RearrangerTestDsl.TARGET, { data, attributes, rule -> handlers[data](attributes, rule) })
|
||||
registerHandler(RearrangerTestDsl.RETURN_TYPE, createStringAttributeHandler('returnTypeAttr'))
|
||||
|
||||
// Getters & setters criteria.
|
||||
registerHandler(RearrangerTestDsl.GETTER_CRITERIA, { data, attributes, rule ->
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'getterNameCriterion', rule.getterSetterDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'getterBodyCriterion', rule.getterSetterDefinition)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.NAME, attributes, 'getterNameCriterion', rule.getterSetterDefinition)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.BODY, attributes, 'getterBodyCriterion', rule.getterSetterDefinition)
|
||||
})
|
||||
registerHandler(RearrangerTestDsl.SETTER_CRITERIA, { data, attributes, rule ->
|
||||
setIf(RearrangerTestDsl.NAME, attributes, 'setterNameCriterion', rule.getterSetterDefinition)
|
||||
setIf(RearrangerTestDsl.BODY, attributes, 'setterBodyCriterion', rule.getterSetterDefinition)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.NAME, attributes, 'setterNameCriterion', rule.getterSetterDefinition)
|
||||
RearrangerTestUtil.setIf(RearrangerTestDsl.BODY, attributes, 'setterBodyCriterion', rule.getterSetterDefinition)
|
||||
})
|
||||
|
||||
// Args number.
|
||||
def argsNumber = [
|
||||
(RearrangerTestDsl.FROM) : 'minParamsAttr',
|
||||
(RearrangerTestDsl.TO) : 'maxParamsAttr'
|
||||
]
|
||||
def argsNumberHandler = { RearrangerTestDsl key, attributes, rule ->
|
||||
if (attributes.containsKey(key.value)) {
|
||||
rule."${argsNumber[key]}".match = true
|
||||
rule."${argsNumber[key]}".value = attributes[key.value]
|
||||
}
|
||||
}
|
||||
registerHandler(RearrangerTestDsl.ARGUMENTS_NUMBER, { data, attributes, rule ->
|
||||
argsNumberHandler(RearrangerTestDsl.FROM, attributes, rule)
|
||||
argsNumberHandler(RearrangerTestDsl.TO, attributes, rule)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ class JavaSpacingRule extends AbstractRuleBuilder<Void> {
|
||||
s.force = true
|
||||
s.nBlankLines = attributes[RearrangerTestDsl.BLANK_LINES.value]
|
||||
}
|
||||
if (attributes[RearrangerTestDsl.REMOVE_BLANK_LINES.value]) {
|
||||
settings.removeBlanksInsideCodeBlocks = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ package com.wrq.rearranger.util.java;
|
||||
* @since 5/17/12 11:05 AM
|
||||
*/
|
||||
public enum MethodType {
|
||||
CONSTRUCTOR, GETTER_OR_SETTER, OTHER
|
||||
CONSTRUCTOR, GETTER_OR_SETTER, OVERLOADED, OTHER
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,6 +4,6 @@ package com.wrq.rearranger.util.java;
|
||||
* @author Denis Zhdanov
|
||||
* @since 5/17/12 3:57 PM
|
||||
*/
|
||||
public enum SortType {
|
||||
BY_NAME
|
||||
public enum SortOption {
|
||||
BY_NAME, BY_TYPE, TYPE_CASE_INSENSITIVE
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,7 @@
|
||||
public class RearrangementTest23
|
||||
implements IFace2, IFace1
|
||||
{
|
||||
|
||||
public int getY() {
|
||||
return 6;
|
||||
}
|
||||
@@ -8,7 +9,6 @@ public class RearrangementTest23
|
||||
public int getX() {
|
||||
return getA() ? 5 : 3;
|
||||
}
|
||||
|
||||
int method1() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,7 +1,8 @@
|
||||
public class RearrangementTest23
|
||||
implements IFace2, IFace1
|
||||
{
|
||||
/** * Interface IFace1 Header *** */
|
||||
/**** Interface IFace1 Header ****/
|
||||
|
||||
public int getY() {
|
||||
return 6;
|
||||
}
|
||||
@@ -10,7 +11,8 @@ public class RearrangementTest23
|
||||
return getA() ? 5 : 3;
|
||||
}
|
||||
/**** Interface IFace1 Trailer ***/
|
||||
/** * Interface IFace2 Header *** */
|
||||
/**** Interface IFace2 Header ****/
|
||||
|
||||
public boolean getB() {
|
||||
return false;
|
||||
}
|
||||
@@ -18,8 +20,7 @@ public class RearrangementTest23
|
||||
public boolean getA() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** * Interface IFace2 Trailer ** */
|
||||
/**** Interface IFace2 Trailer ***/
|
||||
int method1() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,7 +1,8 @@
|
||||
public class RearrangementTest23
|
||||
implements IFace2, IFace1
|
||||
{
|
||||
/** * Interface IFace2 Header *** */
|
||||
/**** Interface IFace2 Header ****/
|
||||
|
||||
public boolean getA() {
|
||||
return true;
|
||||
}
|
||||
@@ -10,7 +11,8 @@ public class RearrangementTest23
|
||||
return false;
|
||||
}
|
||||
/**** Interface IFace2 Trailer ***/
|
||||
/** * Interface IFace1 Header *** */
|
||||
/**** Interface IFace1 Header ****/
|
||||
|
||||
public int getX() {
|
||||
return getA() ? 5 : 3;
|
||||
}
|
||||
@@ -18,8 +20,7 @@ public class RearrangementTest23
|
||||
public int getY() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
/** * Interface IFace1 Trailer ** */
|
||||
/**** Interface IFace1 Trailer ***/
|
||||
int method1() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,7 +1,8 @@
|
||||
public class RearrangementTest23
|
||||
implements IFace2, IFace1
|
||||
{
|
||||
/** * Interface IFace2 Header *** */
|
||||
/**** Interface IFace2 Header ****/
|
||||
|
||||
public boolean getB() {
|
||||
return false;
|
||||
}
|
||||
@@ -10,7 +11,8 @@ public class RearrangementTest23
|
||||
return true;
|
||||
}
|
||||
/**** Interface IFace2 Trailer ***/
|
||||
/** * Interface IFace1 Header *** */
|
||||
/**** Interface IFace1 Header ****/
|
||||
|
||||
public int getY() {
|
||||
return 6;
|
||||
}
|
||||
@@ -18,8 +20,7 @@ public class RearrangementTest23
|
||||
public int getX() {
|
||||
return getA() ? 5 : 3;
|
||||
}
|
||||
|
||||
/** * Interface IFace1 Trailer ** */
|
||||
/**** Interface IFace1 Trailer ***/
|
||||
int method1() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,7 +1,8 @@
|
||||
public class RearrangementTest23
|
||||
implements IFace2, IFace1
|
||||
{
|
||||
/** * Interface IFace2 Header *** */
|
||||
/**** Interface IFace2 Header ****/
|
||||
|
||||
public boolean getA() {
|
||||
return true;
|
||||
}
|
||||
@@ -10,7 +11,8 @@ public class RearrangementTest23
|
||||
return false;
|
||||
}
|
||||
/**** Interface IFace2 Trailer ***/
|
||||
/** * Interface IFace1 Header *** */
|
||||
/**** Interface IFace1 Header ****/
|
||||
|
||||
public int getY() {
|
||||
return 6;
|
||||
}
|
||||
@@ -18,8 +20,7 @@ public class RearrangementTest23
|
||||
public int getX() {
|
||||
return getA() ? 5 : 3;
|
||||
}
|
||||
|
||||
/** * Interface IFace1 Trailer ** */
|
||||
/**** Interface IFace1 Trailer ***/
|
||||
int method1() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ class RearrangementTest26 {
|
||||
public void setValue(int i) {
|
||||
value = i;
|
||||
}
|
||||
|
||||
int value;
|
||||
|
||||
{
|
||||
|
||||
@@ -1,37 +1,32 @@
|
||||
public class RearrangementTest28
|
||||
implements InterfaceName, InterfaceName2
|
||||
{
|
||||
// start of fields
|
||||
// start of fields
|
||||
int i;
|
||||
|
||||
// end of fields
|
||||
// end of fields
|
||||
// start of interface InterfaceName
|
||||
// Level 1 methods
|
||||
public int getTime() {
|
||||
return getAnother();
|
||||
}
|
||||
|
||||
// Level 2 methods
|
||||
// Level 2 methods
|
||||
public int getAnother() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// end Level 2 methods
|
||||
// end Level 2 methods
|
||||
// end Level 1 methods
|
||||
// end of interface InterfaceName
|
||||
// start of interface InterfaceName2
|
||||
public int getDate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// end of interface InterfaceName2
|
||||
// end of interface InterfaceName2
|
||||
// Level 1 methods
|
||||
public void m1() {
|
||||
m2();
|
||||
m3();
|
||||
}
|
||||
|
||||
// Level 2 methods
|
||||
// Level 2 methods
|
||||
public void m2() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
public class RearrangementTest41 {
|
||||
public final void setPrice(final double price) {
|
||||
public final void setPrice(final double price)
|
||||
{
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
public class RearrangementTest43 {
|
||||
|
||||
void method2(int a, int b) {
|
||||
}
|
||||
|
||||
@@ -7,7 +8,6 @@ public class RearrangementTest43 {
|
||||
|
||||
void method1(int a) {
|
||||
}
|
||||
|
||||
void method0() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** test generated comment with fill. */
|
||||
public class RearrangementTest44 {
|
||||
// -+-+-+-+- METHODS -+-+-+-+-
|
||||
// -+-+-+-+- METHODS -+-+-+-+-
|
||||
private void method(int i) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
public class Temp {
|
||||
// ------------------------------ FIELDS ------------------------------
|
||||
|
||||
// ------------------------------ FIELDS ------------------------------
|
||||
|
||||
int field1;
|
||||
|
||||
// -------------------------- OTHER METHODS --------------------------
|
||||
|
||||
@@ -179,9 +179,7 @@
|
||||
noExtractedMethods="false"/>
|
||||
<GetterSetterDefinition getterBody="0" getterName="0" setterBody="0" setterName="0"/>
|
||||
</Method>
|
||||
<Comment condition="2" nPrecedingRulesToMatch="1" nSubsequentRulesToMatch="3" allPrecedingRules="true" allSubsequentRules="false">\n\
|
||||
\ //////////////////////////////////////////////\n\ \ //\ Instance\ Methods\n\ \ //////////////////////////////////////////////
|
||||
</Comment>
|
||||
<Comment condition="2" nPrecedingRulesToMatch="1" nSubsequentRulesToMatch="3" allPrecedingRules="true" allSubsequentRules="false">\n //////////////////////////////////////////////\n // Instance Methods\n //////////////////////////////////////////////</Comment>
|
||||
<Method alphabetize="true" priority="1">
|
||||
<ProtectionLevel public="true" private="false" protected="false" package="false" invert="false"/>
|
||||
<Static value="true" invert="true"/>
|
||||
|
||||
+1
-6
@@ -79,12 +79,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
// TODO: support keys
|
||||
|
||||
if (myActionPanel != null) {
|
||||
return myActionPanel.getData(dataId);
|
||||
}
|
||||
return null;
|
||||
return myActionPanel == null ? null : myActionPanel.getData(dataId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
-1
@@ -681,7 +681,6 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
// TODO: support keys
|
||||
return myActionPanel.getData(dataId);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -49,17 +49,17 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
DefaultActionGroup actionGroup = new DefaultActionGroup();
|
||||
|
||||
ShowJavadoc showJavadoc = new ShowJavadoc();
|
||||
ShowJavadoc showJavadoc = new ShowJavadoc(myPropertyTable);
|
||||
showJavadoc.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_QUICK_JAVADOC).getShortcutSet(), myPropertyTable);
|
||||
actionGroup.add(showJavadoc);
|
||||
|
||||
actionGroup.addSeparator();
|
||||
|
||||
RestoreDefault restoreDefault = new RestoreDefault();
|
||||
RestoreDefault restoreDefault = new RestoreDefault(myPropertyTable);
|
||||
restoreDefault.registerCustomShortcutSet(actionManager.getAction(IdeActions.ACTION_DELETE).getShortcutSet(), myPropertyTable);
|
||||
actionGroup.add(restoreDefault);
|
||||
|
||||
actionGroup.add(new ShowExpert());
|
||||
actionGroup.add(new ShowExpert(myPropertyTable));
|
||||
|
||||
PopupHandler.installPopupHandler(myPropertyTable, actionGroup,
|
||||
ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP,
|
||||
@@ -92,7 +92,7 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
for (AnAction action : myActions) {
|
||||
if (action instanceof IPropertyTableAction) {
|
||||
((IPropertyTableAction)action).update(myPropertyTable);
|
||||
((IPropertyTableAction)action).update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -15,11 +15,9 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface IPropertyTableAction {
|
||||
void update(PropertyTable table);
|
||||
void update();
|
||||
}
|
||||
+9
-9
@@ -16,7 +16,6 @@
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -28,7 +27,11 @@ import com.intellij.openapi.util.IconLoader;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
public RestoreDefault() {
|
||||
private final PropertyTable myTable;
|
||||
|
||||
public RestoreDefault(PropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
String text = DesignerBundle.message("designer.properties.restore_default");
|
||||
presentation.setText(text);
|
||||
@@ -38,13 +41,12 @@ public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
setEnabled(table, e.getPresentation());
|
||||
setEnabled(myTable, e.getPresentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PropertyTable table) {
|
||||
setEnabled(table, getTemplatePresentation());
|
||||
public void update() {
|
||||
setEnabled(myTable, getTemplatePresentation());
|
||||
}
|
||||
|
||||
private static void setEnabled(PropertyTable table, Presentation presentation) {
|
||||
@@ -57,10 +59,8 @@ public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
table.restoreDefaultValue();
|
||||
myTable.restoreDefaultValue();
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -16,7 +16,6 @@
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
@@ -27,7 +26,11 @@ import com.intellij.openapi.util.IconLoader;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ShowExpert extends ToggleAction {
|
||||
public ShowExpert() {
|
||||
private final PropertyTable myTable;
|
||||
|
||||
public ShowExpert(PropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
String text = DesignerBundle.message("designer.properties.show.expert");
|
||||
presentation.setText(text);
|
||||
@@ -37,13 +40,11 @@ public class ShowExpert extends ToggleAction {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
return table.isShowExpert();
|
||||
return myTable.isShowExpert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
table.showExpert(state);
|
||||
myTable.showExpert(state);
|
||||
}
|
||||
}
|
||||
+10
-9
@@ -18,7 +18,6 @@ package com.intellij.designer.propertyTable.actions;
|
||||
import com.intellij.codeInsight.documentation.DocumentationComponent;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -42,7 +41,11 @@ import java.awt.*;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
public ShowJavadoc() {
|
||||
private final PropertyTable myTable;
|
||||
|
||||
public ShowJavadoc(PropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
String text = DesignerBundle.message("designer.properties.show.javadoc");
|
||||
presentation.setText(text);
|
||||
@@ -52,13 +55,12 @@ public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
setEnabled(table, e.getPresentation());
|
||||
setEnabled(myTable, e.getPresentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PropertyTable table) {
|
||||
setEnabled(table, getTemplatePresentation());
|
||||
public void update() {
|
||||
setEnabled(myTable, getTemplatePresentation());
|
||||
}
|
||||
|
||||
private static void setEnabled(PropertyTable table, Presentation presentation) {
|
||||
@@ -72,8 +74,7 @@ public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
|
||||
final DocumentationComponent component = new DocumentationComponent(documentationManager);
|
||||
|
||||
final PropertyTable table = DesignerToolWindowManager.getInstance(project).getPropertyTable();
|
||||
final Property property = table.getSelectionProperty();
|
||||
final Property property = myTable.getSelectionProperty();
|
||||
PsiElement javadocElement = property.getJavadocElement();
|
||||
|
||||
ActionCallback callback;
|
||||
@@ -106,7 +107,7 @@ public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
.createPopup();
|
||||
component.setHint(hint);
|
||||
Disposer.register(hint, component);
|
||||
hint.show(new RelativePoint(table.getParent(), new Point(0, 0)));
|
||||
hint.show(new RelativePoint(myTable.getParent(), new Point(0, 0)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user