mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Alignment on "public, static, void, <T>, throws" replaced with none indent.
Previously alignment were created for mostly every element of method/class declaration
|public |void |run() {
}
Therefore, when posprocess reformat is used in reformat context mode on "run" rename will be reformatted whole method declaration starting with public, which sometimes can be not usefull
This commit is contained in:
@@ -399,7 +399,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
return createAlignment(mySettings.ALIGN_MULTILINE_BINARY_OPERATION, defaultAlignment);
|
||||
}
|
||||
if (nodeType == JavaElementType.CLASS || nodeType == JavaElementType.METHOD) {
|
||||
return Alignment.createAlignment();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -161,12 +161,23 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
|
||||
else if (isSimpleStatement(child) || StdTokenSets.COMMENT_BIT_SET.contains(child.getElementType())){
|
||||
return getCodeBlockInternalIndent(1);
|
||||
}
|
||||
else if (isNodeParentMethod(child) &&
|
||||
(child.getElementType() == JavaElementType.TYPE
|
||||
|| child.getElementType() == JavaTokenType.IDENTIFIER
|
||||
|| child.getElementType() == JavaElementType.THROWS_LIST
|
||||
|| child.getElementType() == JavaElementType.TYPE_PARAMETER_LIST)) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
else {
|
||||
return Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isNodeParentMethod(@NotNull ASTNode node) {
|
||||
return node.getTreeParent() != null && node.getTreeParent().getElementType() == JavaElementType.METHOD;
|
||||
}
|
||||
|
||||
private Indent calcIndentBefore(final ASTNode child, final int state) {
|
||||
if (state == AFTER_ELSE) {
|
||||
if (!mySettings.SPECIAL_ELSE_IF_TREATMENT) {
|
||||
|
||||
@@ -260,17 +260,22 @@ public class CodeBlockBlock extends AbstractJavaBlock {
|
||||
}
|
||||
|
||||
private Indent calcCurrentIndent(final ASTNode child, final int state) {
|
||||
if (isRBrace(child) || child.getElementType() == JavaTokenType.AT) {
|
||||
IElementType elementType = child.getElementType();
|
||||
if (isRBrace(child) || elementType == JavaTokenType.AT) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
|
||||
if (state == BEFORE_FIRST) return Indent.getNoneIndent();
|
||||
|
||||
if (child.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) {
|
||||
if (elementType == JavaElementType.SWITCH_LABEL_STATEMENT) {
|
||||
return getCodeBlockInternalIndent(myChildrenIndent);
|
||||
}
|
||||
if (state == BEFORE_LBRACE) {
|
||||
if (isLBrace(child)) {
|
||||
if (isLBrace(child)
|
||||
|| elementType == JavaTokenType.CLASS_KEYWORD
|
||||
|| elementType == JavaTokenType.INTERFACE_KEYWORD
|
||||
|| elementType == JavaTokenType.IDENTIFIER
|
||||
|| elementType == JavaTokenType.ENUM_KEYWORD) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -21,11 +21,13 @@ import com.intellij.formatting.Indent;
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.formatting.alignment.AlignmentStrategy;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -63,14 +65,18 @@ public class ExtendsListBlock extends AbstractJavaBlock{
|
||||
|
||||
while (child != null) {
|
||||
if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){
|
||||
if (ElementType.KEYWORD_BIT_SET.contains(child.getElementType())) {
|
||||
IElementType elementType = child.getElementType();
|
||||
if (ElementType.KEYWORD_BIT_SET.contains(elementType)) {
|
||||
if (!elementsExceptKeyword.isEmpty()) {
|
||||
result.add(new SyntheticCodeBlock(elementsExceptKeyword, null, mySettings, myJavaSettings, Indent.getNoneIndent(), null));
|
||||
elementsExceptKeyword = new ArrayList<Block>();
|
||||
}
|
||||
result.add(createJavaBlock(child, mySettings, myJavaSettings, myChildIndent, arrangeChildWrap(child, childWrap), alignment));
|
||||
Indent indent = mySettings.ALIGN_THROWS_KEYWORD
|
||||
&& elementType == JavaTokenType.THROWS_KEYWORD ? Indent.getNoneIndent() : myChildIndent;
|
||||
|
||||
result.add(createJavaBlock(child, mySettings, myJavaSettings, indent, arrangeChildWrap(child, childWrap), alignment));
|
||||
} else {
|
||||
Alignment candidate = myAlignmentStrategy.getAlignment(child.getElementType());
|
||||
Alignment candidate = myAlignmentStrategy.getAlignment(elementType);
|
||||
if (candidate != null) {
|
||||
alignment = myChildAlignment = candidate;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
// "Annotate as @SafeVarargs" "true"
|
||||
import java.util.List;
|
||||
public class Test {
|
||||
public <T> @SafeVarargs
|
||||
static void main(List<T>... args) {
|
||||
public <T> @SafeVarargs
|
||||
static void main(List<T>... args) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// "Annotate as @SafeVarargs" "true"
|
||||
import java.util.List;
|
||||
public class Test {
|
||||
public <T> static void m<caret>ain(List<T>... args) {
|
||||
public <T> static void m<caret>ain(List<T>... args) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user