WI-2085: PHP: Enter after a statement adds superfluous indent

This commit is contained in:
Rustam.Vishnyakov
2010-05-28 17:33:46 +04:00
parent cce30cd2ba
commit e9c6928e81
2 changed files with 10 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.formatter.common.AbstractBlock;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.templateLanguages.OuterLanguageElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlElementType;
import com.intellij.psi.xml.XmlTag;
@@ -163,6 +164,14 @@ public abstract class AbstractSyntheticBlock implements Block{
return false;
}
/**
* Checks if the block contains a single node which belongs to the outer (template) language.
* @return True if it does, False otherwise.
*/
public boolean isOuterLanguageBlock() {
return (myStartTreeNode == myEndTreeNode) && (myStartTreeNode instanceof OuterLanguageElement);
}
public boolean isLeaf() {
return false;
}

View File

@@ -177,6 +177,7 @@ public class SyntheticBlock extends AbstractSyntheticBlock implements Block, Rea
@NotNull
public ChildAttributes getChildAttributes(final int newChildIndex) {
if (isOuterLanguageBlock()) return ChildAttributes.DELEGATE_TO_NEXT_CHILD;
final List<Block> subBlocks = getSubBlocks();
final int prevBlockIndex = newChildIndex - 1;
if (prevBlockIndex >= 0 && prevBlockIndex < subBlocks.size()) {