use of com.intellij.formatting.templateLanguages.DataLanguageBlockWrapper in project intellij-community by JetBrains.
the class BlockTreeNode method update.
@Override
protected void update(PresentationData presentation) {
String name = myBlock.getClass().getSimpleName();
if (myBlock instanceof DataLanguageBlockWrapper) {
name += " (" + ((DataLanguageBlockWrapper) myBlock).getOriginal().getClass().getSimpleName() + ")";
}
presentation.addText(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
if (myBlock.getIndent() != null) {
presentation.addText(" " + String.valueOf(myBlock.getIndent()).replaceAll("[<>]", " "), SimpleTextAttributes.GRAY_ATTRIBUTES);
} else {
presentation.addText(" Indent: null", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
if (myBlock.getAlignment() != null) {
float d = 1.f * System.identityHashCode(myBlock.getAlignment()) / Integer.MAX_VALUE;
Color color = new JBColor(Color.HSBtoRGB(1.0f * d, .3f, .7f), Color.HSBtoRGB(1.0f * d, .3f, .8f));
presentation.addText(" " + String.valueOf(myBlock.getAlignment()), new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, color));
}
if (myBlock.getWrap() != null) {
presentation.addText(" " + String.valueOf(myBlock.getWrap()), new SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, PlatformColors.BLUE));
}
}
use of com.intellij.formatting.templateLanguages.DataLanguageBlockWrapper in project intellij-plugins by JetBrains.
the class CfmlBlock method getChildAttributes.
@NotNull
@Override
public ChildAttributes getChildAttributes(int newChildIndex) {
List<Block> childBlockList = getSubBlocks();
if (newChildIndex > 0 && newChildIndex - 1 < childBlockList.size()) {
ASTBlock prevBlock = (ASTBlock) childBlockList.get(newChildIndex - 1);
if (prevBlock != null) {
Indent indent;
Alignment alignment = myAlignmentProcessor.createChildAlignment();
ASTNode prevNode = prevBlock.getNode();
if (prevNode != null) {
PsiElement prevTreePsiElement = prevNode.getTreePrev() != null ? prevNode.getTreePrev().getPsi() : null;
IElementType prevBlockType = prevNode.getElementType();
if (prevBlockType == CfscriptTokenTypes.L_CURLYBRACKET) {
if (myNode.getElementType() == CfmlElementTypes.FUNCTION_DEFINITION && mySettings.METHOD_BRACE_STYLE == CommonCodeStyleSettings.NEXT_LINE_SHIFTED2) {
indent = Indent.getSpaceIndent(superSettings.getIndentSize(CfmlFileType.INSTANCE) * 2);
} else if (mySettings.BRACE_STYLE == CommonCodeStyleSettings.NEXT_LINE_SHIFTED2) {
indent = Indent.getSpaceIndent(superSettings.getIndentSize(CfmlFileType.INSTANCE) * 2);
} else {
indent = Indent.getNormalIndent();
}
} else if (myNode.getElementType() == CfmlStubElementTypes.CFML_FILE) {
indent = Indent.getNoneIndent();
} else if ((prevBlockType == CfmlTokenTypes.R_ANGLEBRACKET) && prevTreePsiElement != null && !prevTreePsiElement.getText().equalsIgnoreCase("cfscript")) {
indent = Indent.getNormalIndent();
} else if ((prevBlockType == CfmlTokenTypes.CLOSER) && prevTreePsiElement != null && !prevTreePsiElement.getText().equalsIgnoreCase("cfscript")) {
indent = null;
} else if (prevBlockType == CfmlElementTypes.TAG || prevBlockType == CfmlElementTypes.ARGUMENT_TAG || prevBlockType == CfmlElementTypes.COMPONENT_TAG || prevBlockType == CfmlElementTypes.FUNCTION_TAG || prevBlockType == CfmlElementTypes.SCRIPT_TAG) {
indent = Indent.getNormalIndent();
} else if (prevBlockType == CfmlTokenTypes.COMMENT || prevBlockType == CfmlElementTypes.TEMPLATE_TEXT) {
//getChildAttributes(newChildIndex - 1).getChildIndent();
indent = prevBlock.getIndent();
} else {
indent = Indent.getNormalIndent();
}
} else {
indent = ((DataLanguageBlockWrapper) prevBlock).getOriginal().getIndent();
}
return new ChildAttributes(indent, alignment);
}
}
return super.getChildAttributes(newChildIndex);
}
Aggregations