process c-style arrays in setInitializer (IDEA-20538 )

This commit is contained in:
anna
2011-08-26 17:57:19 +02:00
parent 79e57eb2d3
commit 9bc5f34ff8
3 changed files with 21 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ import com.intellij.psi.impl.GeneratedMarkerVisitor;
import com.intellij.psi.impl.source.PsiTypeElementImpl;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.CharTable;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
@@ -154,7 +155,9 @@ public class JavaSharedImplUtil {
if (eq == null) {
final CharTable charTable = SharedImplUtil.findCharTableByTree(variableElement);
eq = Factory.createSingleLeafElement(JavaTokenType.EQ, "=", 0, 1, charTable, variable.getManager());
variableElement.addInternal((TreeElement)eq, eq, variable.getNameIdentifier().getNode(), Boolean.FALSE);
PsiElement element = variable.getNameIdentifier();
final ASTNode node = TreeUtil.skipElements(element.getNode().getTreeNext(), TokenSet.orSet(ElementType.WHITE_SPACE_BIT_SET, TokenSet.create(JavaTokenType.LBRACKET, JavaTokenType.RBRACKET)));
variableElement.addInternal((TreeElement)eq, eq, node, Boolean.TRUE);
eq = variableElement.findChildByRole(ChildRole.INITIALIZER_EQ);
}
variable.addAfter(initializer, eq.getPsi());

View File

@@ -0,0 +1,8 @@
// "Move assignment to field declaration" "true"
public class Foo {
protected boolean isString[] = new boolean[123];
public Foo() {
}
}

View File

@@ -0,0 +1,9 @@
// "Move assignment to field declaration" "true"
public class Foo {
protected boolean isString[] ;
public Foo() {
isSt<caret>ring = new boolean[123];
}
}