cidr-formatter: alignment groups

This commit is contained in:
Anton Makeev
2010-09-10 16:45:51 +04:00
parent 155bc406e6
commit 4f08c0cb97
2 changed files with 10 additions and 9 deletions
@@ -18,9 +18,10 @@ package com.intellij.formatting.alignment;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import java.util.*;
import static java.util.Arrays.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Encapsulates information necessary for correct <code>'align in columns'</code> processing.
@@ -59,7 +60,7 @@ public class AlignmentInColumnsConfig {
IElementType ... targetDeclarationTypes)
{
this(Collections.singleton(stopMultilineCheckElementTypes), whiteSpaceTokenTypes, commentTokenTypes, equalType,
asList(targetDeclarationTypes));
targetDeclarationTypes);
}
/**
@@ -96,13 +97,13 @@ public class AlignmentInColumnsConfig {
TokenSet whiteSpaceTokenTypes,
TokenSet commentTokenTypes,
IElementType equalType,
Collection<IElementType> targetDeclarationTypes)
IElementType... targetDeclarationTypes)
{
myStopMultilineCheckElementTypes.addAll(stopMultilineCheckElementTypes);
myWhiteSpaceTokenTypes = whiteSpaceTokenTypes;
myCommentTokenTypes = commentTokenTypes;
myEqualType = equalType;
myTargetDeclarationTypes.addAll(targetDeclarationTypes);
Collections.addAll(myTargetDeclarationTypes, targetDeclarationTypes);
}
/**
@@ -171,13 +171,13 @@ public class AlignmentInColumnsHelper {
/**
* There is a possible case that given base node doesn't have {@link AlignmentInColumnsConfig#getTargetDeclarationTypes() target type}
* but it's first child node or first child node of the first child node etc does.
* but its first child node or first child node of the first child node etc does.
* <p/>
* This method tries to derive node of the target type from the given node.
*
* @param baseNode base node to process
* @param targetTypes target node types
* @return base node or it's first descendant child that has
* @return base node or its first descendant child that has
* {@link AlignmentInColumnsConfig#getTargetDeclarationTypes() target type} target type if the one if found;
* <code>null</code> otherwise
*/
@@ -302,7 +302,7 @@ public class AlignmentInColumnsHelper {
* @param type target child node type
* @return <code>true</code> if given parent node contains direct child of the given type; <code>false</code> otherwise
*/
public static boolean containsSubNodeOfType(ASTNode node, IElementType type) {
private static boolean containsSubNodeOfType(ASTNode node, IElementType type) {
for(ASTNode child = node.getFirstChildNode(); child != null && child.getTreeParent() == node; child = child.getTreeNext()) {
if (child.getElementType() == type) {
return true;