Java Code Examples for com.intellij.lang.ASTNode.getTextLength()

The following are Jave code examples for showing how to use getTextLength() of the com.intellij.lang.ASTNode class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-csv-validator   File: CsvBlock.java   Source Code and License Vote up 5 votes
@Override
protected List<Block> buildChildren() {
    List<ASTNode> todoNodes = new ArrayList<>();
    List<Block> blocks = new ArrayList<>();
    todoNodes.add(getNode().getFirstChildNode());
    CsvBlockField currentField = null;
    while (todoNodes.size() > 0) {
        ASTNode node = todoNodes.remove(todoNodes.size() - 1);
        if (node == null) {
            continue;
        }
        
        IElementType elementType = node.getElementType();
        todoNodes.add(node.getTreeNext());
        if (elementType == CsvTypes.RECORD) {
            todoNodes.add(node.getFirstChildNode());
        } else if (elementType == CsvTypes.FIELD) {
            currentField = new CsvBlockField(node, formattingInfo);
            if (currentField.getTextLength() > 0) {
                blocks.add(currentField);
            }
        } else if (elementType == CsvTypes.COMMA || elementType == CsvTypes.CRLF) {
            blocks.add(new CsvBlockElement(node, formattingInfo, currentField));
        } else if (elementType != TokenType.WHITE_SPACE && node.getTextLength() > 0) {
            blocks.add(new CsvDummyBlock(node, formattingInfo));
        }
    }
    return blocks;
}
 
Example 2
Project: intellij-csv-validator   File: CsvFormatHelper.java   Source Code and License Vote up 5 votes
public static int getTextLength(ASTNode node, CodeStyleSettings codeStyleSettings) {
    CsvCodeStyleSettings csvCodeStyleSettings = codeStyleSettings.getCustomSettings(CsvCodeStyleSettings.class);
    String text = node.getText();
    int length = node.getTextLength();
    if (csvCodeStyleSettings.TABULARIZE && !csvCodeStyleSettings.WHITE_SPACES_OUTSIDE_QUOTES && text.startsWith("\"")) {
        text = text.substring(1, text.length() - 1);
        text = BEGIN_WHITE_SPACE_PATTERN.matcher(text).replaceFirst("");
        text = END_WHITE_SPACE_PATTERN.matcher(text).replaceFirst("");
        length = text.length() + 2;
    }
    return length;
}
 
Example 3
Project: AppleScript-IDEA   File: AppleScriptSpacingProcessor.java   Source Code and License Vote up 4 votes
private static boolean isWhiteSpace(final ASTNode node) {
  return node != null && (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(node) || node.getTextLength() == 0);
}